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)
100
struct dentry *wh_dentry, *parent, *h_parent;
100
struct dentry *wh_dentry, *parent, *h_parent, *gparent;
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;
106
108
LKTRTrace("%.*s, src %p\n", AuDLNPair(dentry), src_dentry);
115
117
if (unlikely(err < 0))
121
//todo: meaningless lock if CONFIG_AUFS_DEBUG is disabled.
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);
118
131
dir = parent->d_inode;
119
132
h_parent = au_h_dptr_i(parent, bcpup);
120
133
h_dir = h_parent->d_inode;
135
AuDbgSleep(DbgUdbaRace);
121
137
hdir_lock(h_dir, dir, bcpup);
140
* someone else might change our parent-child relationship directly,
141
* bypassing aufs, while we are handling a systemcall for aufs.
143
wh_dentry = ERR_PTR(-EIO);
144
if (unlikely(h_parent != au_h_dptr_i(dentry, bcpup)->d_parent))
147
revalidate h_negative
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 */
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);
132
160
wh_dentry = lkup_wh(h_parent, &dentry->d_name, &ndx);
133
161
//wh_dentry = ERR_PTR(-1);
134
164
if (IS_ERR(wh_dentry))
135
165
hdir_unlock(h_dir, dir, bcpup);
138
167
AuTraceErrPtr(wh_dentry);
139
168
return wh_dentry;
220
250
err = epilog(dir, wh_dentry, dentry);
224
if (unlikely(err && h_dentry->d_inode)) {
254
if (unlikely(created && err && h_dentry->d_inode)) {
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)
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;
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;
306
347
src_dir = a->src_parent->d_inode;
307
350
if (!a->issamedir) {
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);
315
hdir = au_h_iptr_i(src_dir, a->bdst);
316
hdir_lock(hdir, src_dir, a->bdst);
357
hdir_lock(a->h_dir, dir, a->bdst);
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);
331
hdir_unlock(hdir, src_dir, a->bdst);
332
hdir_lock(a->h_dir, dir, a->bdst);
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);
372
//todo: test parent-gparent relationship
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);
381
if (unlikely(gparent)) {
382
ii_read_unlock(gdir);
388
hdir_unlock(h_dir, src_dir, a->bdst);
389
hdir_lock(a->h_dir, dir, a->bdst);
333
392
di_read_unlock(a->src_parent, AuLock_IR);