16
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
/* $Id: dentry.c,v 1.44 2007/06/04 02:17:34 sfjro Exp $ */
19
/* $Id: dentry.c,v 1.64 2007/12/03 01:37:50 sfjro Exp $ */
21
21
//#include <linux/fs.h>
22
22
//#include <linux/namei.h>
25
#ifdef CONFIG_AUFS_LHASH_PATCH
26
/* subset of nameidata */
28
struct dentry *dentry;
33
struct open_intent open;
37
static void au_ndsub_restore(struct nameidata *nd, struct au_ndsub *save)
39
nd->dentry = save->dentry;
41
nd->flags = save->flags;
42
nd->intent = save->intent;
46
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) \
47
&& !defined(AuNoNfsBranch)
48
static int au_fake_intent(/* struct au_ndsub *save, */struct nameidata *nd, int perm)
52
LKTRTrace("perm %d\n", perm);
56
save->dentry = nd->dentry;
58
save->flags = nd->flags;
59
save->intent = nd->intent;
62
nd->intent.open.file = NULL;
63
if (nd->flags & LOOKUP_OPEN) {
65
nd->intent.open.file = get_empty_filp();
66
if (unlikely(!nd->intent.open.file)) {
67
//nd->intent.open.file = save->intent.open.file;
72
if (!br_writable(perm)) {
73
nd->intent.open.flags = au_file_roflags
74
(nd->intent.open.flags) | FMODE_READ;
75
nd->flags &= ~LOOKUP_CREATE;
84
static int au_hin_after_reval(struct nameidata *nd, struct dentry *dentry,
85
aufs_bindex_t bindex, struct file *file)
89
LKTRTrace("nd %p, %.*s, b%d, f %d\n",
90
nd, AuDLNPair(dentry), bindex, !!file);
93
if ((nd->flags & LOOKUP_OPEN)
94
&& nd->intent.open.file
95
&& !IS_ERR(nd->intent.open.file)) {
96
if (nd->intent.open.file->f_dentry) {
97
//AuDbgFile(nd->intent.open.file);
98
err = au_set_h_intent(dentry, bindex, file,
99
nd->intent.open.file);
101
nd->intent.open.file = NULL;
103
if (unlikely(nd->intent.open.file))
104
put_filp(nd->intent.open.file);
27
110
#ifdef CONFIG_AUFS_DLGT
28
struct lookup_hash_args {
111
struct au_lookup_hash_args {
29
112
struct dentry **errp;
30
113
struct qstr *name;
31
114
struct dentry *base;
32
115
struct nameidata *nd;
35
static void call_lookup_hash(void *args)
118
static void au_call_lookup_hash(void *args)
37
struct lookup_hash_args *a = args;
38
*a->errp = __lookup_hash(a->name, a->base, a->nd);
120
struct au_lookup_hash_args *a = args;
121
*a->errp = vfsub__lookup_hash(a->name, a->base, a->nd);
40
123
#endif /* CONFIG_AUFS_DLGT */
42
static struct dentry *lkup_hash(const char *name, struct dentry *parent,
43
int len, struct lkup_args *lkup)
125
static struct dentry *au_lkup_hash(const char *name, struct dentry *parent,
126
int len, struct aufs_ndx *ndx)
45
128
struct dentry *dentry;
47
130
unsigned long hash;
50
struct nameidata tmp_nd;
133
struct nameidata tmp_nd, *ndo;
52
136
dentry = ERR_PTR(-EACCES);
66
150
this.hash = end_name_hash(hash);
68
memset(&tmp_nd, 0, sizeof(tmp_nd));
155
err = au_fake_intent(&tmp_nd, ndx->br->br_perm);
156
dentry = ERR_PTR(err);
160
memset(&tmp_nd, 0, sizeof(tmp_nd));
69
162
tmp_nd.dentry = dget(parent);
70
tmp_nd.mnt = mntget(lkup->nfsmnt);
163
tmp_nd.mnt = mntget(ndx->nfsmnt);
71
164
#ifndef CONFIG_AUFS_DLGT
72
dentry = __lookup_hash(&this, parent, &tmp_nd);
165
dentry = vfsub__lookup_hash(&this, parent, &tmp_nd);
75
dentry = __lookup_hash(&this, parent, &tmp_nd);
168
dentry = vfsub__lookup_hash(&this, parent, &tmp_nd);
78
struct lookup_hash_args args = {
171
struct au_lookup_hash_args args = {
84
wkq_err = au_wkq_wait(call_lookup_hash, &args, /*dlgt*/1);
177
wkq_err = au_wkq_wait(au_call_lookup_hash, &args, /*dlgt*/1);
85
178
if (unlikely(wkq_err))
86
179
dentry = ERR_PTR(wkq_err);
181
#endif /* CONFIG_AUFS_DLGT */
182
if (0 && !IS_ERR(dentry))
184
if (!IS_ERR(dentry)) {
185
/* why negative dentry for a new dir was unhashed? */
186
if (unlikely(d_unhashed(dentry)))
188
if (tmp_nd.intent.open.file
189
&& tmp_nd.intent.open.file->f_dentry) {
190
//AuDbgFile(tmp_nd.intent.open.file);
191
ndx->nd_file = tmp_nd.intent.open.file;
192
tmp_nd.intent.open.file = NULL;
89
196
path_release(&tmp_nd);
199
if (tmp_nd.intent.open.file)
200
put_filp(tmp_nd.intent.open.file);
202
AuTraceErrPtr(dentry);
95
#elif defined(CONFIG_AUFS_DLGT)
96
static struct dentry *lkup_hash(const char *name, struct dentry *parent,
97
int len, struct lkup_args *lkup)
206
static int au_fake_intent(struct nameidata *nd, int perm)
211
static int au_hin_after_reval(struct nameidata *nd, struct dentry *dentry,
212
aufs_bindex_t bindex, struct file *file)
217
#if !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT)
218
static struct dentry *au_lkup_hash(const char *name, struct dentry *parent,
219
int len, struct aufs_ndx *ndx)
99
221
return ERR_PTR(-ENOSYS);
224
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !AuNoNfsBranch */
226
/* ---------------------------------------------------------------------- */
228
#if !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT)
103
230
#ifdef CONFIG_AUFS_DLGT
104
struct lookup_one_len_args {
231
struct au_lookup_one_len_args {
105
232
struct dentry **errp;
106
233
const char *name;
107
234
struct dentry *parent;
111
static void call_lookup_one_len(void *args)
238
static void au_call_lookup_one_len(void *args)
113
struct lookup_one_len_args *a = args;
114
*a->errp = lookup_one_len(a->name, a->parent, a->len);
240
struct au_lookup_one_len_args *a = args;
241
*a->errp = vfsub_lookup_one_len(a->name, a->parent, a->len);
116
243
#endif /* CONFIG_AUFS_DLGT */
118
#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
119
245
/* cf. lookup_one_len() in linux/fs/namei.c */
120
struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
121
struct lkup_args *lkup)
246
struct dentry *au_lkup_one(const char *name, struct dentry *parent, int len,
247
struct aufs_ndx *ndx)
123
249
struct dentry *dentry;
125
LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n",
126
DLNPair(parent), len, name, lkup->nfsmnt, lkup->dlgt);
251
LKTRTrace("%.*s/%.*s, ndx{%d, %d}\n",
252
AuDLNPair(parent), len, name, !!ndx->nfsmnt, ndx->dlgt);
129
256
#ifndef CONFIG_AUFS_DLGT
130
dentry = lookup_one_len(name, parent, len);
257
dentry = vfsub_lookup_one_len(name, parent, len);
133
dentry = lookup_one_len(name, parent, len);
260
dentry = vfsub_lookup_one_len(name, parent, len);
136
struct lookup_one_len_args args = {
263
struct au_lookup_one_len_args args = {
139
266
.parent = parent,
142
wkq_err = au_wkq_wait(call_lookup_one_len, &args,
269
wkq_err = au_wkq_wait(au_call_lookup_one_len, &args,
144
271
if (unlikely(wkq_err))
145
272
dentry = ERR_PTR(wkq_err);
274
#endif /* CONFIG_AUFS_DLGT */
149
dentry = lkup_hash(name, parent, len, lkup);
277
dentry = au_lkup_hash(name, parent, len, ndx);
279
AuTraceErrPtr(dentry);
282
#endif /* !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT) */
156
struct lkup_one_args {
284
struct au_lkup_one_args {
157
285
struct dentry **errp;
158
286
const char *name;
159
287
struct dentry *parent;
161
struct lkup_args *lkup;
289
struct aufs_ndx *ndx;
164
static void call_lkup_one(void *args)
292
static void au_call_lkup_one(void *args)
166
struct lkup_one_args *a = args;
167
*a->errp = lkup_one(a->name, a->parent, a->len, a->lkup);
294
struct au_lkup_one_args *a = args;
295
*a->errp = au_lkup_one(a->name, a->parent, a->len, a->ndx);
298
struct au_do_lookup_args {
299
unsigned int allow_neg:1;
302
struct nameidata *nd;
171
306
* returns positive/negative dentry, NULL or an error.
172
307
* NULL means whiteout-ed or not-found.
174
static struct dentry *do_lookup(struct dentry *hidden_parent,
175
struct dentry *dentry, aufs_bindex_t bindex,
176
struct qstr *wh_name, int allow_neg,
177
mode_t type, int dlgt)
310
struct dentry *au_do_lookup(struct dentry *h_parent, struct dentry *dentry,
311
aufs_bindex_t bindex, struct qstr *wh_name,
312
struct au_do_lookup_args *args)
179
struct dentry *hidden_dentry;
314
struct dentry *h_dentry;
180
315
int wh_found, wh_able, opq;
181
struct inode *hidden_dir, *hidden_inode;
316
struct inode *h_dir, *h_inode;
182
317
struct qstr *name;
183
318
struct super_block *sb;
184
struct lkup_args lkup = {.dlgt = dlgt};
319
struct nameidata tmp_nd;
320
struct aufs_ndx ndx = {
186
LKTRTrace("%.*s/%.*s, b%d, allow_neg %d, type 0%o, dlgt %d\n",
187
DLNPair(hidden_parent), DLNPair(dentry), bindex, allow_neg,
325
LKTRTrace("%.*s/%.*s, b%d, {allow_neg %d, type 0%o, dlgt %d, nd %d}\n",
326
AuDLNPair(h_parent), AuDLNPair(dentry), bindex,
327
args->allow_neg, args->type, args->dlgt, !!args->nd);
189
328
AuDebugOn(IS_ROOT(dentry));
190
hidden_dir = hidden_parent->d_inode;
191
IMustLock(hidden_dir);
329
h_dir = h_parent->d_inode;
194
332
sb = dentry->d_sb;
195
wh_able = sbr_is_whable(sb, bindex);
196
lkup.nfsmnt = au_nfsmnt(sb, bindex);
333
ndx.nfsmnt = au_nfsmnt(sb, bindex);
334
LKTRTrace("nfsmnt %p\n", ndx.nfsmnt);
335
ndx.br = stobr(sb, bindex);
336
wh_able = br_whable(ndx.br->br_perm);
197
337
name = &dentry->d_name;
198
338
if (unlikely(wh_able)) {
199
#if 0 //def CONFIG_AUFS_ROBR
339
#ifdef CONFIG_AUFS_ROBR
200
341
if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN))
201
wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0,
342
wh_found = au_test_wh(h_parent, wh_name, /*try_sio*/0,
206
wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0, &lkup);
345
wh_found = au_test_wh(h_parent, wh_name, /*try_sio*/0, &ndx);
209
348
//if (LktrCond) wh_found = -1;
210
hidden_dentry = ERR_PTR(wh_found);
349
h_dentry = ERR_PTR(wh_found);
212
351
goto real_lookup;
213
352
if (unlikely(wh_found < 0))
216
355
/* We found a whiteout */
217
356
//set_dbend(dentry, bindex);
218
357
set_dbwh(dentry, bindex);
358
if (!args->allow_neg)
220
359
return NULL; /* success */
361
&& au_test_nfs(h_parent->d_sb)
362
&& (ndx.nd->flags & LOOKUP_CREATE))) {
364
tmp_nd.flags &= ~(LOOKUP_OPEN | LOOKUP_CREATE);
224
hidden_dentry = lkup_one(name->name, hidden_parent, name->len, &lkup);
225
//if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
226
if (IS_ERR(hidden_dentry))
369
/* do not superio. */
370
h_dentry = au_lkup_one(name->name, h_parent, name->len, &ndx);
371
//if (LktrCond) {dput(h_dentry); h_dentry = ERR_PTR(-1);}
372
if (IS_ERR(h_dentry))
228
AuDebugOn(d_unhashed(hidden_dentry));
229
hidden_inode = hidden_dentry->d_inode;
374
AuDebugOn(d_unhashed(h_dentry));
375
h_inode = h_dentry->d_inode;
377
if (!args->allow_neg)
233
379
} else if (wh_found
234
|| (type && type != (hidden_inode->i_mode & S_IFMT)))
380
|| (args->type && args->type != (h_inode->i_mode & S_IFMT)))
237
383
if (dbend(dentry) <= bindex)
238
384
set_dbend(dentry, bindex);
239
if (dbstart(dentry) == -1 || bindex < dbstart(dentry))
385
if (dbstart(dentry) < 0 || bindex < dbstart(dentry))
240
386
set_dbstart(dentry, bindex);
241
set_h_dptr(dentry, bindex, hidden_dentry);
243
if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode) || !wh_able)
244
return hidden_dentry; /* success */
246
hi_lock_child(hidden_inode);
247
opq = is_diropq(hidden_dentry, &lkup);
387
set_h_dptr(dentry, bindex, h_dentry);
389
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) \
390
&& !defined(AuNoNfsBranch)
391
if (unlikely(ndx.nd_file)) {
393
AuDebugOn(!args->nd);
394
err = au_set_h_intent(dentry, bindex,
395
args->nd->intent.open.file, ndx.nd_file);
398
set_h_dptr(dentry, bindex, NULL);
399
//todo: update bstart and bend
400
h_dentry = ERR_PTR(err);
406
if (!h_inode || !S_ISDIR(h_inode->i_mode) || !wh_able)
407
return h_dentry; /* success */
409
vfsub_i_lock_nested(h_inode, AuLsc_I_CHILD);
410
opq = au_test_diropq(h_dentry, &ndx);
248
411
//if (LktrCond) opq = -1;
249
i_unlock(hidden_inode);
412
vfsub_i_unlock(h_inode);
251
414
set_dbdiropq(dentry, bindex);
252
415
else if (unlikely(opq < 0)) {
253
416
set_h_dptr(dentry, bindex, NULL);
254
hidden_dentry = ERR_PTR(opq);
417
h_dentry = ERR_PTR(opq);
260
hidden_dentry = NULL;
262
TraceErrPtr(hidden_dentry);
263
return hidden_dentry;
425
AuTraceErrPtr(h_dentry);
267
430
* returns the number of hidden positive dentries,
268
431
* otherwise an error.
270
int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type)
433
int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type,
434
struct nameidata *nd)
272
int npositive, err, allow_neg, dlgt;
273
437
struct dentry *parent;
274
438
aufs_bindex_t bindex, btail;
275
439
const struct qstr *name = &dentry->d_name;
276
440
struct qstr whname;
277
441
struct super_block *sb;
442
struct au_do_lookup_args args = {
279
LKTRTrace("%.*s, b%d, type 0%o\n", LNPair(name), bstart, type);
447
LKTRTrace("%.*s, b%d, type 0%o\n", AuLNPair(name), bstart, type);
280
448
AuDebugOn(bstart < 0 || IS_ROOT(dentry));
450
/* dir may not be locked */
281
451
parent = dget_parent(dentry);
283
#if 1 //ndef CONFIG_AUFS_ROBR
453
#ifndef CONFIG_AUFS_ROBR
285
455
if (unlikely(!strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
294
464
sb = dentry->d_sb;
295
dlgt = need_dlgt(sb);
465
args.dlgt = !!au_need_dlgt(sb);
466
args.allow_neg = !type;
298
468
btail = dbtaildir(parent);
299
469
for (bindex = bstart; bindex <= btail; bindex++) {
300
struct dentry *hidden_parent, *hidden_dentry;
301
struct inode *hidden_inode;
302
struct inode *hidden_dir;
470
struct dentry *h_parent, *h_dentry;
471
struct inode *h_inode, *h_dir;
304
hidden_dentry = au_h_dptr_i(dentry, bindex);
306
if (hidden_dentry->d_inode)
473
h_dentry = au_h_dptr_i(dentry, bindex);
475
if (h_dentry->d_inode)
308
477
if (type != S_IFDIR)
312
hidden_parent = au_h_dptr_i(parent, bindex);
481
h_parent = au_h_dptr_i(parent, bindex);
315
hidden_dir = hidden_parent->d_inode;
316
if (!hidden_dir || !S_ISDIR(hidden_dir->i_mode))
484
h_dir = h_parent->d_inode;
485
if (!h_dir || !S_ISDIR(h_dir->i_mode))
319
hi_lock_parent(hidden_dir);
320
hidden_dentry = do_lookup(hidden_parent, dentry, bindex,
321
&whname, allow_neg, type, dlgt);
488
vfsub_i_lock_nested(h_dir, AuLsc_I_PARENT);
489
h_dentry = au_do_lookup(h_parent, dentry, bindex, &whname,
322
491
// do not dput for testing
323
//if (LktrCond) {hidden_dentry = ERR_PTR(-1);}
324
i_unlock(hidden_dir);
325
err = PTR_ERR(hidden_dentry);
326
if (IS_ERR(hidden_dentry))
492
//if (LktrCond) {h_dentry = ERR_PTR(-1);}
493
vfsub_i_unlock(h_dir);
494
err = PTR_ERR(h_dentry);
495
if (IS_ERR(h_dentry))
330
if (dbwh(dentry) != -1)
499
if (dbwh(dentry) >= 0)
334
hidden_inode = hidden_dentry->d_inode;
503
h_inode = h_dentry->d_inode;
339
type = hidden_inode->i_mode & S_IFMT;
508
args.type = h_inode->i_mode & S_IFMT;
509
if (args.type != S_IFDIR)
342
else if (dbdiropq(dentry) != -1)
511
else if (dbdiropq(dentry) >= 0)
353
522
au_free_whname(&whname);
360
struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
361
struct lkup_args *lkup)
529
struct dentry *au_sio_lkup_one(const char *name, struct dentry *parent, int len,
530
struct aufs_ndx *ndx)
363
532
struct dentry *dentry;
366
LKTRTrace("%.*s/%.*s\n", DLNPair(parent), len, name);
367
IMustLock(parent->d_inode);
535
LKTRTrace("%.*s/%.*s\n", AuDLNPair(parent), len, name);
369
if (!au_test_perm(parent->d_inode, MAY_EXEC, lkup->dlgt))
370
dentry = lkup_one(name, parent, len, lkup);
537
if (!au_test_perm(parent->d_inode, MAY_EXEC, ndx->dlgt))
538
dentry = au_lkup_one(name, parent, len, ndx);
373
int dlgt = lkup->dlgt;
374
struct lkup_one_args args = {
541
int dlgt = ndx->dlgt;
542
struct au_lkup_one_args args = {
377
545
.parent = parent,
383
wkq_err = au_wkq_wait(call_lkup_one, &args, /*dlgt*/0);
551
wkq_err = au_wkq_wait(au_call_lkup_one, &args, /*dlgt*/0);
384
552
if (unlikely(wkq_err))
385
553
dentry = ERR_PTR(wkq_err);
557
AuTraceErrPtr(dentry);
394
562
* lookup @dentry on @bindex which should be negative.
396
int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
564
int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
399
struct dentry *parent, *hidden_parent, *hidden_dentry;
400
struct inode *hidden_dir;
401
struct lkup_args lkup;
567
struct dentry *parent, *h_parent, *h_dentry;
569
struct aufs_ndx ndx = {
573
struct super_block *sb;
403
LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
575
LKTRTrace("%.*s, b%d\n", AuDLNPair(dentry), bindex);
576
/* dir may not be locked */
404
577
parent = dget_parent(dentry);
405
578
AuDebugOn(!parent || !parent->d_inode
406
579
|| !S_ISDIR(parent->d_inode->i_mode));
407
hidden_parent = au_h_dptr_i(parent, bindex);
408
AuDebugOn(!hidden_parent);
409
hidden_dir = hidden_parent->d_inode;
410
AuDebugOn(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
411
IMustLock(hidden_dir);
580
h_parent = au_h_dptr_i(parent, bindex);
581
AuDebugOn(!h_parent);
582
h_dir = h_parent->d_inode;
583
AuDebugOn(!h_dir || !S_ISDIR(h_dir->i_mode));
413
lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bindex);
414
lkup.dlgt = need_dlgt(dentry->d_sb);
415
hidden_dentry = sio_lkup_one(dentry->d_name.name, hidden_parent,
416
dentry->d_name.len, &lkup);
417
//if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
418
err = PTR_ERR(hidden_dentry);
419
if (IS_ERR(hidden_dentry))
586
ndx.nfsmnt = au_nfsmnt(sb, bindex);
587
ndx.dlgt = au_need_dlgt(sb);
588
h_dentry = au_sio_lkup_one(dentry->d_name.name, h_parent,
589
dentry->d_name.len, &ndx);
590
//if (LktrCond) {dput(h_dentry); h_dentry = ERR_PTR(-1);}
591
err = PTR_ERR(h_dentry);
592
if (IS_ERR(h_dentry))
421
if (unlikely(hidden_dentry->d_inode)) {
594
if (unlikely(h_dentry->d_inode)) {
423
IOErr("b%d %.*s should be negative.%s\n",
424
bindex, DLNPair(hidden_dentry),
425
au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY) ? "" :
426
" Try udba=inotify.");
596
AuIOErr("b%d %.*s should be negative.\n",
597
bindex, AuDLNPair(h_dentry));
544
711
if (type != S_IFDIR && dinfo->di_bstart == parent_bstart)
545
712
goto out_dgen; /* success */
548
nd.last_type = LAST_ROOT;
549
nd.flags = LOOKUP_FOLLOW;
552
nd.dentry = dget(parent);
554
npositive = lkup_dentry(dentry, parent_bstart, type);
714
npositive = au_lkup_dentry(dentry, parent_bstart, type, /*nd*/NULL);
555
715
//if (LktrCond) npositive = -1;
556
716
if (npositive < 0)
718
if (unlikely(dinfo->di_bwh >= 0 && dinfo->di_bwh <= dinfo->di_bstart))
560
722
au_update_digen(dentry);
725
AuTraceErr(npositive);
564
726
return npositive;
567
static int h_d_revalidate(struct dentry *dentry, struct nameidata *nd,
729
static int h_d_revalidate(struct dentry *dentry, struct inode *inode,
730
struct nameidata *nd, int do_udba)
570
int err, plus, locked, unhashed, is_root, h_plus, is_nfs;
732
int err, plus, locked, unhashed, is_root, h_plus, valid;
571
733
struct nameidata fake_nd, *p;
572
734
aufs_bindex_t bindex, btail, bstart, ibs, ibe;
573
735
struct super_block *sb;
574
struct inode *inode, *first, *h_inode, *h_cached_inode;
736
struct inode *first, *h_inode, *h_cached_inode;
575
737
umode_t mode, h_mode;
576
738
struct dentry *h_dentry;
577
739
int (*reval)(struct dentry *, struct nameidata *);
578
740
struct qstr *name;
580
LKTRTrace("%.*s\n", DLNPair(dentry));
581
inode = dentry->d_inode;
742
LKTRTrace("%.*s, nd %d\n", AuDLNPair(dentry), !!nd);
582
743
AuDebugOn(inode && au_digen(dentry) != au_iigen(inode));
587
746
sb = dentry->d_sb;
592
752
unhashed = d_unhashed(dentry);
593
753
is_root = IS_ROOT(dentry);
594
754
name = &dentry->d_name;
825
1019
static int aufs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
827
int valid, sgen, err, do_udba;
1021
int valid, err, do_udba;
828
1022
struct super_block *sb;
829
1024
struct inode *inode;
1025
struct nameidata tmp_nd, *ndp;
1026
struct aufs_sbinfo *sbinfo;
1027
//todo: no more lower nameidata, only here. re-use it.
831
LKTRTrace("dentry %.*s\n", DLNPair(dentry));
1029
LKTRTrace("dentry %.*s\n", AuDLNPair(dentry));
832
1030
if (nd && nd->dentry)
833
LKTRTrace("nd %.*s\n", DLNPair(nd->dentry));
1031
LKTRTrace("nd{%.*s, 0x%x}\n", AuDLNPair(nd->dentry), nd->flags);
834
1032
//dir case: AuDebugOn(dentry->d_parent != nd->dentry);
835
//remove failure case: AuDebugOn(!IS_ROOT(dentry) && d_unhashed(dentry));
1033
//remove failure case:AuDebugOn(!IS_ROOT(dentry) && d_unhashed(dentry));
836
1034
AuDebugOn(!dentry->d_fsdata);
1035
//AuDbgDentry(dentry);
840
1038
inode = dentry->d_inode;
842
1039
sb = dentry->d_sb;
1040
si_read_lock(sb, AuLock_FLUSH);
844
1042
sgen = au_sigen(sb);
845
1043
if (au_digen(dentry) == sgen)
846
di_read_lock_child(dentry, !AUFS_I_RLOCK);
1044
di_read_lock_child(dentry, !AuLock_IR);
848
1046
AuDebugOn(IS_ROOT(dentry));
849
1047
#ifdef ForceInotify
850
Dbg("UDBA or digen, %.*s\n", DLNPair(dentry));
1048
AuDbg("UDBA or digen, %.*s\n", AuDLNPair(dentry));
1050
//di_read_lock_child(dentry, AuLock_IR);err = -EINVAL; goto out;
1051
//vfsub_i_lock(inode);
853
1052
di_write_lock_child(dentry);
855
1054
err = au_reval_dpath(dentry, sgen);
857
di_downgrade_lock(dentry, AUFS_I_RLOCK);
1056
di_downgrade_lock(dentry, AuLock_IR);
1057
//vfsub_i_unlock(inode);
859
1058
if (unlikely(err))
861
1060
ii_read_unlock(inode);