~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs25/branch.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-08-21 14:58:54 UTC
  • mfrom: (1.1.8 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080821145854-4b49x09r4zmvlk5o
Tags: 0+20080719-4
01_vserver_apparmor.dpatch: [UPDATE] Disable vserver patches on kernel 
2.6.26, because they are not needed anymore. (Closes: #495921)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
 * branch management
21
21
 *
22
 
 * $Id: branch.c,v 1.7 2008/06/02 02:36:59 sfjro Exp $
 
22
 * $Id: branch.c,v 1.10 2008/07/14 00:13:49 sfjro Exp $
23
23
 */
24
24
 
25
25
#include <linux/iso_fs.h>
32
32
{
33
33
        AuTraceEnter();
34
34
 
35
 
        if (br->br_xino)
36
 
                fput(br->br_xino);
 
35
        if (br->br_xino.xi_file)
 
36
                fput(br->br_xino.xi_file);
37
37
        dput(br->br_wh);
38
38
        dput(br->br_plink);
39
39
        if (!au_test_nfs(br->br_mnt->mnt_sb))
124
124
 
125
125
        LKTRTrace("%.*s, %.*s\n", AuDLNPair(h_d1), AuDLNPair(h_d2));
126
126
 
127
 
        err = au_test_subdir(h_d1, h_d2);
 
127
        err = !!au_test_subdir(h_d1, h_d2);
128
128
        AuTraceErr(err);
129
129
        return err;
130
130
}
170
170
                      struct dentry *h_root, struct vfsmount *h_mnt)
171
171
{
172
172
        int err, old_perm;
173
 
        struct inode *dir, *h_dir;
174
 
        const int new = (bindex < 0);
 
173
        struct inode *h_dir;
175
174
 
176
175
        LKTRTrace("b%d, new_perm %d\n", bindex, new_perm);
177
176
 
178
 
        dir = sb->s_root->d_inode;
179
177
        h_dir = h_root->d_inode;
180
 
        if (new)
181
 
                mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
182
 
        else
183
 
                au_hdir_lock(h_dir, dir, bindex);
184
 
 
 
178
        mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
185
179
        br_wh_write_lock(br);
186
180
        old_perm = br->br_perm;
187
181
        br->br_perm = new_perm;
188
 
        err = au_wh_init(h_root, br, au_do_nfsmnt(h_mnt), sb);
 
182
        err = au_wh_init(h_root, br, au_do_nfsmnt(h_mnt), sb, bindex);
189
183
        br->br_perm = old_perm;
190
184
        br_wh_write_unlock(br);
191
 
 
192
 
        if (new)
193
 
                mutex_unlock(&h_dir->i_mutex);
194
 
        else
195
 
                au_hdir_unlock(h_dir, dir, bindex);
 
185
        mutex_unlock(&h_dir->i_mutex);
196
186
 
197
187
        AuTraceErr(err);
198
188
        return err;
221
211
        inode = root->d_inode;
222
212
        IiMustWriteLock(inode);
223
213
 
224
 
        add_branch = kmalloc(sizeof(*add_branch), GFP_KERNEL);
 
214
        add_branch = kmalloc(sizeof(*add_branch), GFP_NOFS);
225
215
        if (unlikely(!add_branch))
226
216
                goto out;
227
217
 
229
219
        if (unlikely(!sz))
230
220
                sz = sizeof(*branchp);
231
221
        p = au_sbi(sb)->si_branch;
232
 
        branchp = au_kzrealloc(p, sz, sizeof(*branchp) * new_nbranch,
233
 
                               GFP_KERNEL);
 
222
        branchp = au_kzrealloc(p, sz, sizeof(*branchp) * new_nbranch, GFP_NOFS);
234
223
        if (unlikely(!branchp))
235
224
                goto out_br;
236
225
        au_sbi(sb)->si_branch = branchp;
240
229
                sz = sizeof(*hdentryp);
241
230
        p = au_di(root)->di_hdentry;
242
231
        hdentryp = au_kzrealloc(p, sz, sizeof(*hdentryp) * new_nbranch,
243
 
                                GFP_KERNEL);
 
232
                                GFP_NOFS);
244
233
        if (unlikely(!hdentryp))
245
234
                goto out_br;
246
235
        au_di(root)->di_hdentry = hdentryp;
249
238
        if (unlikely(!sz))
250
239
                sz = sizeof(*hinodep);
251
240
        p = au_ii(inode)->ii_hinode;
252
 
        hinodep = au_kzrealloc(p, sz, sizeof(*hinodep) * new_nbranch,
253
 
                               GFP_KERNEL);
 
241
        hinodep = au_kzrealloc(p, sz, sizeof(*hinodep) * new_nbranch, GFP_NOFS);
254
242
        if (unlikely(!hinodep))
255
243
                goto out_br;
256
244
        au_ii(inode)->ii_hinode = hinodep;
281
269
        return err;
282
270
}
283
271
 
 
272
static int au_unsupported_fs(struct super_block *sb)
 
273
{
 
274
        return (sb->s_magic == PROC_SUPER_MAGIC
 
275
#ifdef SYSFS_MAGIC
 
276
                || sb->s_magic == SYSFS_MAGIC
 
277
#endif
 
278
                || !strcmp(au_sbtype(sb), "unionfs"));
 
279
}
 
280
 
284
281
/*
285
282
 * returns:
286
283
 * 0: success, the caller will add it
340
337
                goto out;
341
338
        }
342
339
 
343
 
        if (unlikely(!strcmp(au_sbtype(inode->i_sb), "unionfs"))) {
 
340
        if (unlikely(au_unsupported_fs(inode->i_sb))) {
344
341
                AuErr("unsupported filesystem, %s\n", add->path);
345
342
                goto out;
346
343
        }
402
399
                        goto out;
403
400
        }
404
401
 
405
 
        br->br_xino = NULL;
 
402
        br->br_xino.xi_file = NULL;
 
403
        mutex_init(&br->br_xino.xi_nondir_mtx);
406
404
        br->br_mnt = mntget(add->nd.path.mnt);
407
405
        mnt_flags = au_mntflags(sb);
408
406
        if (au_opt_test(mnt_flags, XINO)) {
409
407
                err = au_xino_br(sb, br, add->nd.path.dentry->d_inode->i_ino,
410
 
                                 au_sbr(sb, 0)->br_xino, /*do_test*/1);
 
408
                                 au_sbr(sb, 0)->br_xino.xi_file, /*do_test*/1);
411
409
                if (unlikely(err)) {
412
 
                        AuDebugOn(br->br_xino);
 
410
                        AuDebugOn(br->br_xino.xi_file);
413
411
                        goto out;
414
412
                }
415
413
#if 0 /* reserved for future use */
417
415
                err = au_xinodir_br(sb, br, add->nd.path.dentry->d_inode->i_ino,
418
416
                                    /*do_test*/1);
419
417
                if (unlikely(err)) {
420
 
                        AuDebugOn(br->br_xino);
 
418
                        AuDebugOn(br->br_xino.xi_file);
421
419
                        goto out;
422
420
                }
423
421
#endif
522
520
        if (sb->s_maxbytes < maxb)
523
521
                sb->s_maxbytes = maxb;
524
522
 
 
523
        /* safe d_parent refference */
 
524
        if (!sbinfo->si_xino_def_br
 
525
            && add_branch->br_xino.xi_file
 
526
            && add_branch->br_xino.xi_file->f_dentry->d_parent == dentry)
 
527
                sbinfo->si_xino_def_br = add_branch;
 
528
 
525
529
 out:
526
530
        AuTraceErr(err);
527
531
        return err;
552
556
        LKTRTrace("b%d, gen%d\n", bindex, sigen);
553
557
        SiMustWriteLock(root->d_sb);
554
558
 
555
 
        err = au_dpages_init(&dpages, GFP_TEMPORARY);
 
559
        err = au_dpages_init(&dpages, GFP_NOFS);
556
560
        if (unlikely(err))
557
561
                goto out;
558
562
        err = au_dcsub_pages(&dpages, root, NULL, NULL);
798
802
                                sb->s_maxbytes = maxb;
799
803
                }
800
804
        }
 
805
 
 
806
        if (sbinfo->si_xino_def_br == br)
 
807
                sbinfo->si_xino_def_br = NULL;
801
808
        goto out; /* success */
802
809
 
803
810
 out_wh: