~ubuntu-branches/ubuntu/utopic/aufs/utopic

« back to all changes in this revision

Viewing changes to fs/aufs/i_op_add.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-01-30 15:27:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130152704-uvd64xgdg17ro2s8
Tags: 0+20080129-1
* New upstream snapshot
* 01_vserver_apparmor: Combined patch for vServer and AppArmor Kernels
  - AppArmor kernels have no ia_file, do not use it (LP: #182481)
  - AppArmor patch written by Joerg Schirottke for Kanotix (thank you!)
  - Replaces 01_vserver and 06_ubuntu
* 03_missing_headers: Define the magic numbers for XFS and TMPFS
* 04_sec_perm: Do not use security_inode_permission with kernel >= 2.6.24
* Inform about available pre-compiled modules in aufs-source description
* conf.mk:
  - Rewrite automatic configuration part, define a function and call it
  - Activate the AUFS_FAKE_DM only if the lhash patch has not been applied

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: i_op_add.c,v 1.56 2007/12/10 01:19:07 sfjro Exp $ */
 
19
/* $Id: i_op_add.c,v 1.58 2008/01/28 05:02:00 sfjro Exp $ */
20
20
 
21
21
#include "aufs.h"
22
22
 
97
97
lock_hdir_lkup_wh(struct dentry *dentry, struct au_dtime *dt,
98
98
                  struct dentry *src_dentry, struct au_wr_dir_args *wr_dir_args)
99
99
{
100
 
        struct dentry *wh_dentry, *parent, *h_parent;
 
100
        struct dentry *wh_dentry, *parent, *h_parent, *gparent;
101
101
        int err;
102
102
        aufs_bindex_t bstart, bcpup;
103
 
        struct inode *dir, *h_dir;
 
103
        struct inode *dir, *h_dir, *gdir;
104
104
        struct aufs_ndx ndx;
 
105
        struct super_block *sb;
 
106
        struct aufs_hinode *hgdir;
105
107
 
106
108
        LKTRTrace("%.*s, src %p\n", AuDLNPair(dentry), src_dentry);
107
109
 
115
117
        if (unlikely(err < 0))
116
118
                goto out;
117
119
 
 
120
        sb = parent->d_sb;
 
121
        //todo: meaningless lock if CONFIG_AUFS_DEBUG is disabled.
 
122
        hgdir = NULL;
 
123
        if (unlikely(dt && au_flag_test_udba_inotify(sb) && !IS_ROOT(parent))) {
 
124
                gparent = dget_parent(parent);
 
125
                gdir = gparent->d_inode;
 
126
                ii_read_lock_parent2(gdir);
 
127
                hgdir = itohi(gdir, bcpup);
 
128
                ii_read_unlock(gdir);
 
129
                dput(gparent);
 
130
        }
118
131
        dir = parent->d_inode;
119
132
        h_parent = au_h_dptr_i(parent, bcpup);
120
133
        h_dir = h_parent->d_inode;
 
134
#ifdef DbgUdbaRace
 
135
        AuDbgSleep(DbgUdbaRace);
 
136
#endif
121
137
        hdir_lock(h_dir, dir, bcpup);
 
138
 
 
139
        /*
 
140
         * someone else might change our parent-child relationship directly,
 
141
         * bypassing aufs, while we are handling a systemcall for aufs.
 
142
         */
 
143
        wh_dentry = ERR_PTR(-EIO);
 
144
        if (unlikely(h_parent != au_h_dptr_i(dentry, bcpup)->d_parent))
 
145
                goto out_dir;
 
146
#if 0
 
147
        revalidate h_negative
 
148
#endif
 
149
 
122
150
        if (dt)
123
 
                au_dtime_store(dt, parent, bcpup, h_parent);
 
151
                au_dtime_store(dt, parent, h_parent, hgdir);
124
152
        wh_dentry = NULL;
125
153
        if (/* bcpup != bstart || */ bcpup != dbwh(dentry))
126
154
                goto out; /* success */
127
155
 
128
 
        ndx.nfsmnt = au_nfsmnt(parent->d_sb, bcpup);
129
 
        ndx.dlgt = au_need_dlgt(parent->d_sb);
 
156
        ndx.nfsmnt = au_nfsmnt(sb, bcpup);
 
157
        ndx.dlgt = au_need_dlgt(sb);
130
158
        ndx.nd = NULL;
131
159
        //ndx.br = NULL;
132
160
        wh_dentry = lkup_wh(h_parent, &dentry->d_name, &ndx);
133
161
        //wh_dentry = ERR_PTR(-1);
 
162
 
 
163
 out_dir:
134
164
        if (IS_ERR(wh_dentry))
135
165
                hdir_unlock(h_dir, dir, bcpup);
136
 
 
137
166
 out:
138
167
        AuTraceErrPtr(wh_dentry);
139
168
        return wh_dentry;
162
191
static int add_simple(struct inode *dir, struct dentry *dentry,
163
192
                      struct simple_arg *arg)
164
193
{
165
 
        int err, dlgt;
 
194
        int err, dlgt, created;
166
195
        struct dentry *h_dentry, *h_parent, *wh_dentry, *parent;
167
196
        struct inode *h_dir;
168
197
        struct au_dtime dt;
216
245
#else
217
246
        err = -1;
218
247
#endif
 
248
        created = !err;
219
249
        if (!err)
220
250
                err = epilog(dir, wh_dentry, dentry);
221
251
        //err = -1;
222
252
 
223
253
        /* revert */
224
 
        if (unlikely(err && h_dentry->d_inode)) {
 
254
        if (unlikely(created && err && h_dentry->d_inode)) {
225
255
                int rerr;
226
256
                vfsub_args_init(&vargs, NULL, dlgt, 0);
227
257
                rerr = vfsub_unlink(h_dir, h_dentry, &vargs);
297
327
                            struct link_arg *a)
298
328
{
299
329
        int err;
300
 
        struct inode *hi, *hdir = NULL, *src_dir;
 
330
        struct inode *hi, *h_dir, *src_dir, *gdir;
301
331
        struct au_cpup_flags cflags;
 
332
        struct dentry *gparent;
302
333
 
303
334
        AuTraceEnter();
304
335
 
305
 
        err = 0;
 
336
        gparent = NULL;
 
337
        gdir = NULL;
 
338
        if (unlikely(au_flag_test_udba_inotify(src_dentry->d_sb)
 
339
                     && !IS_ROOT(a->src_parent))) {
 
340
                gparent = dget_parent(a->src_parent);
 
341
                gdir = gparent->d_inode;
 
342
                if (gdir == dir) {
 
343
                        dput(gparent);
 
344
                        gparent = NULL;
 
345
                }
 
346
        }
306
347
        src_dir = a->src_parent->d_inode;
 
348
        h_dir = NULL;
 
349
 
307
350
        if (!a->issamedir) {
308
 
                // todo: dead lock?
 
351
                /* this temporary unlock/lock is safe */
 
352
                hdir_unlock(a->h_dir, dir, a->bdst);
309
353
                di_read_lock_parent2(a->src_parent, AuLock_IR);
310
 
                /* this temporary unlock/lock is safe */
311
 
                hdir_unlock(a->h_dir, dir, a->bdst);
312
354
                err = au_test_and_cpup_dirs(src_dentry, a->bdst, a->parent);
313
355
                //err = -1;
314
 
                if (!err) {
315
 
                        hdir = au_h_iptr_i(src_dir, a->bdst);
316
 
                        hdir_lock(hdir, src_dir, a->bdst);
 
356
                if (unlikely(err)) {
 
357
                        hdir_lock(a->h_dir, dir, a->bdst);
 
358
                        goto out;
317
359
                }
318
 
        }
319
 
 
320
 
        if (!err) {
321
 
                cflags.dtime = 1;
322
 
                hi = au_h_dptr(src_dentry)->d_inode;
323
 
                vfsub_i_lock_nested(hi, AuLsc_I_CHILD);
324
 
                err = au_sio_cpup_simple(src_dentry, a->bdst, -1, &cflags);
325
 
                //err = -1;
326
 
                vfsub_i_unlock(hi);
327
 
        }
328
 
 
329
 
        if (!a->issamedir) {
330
 
                if (hdir)
331
 
                        hdir_unlock(hdir, src_dir, a->bdst);
332
 
                hdir_lock(a->h_dir, dir, a->bdst);
 
360
 
 
361
                //todo: meaningless lock if CONFIG_AUFS_DEBUG is disabled.
 
362
                if (unlikely(gparent))
 
363
                        ii_read_lock_parent3(gdir);
 
364
                h_dir = au_h_iptr_i(src_dir, a->bdst);
 
365
                hdir_lock(h_dir, src_dir, a->bdst);
 
366
        } else if (unlikely(gparent)) {
 
367
                /* this temporary unlock/lock is safe */
 
368
                hdir_unlock(a->h_dir, dir, a->bdst);
 
369
                ii_read_lock_parent3(gdir);
 
370
                hdir_lock(a->h_dir, dir, a->bdst);
 
371
        }
 
372
        //todo: test parent-gparent relationship
 
373
 
 
374
        cflags.dtime = 1;
 
375
        hi = au_h_dptr(src_dentry)->d_inode;
 
376
        vfsub_i_lock_nested(hi, AuLsc_I_CHILD);
 
377
        err = au_sio_cpup_simple(src_dentry, a->bdst, -1, &cflags);
 
378
        //err = -1;
 
379
        vfsub_i_unlock(hi);
 
380
 
 
381
        if (unlikely(gparent)) {
 
382
                ii_read_unlock(gdir);
 
383
                dput(gparent);
 
384
        }
 
385
 
 
386
 out:
 
387
        if (h_dir) {
 
388
                hdir_unlock(h_dir, src_dir, a->bdst);
 
389
                hdir_lock(a->h_dir, dir, a->bdst);
 
390
        }
 
391
        if (!a->issamedir)
333
392
                di_read_unlock(a->src_parent, AuLock_IR);
334
 
        }
335
393
 
336
394
        AuTraceErr(err);
337
395
        return err;
504
562
                /* nfs case (< 2.6.15) */
505
563
                d_drop(dentry);
506
564
#if 0 // debug
507
 
        au_debug_on();
508
 
        DbgInode(a.inode);
509
 
        au_debug_off();
 
565
        //au_debug_on();
 
566
        AuDbgInode(a.inode);
 
567
        //au_debug_off();
510
568
        {
511
569
                aufs_bindex_t i;
512
570
                for (i = ibstart(a.inode); i <= ibend(a.inode); i++) {