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

« back to all changes in this revision

Viewing changes to fs/aufs/dentry.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2005, 2006, 2007, 2008 Junjiro Okajima
 
2
 * Copyright (C) 2005-2008 Junjiro Okajima
3
3
 *
4
4
 * This program, aufs is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: dentry.c,v 1.72 2008/03/31 07:42:05 sfjro Exp $ */
 
19
/*
 
20
 * lookup and dentry operations
 
21
 *
 
22
 * $Id: dentry.c,v 1.74 2008/04/13 23:39:09 sfjro Exp $
 
23
 */
20
24
 
21
25
//#include <linux/fs.h>
22
26
//#include <linux/namei.h>
23
27
#include "aufs.h"
24
28
 
25
 
#if 0
26
 
/* subset of nameidata */
27
 
struct au_ndsub {
28
 
        struct dentry   *dentry;
29
 
        struct vfsmount *mnt;
30
 
        unsigned int    flags;
31
 
 
32
 
        union {
33
 
                struct open_intent open;
34
 
        } intent;
35
 
};
36
 
 
37
 
static void au_ndsub_restore(struct nameidata *nd, struct au_ndsub *save)
38
 
{
39
 
        nd->dentry = save->dentry;
40
 
        nd->mnt = save->mnt;
41
 
        nd->flags = save->flags;
42
 
        nd->intent = save->intent;
43
 
}
44
 
#endif
45
 
 
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,
49
 
                          int perm)
50
 
{
51
 
        int err;
52
 
 
53
 
        LKTRTrace("perm %d\n", perm);
54
 
 
55
 
        err = 0;
56
 
#if 0
57
 
        save->dentry = nd->dentry;
58
 
        save->mnt = nd->mnt;
59
 
        save->flags = nd->flags;
60
 
        save->intent = nd->intent;
61
 
#endif
62
 
 
63
 
        nd->intent.open.file = NULL;
64
 
        if (nd->flags & LOOKUP_OPEN) {
65
 
                err = -ENFILE;
66
 
                nd->intent.open.file = get_empty_filp();
67
 
                if (unlikely(!nd->intent.open.file)) {
68
 
                        //nd->intent.open.file = save->intent.open.file;
69
 
                        goto out;
70
 
                }
71
 
 
72
 
                err = 0;
73
 
                if (!br_writable(perm)) {
74
 
                        nd->intent.open.flags = au_file_roflags
75
 
                                (nd->intent.open.flags) | FMODE_READ;
76
 
                        nd->flags &= ~LOOKUP_CREATE;
77
 
                }
78
 
        }
79
 
 
80
 
 out:
81
 
        AuTraceErr(err);
82
 
        return err;
83
 
}
84
 
 
85
 
static int au_hin_after_reval(struct nameidata *nd, struct dentry *dentry,
86
 
                              aufs_bindex_t bindex, struct file *file)
87
 
{
88
 
        int err;
89
 
 
90
 
        LKTRTrace("nd %p, %.*s, b%d, f %d\n",
91
 
                  nd, AuDLNPair(dentry), bindex, !!file);
92
 
 
93
 
        err = 0;
94
 
        if ((nd->flags & LOOKUP_OPEN)
95
 
            && nd->intent.open.file
96
 
            && !IS_ERR(nd->intent.open.file)) {
97
 
                if (nd->intent.open.file->f_dentry) {
98
 
                        //AuDbgFile(nd->intent.open.file);
99
 
                        err = au_set_h_intent(dentry, bindex, file,
100
 
                                              nd->intent.open.file);
101
 
                        if (!err)
102
 
                                nd->intent.open.file = NULL;
103
 
                }
104
 
                if (unlikely(nd->intent.open.file))
105
 
                        put_filp(nd->intent.open.file);
106
 
        }
107
 
 
108
 
        return err;
109
 
}
110
 
 
111
 
#ifdef CONFIG_AUFS_DLGT
112
 
struct au_lookup_hash_args {
113
 
        struct dentry **errp;
114
 
        struct qstr *name;
115
 
        struct dentry *base;
116
 
        struct nameidata *nd;
117
 
};
118
 
 
119
 
static void au_call_lookup_hash(void *args)
120
 
{
121
 
        struct au_lookup_hash_args *a = args;
122
 
        *a->errp = vfsub__lookup_hash(a->name, a->base, a->nd);
123
 
}
124
 
#endif /* CONFIG_AUFS_DLGT */
125
 
 
126
 
static struct dentry *au_lkup_hash(const char *name, struct dentry *parent,
127
 
                                   int len, struct aufs_ndx *ndx)
128
 
{
129
 
        struct dentry *dentry;
130
 
        char *p;
131
 
        unsigned long hash;
132
 
        struct qstr this;
133
 
        unsigned int c;
134
 
        struct nameidata tmp_nd, *ndo;
135
 
        int err, dirperm1;
136
 
 
137
 
        dentry = ERR_PTR(-EACCES);
138
 
        this.name = name;
139
 
        this.len = len;
140
 
        if (unlikely(!len))
141
 
                goto out;
142
 
 
143
 
        p = (void *)name;
144
 
        hash = init_name_hash();
145
 
        while (len--) {
146
 
                c = *p++;
147
 
                if (unlikely(c == '/' || c == '\0'))
148
 
                        goto out;
149
 
                hash = partial_name_hash(c, hash);
150
 
        }
151
 
        this.hash = end_name_hash(hash);
152
 
 
153
 
        ndo = ndx->nd;
154
 
        if (ndo) {
155
 
                tmp_nd = *ndo;
156
 
                err = au_fake_intent(&tmp_nd, ndx->br->br_perm);
157
 
                dentry = ERR_PTR(err);
158
 
                if (unlikely(err))
159
 
                        goto out_intent;
160
 
        } else
161
 
                memset(&tmp_nd, 0, sizeof(tmp_nd));
162
 
 
163
 
        tmp_nd.dentry = dget(parent);
164
 
        tmp_nd.mnt = mntget(ndx->nfsmnt);
165
 
#ifndef CONFIG_AUFS_DLGT
166
 
        dirperm1 = 0;
167
 
        dentry = vfsub__lookup_hash(&this, parent, &tmp_nd);
168
 
#else
169
 
        dirperm1 = au_ftest_ndx(ndx->flags, DIRPERM1);
170
 
        if (!dirperm1 && !au_ftest_ndx(ndx->flags, DLGT))
171
 
                dentry = vfsub__lookup_hash(&this, parent, &tmp_nd);
172
 
        else {
173
 
                int wkq_err;
174
 
                struct au_lookup_hash_args args = {
175
 
                        .errp   = &dentry,
176
 
                        .name   = &this,
177
 
                        .base   = parent,
178
 
                        .nd     = &tmp_nd
179
 
                };
180
 
                wkq_err = au_wkq_wait(au_call_lookup_hash, &args,
181
 
                                      /*dlgt*/!dirperm1);
182
 
                if (unlikely(wkq_err))
183
 
                        dentry = ERR_PTR(wkq_err);
184
 
        }
185
 
#endif /* CONFIG_AUFS_DLGT */
186
 
        if (0 && !IS_ERR(dentry))
187
 
                AuDbgDentry(dentry);
188
 
        if (!IS_ERR(dentry)) {
189
 
                /* why negative dentry for a new dir was unhashed? */
190
 
                if (unlikely(d_unhashed(dentry)))
191
 
                        d_rehash(dentry);
192
 
                if (tmp_nd.intent.open.file
193
 
                    && tmp_nd.intent.open.file->f_dentry) {
194
 
                        //AuDbgFile(tmp_nd.intent.open.file);
195
 
                        ndx->nd_file = tmp_nd.intent.open.file;
196
 
                        tmp_nd.intent.open.file = NULL;
197
 
                        //br_get(ndx->br);
198
 
                }
199
 
        }
200
 
        path_release(&tmp_nd);
201
 
 
202
 
 out_intent:
203
 
        if (tmp_nd.intent.open.file)
204
 
                put_filp(tmp_nd.intent.open.file);
205
 
 out:
206
 
        AuTraceErrPtr(dentry);
207
 
        return dentry;
208
 
}
209
 
#else
210
 
static int au_fake_intent(struct nameidata *nd, int perm)
211
 
{
212
 
        return 0;
213
 
}
214
 
 
215
 
static int au_hin_after_reval(struct nameidata *nd, struct dentry *dentry,
216
 
                              aufs_bindex_t bindex, struct file *file)
217
 
{
218
 
        return 0;
219
 
}
220
 
 
221
 
#if !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT)
222
 
static struct dentry *au_lkup_hash(const char *name, struct dentry *parent,
223
 
                                   int len, struct aufs_ndx *ndx)
224
 
{
225
 
        return ERR_PTR(-ENOSYS);
226
 
}
227
 
#endif
228
 
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !AuNoNfsBranch */
229
 
 
230
29
/* ---------------------------------------------------------------------- */
231
30
 
232
 
#if !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT)
233
 
 
234
 
#ifdef CONFIG_AUFS_DLGT
235
 
struct au_lookup_one_len_args {
236
 
        struct dentry **errp;
237
 
        const char *name;
238
 
        struct dentry *parent;
239
 
        int len;
240
 
};
241
 
 
242
 
static void au_call_lookup_one_len(void *args)
243
 
{
244
 
        struct au_lookup_one_len_args *a = args;
245
 
        *a->errp = vfsub_lookup_one_len(a->name, a->parent, a->len);
246
 
}
247
 
#endif /* CONFIG_AUFS_DLGT */
248
 
 
 
31
#if defined(CONFIG_AUFS_BR_NFS) || defined(CONFIG_AUFS_DLGT)
249
32
/* cf. lookup_one_len() in linux/fs/namei.c */
250
33
struct dentry *au_lkup_one(const char *name, struct dentry *parent, int len,
251
 
                           struct aufs_ndx *ndx)
 
34
                           struct au_ndx *ndx)
252
35
{
253
36
        struct dentry *dentry;
254
37
 
256
39
                  AuDLNPair(parent), len, name, !!ndx->nfsmnt, ndx->flags);
257
40
 
258
41
        ndx->nd_file = NULL;
259
 
        if (!ndx->nfsmnt) {
260
 
#ifndef CONFIG_AUFS_DLGT
261
 
                dentry = vfsub_lookup_one_len(name, parent, len);
262
 
#else
263
 
                int dirperm1 = au_ftest_ndx(ndx->flags, DIRPERM1);
264
 
                if (!dirperm1 && !au_ftest_ndx(ndx->flags, DLGT))
265
 
                        dentry = vfsub_lookup_one_len(name, parent, len);
266
 
                else {
267
 
                        int wkq_err;
268
 
                        struct au_lookup_one_len_args args = {
269
 
                                .errp   = &dentry,
270
 
                                .name   = name,
271
 
                                .parent = parent,
272
 
                                .len    = len
273
 
                        };
274
 
                        wkq_err = au_wkq_wait(au_call_lookup_one_len, &args,
275
 
                                              /*dlgt*/!dirperm1);
276
 
                        if (unlikely(wkq_err))
277
 
                                dentry = ERR_PTR(wkq_err);
278
 
                }
279
 
#endif /* CONFIG_AUFS_DLGT */
280
 
 
281
 
        } else
 
42
        if (!ndx->nfsmnt)
 
43
                dentry = au_lkup_one_dlgt(name, parent, len, ndx->flags);
 
44
        else
282
45
                dentry = au_lkup_hash(name, parent, len, ndx);
283
46
 
284
47
        AuTraceErrPtr(dentry);
285
48
        return dentry;
286
49
}
287
 
#endif /* !defined(AuNoNfsBranch) || defined(CONFIG_AUFS_DLGT) */
288
 
 
289
 
#ifdef CONFIG_AUFS_ROBR
290
 
static int au_test_robr_wh(struct qstr *name, struct dentry *h_parent,
291
 
                           struct qstr *wh_name, int try_sio,
292
 
                           struct aufs_ndx *ndx)
293
 
{
294
 
        if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN))
295
 
                return au_test_wh(h_parent, wh_name, try_sio, ndx);
296
 
        return -EPERM;
297
 
}
298
 
 
299
 
static int au_test_robr_shwh(struct super_block *sb, const struct qstr *name)
300
 
{
301
 
        return 0;
302
 
}
303
 
 
304
 
#else
305
 
 
306
 
static int au_test_robr_wh(struct qstr *name, struct dentry *h_parent,
307
 
                           struct qstr *wh_name, int try_sio,
308
 
                           struct aufs_ndx *ndx)
309
 
{
310
 
        return au_test_wh(h_parent, wh_name, try_sio, ndx);
311
 
}
312
 
 
313
 
static int au_test_robr_shwh(struct super_block *sb, const struct qstr *name)
314
 
{
315
 
        if (unlikely(!au_flag_test_shwh(sb)
316
 
                     && !strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
317
 
                return -EPERM;
318
 
        return 0;
319
 
}
320
 
 
321
 
#endif /* CONFIG_AUFS_ROBR */
 
50
#endif /* CONFIG_AUFS_BR_NFS || CONFIG_AUFS_DLGT */
322
51
 
323
52
struct au_lkup_one_args {
324
53
        struct dentry **errp;
325
54
        const char *name;
326
55
        struct dentry *parent;
327
56
        int len;
328
 
        struct aufs_ndx *ndx;
 
57
        struct au_ndx *ndx;
329
58
};
330
59
 
331
60
static void au_call_lkup_one(void *args)
340
69
#define au_ftest_lkup(flags, name)      ((flags) & AuLkup_##name)
341
70
#define au_fset_lkup(flags, name)       { (flags) |= AuLkup_##name; }
342
71
#define au_fclr_lkup(flags, name)       { (flags) &= ~AuLkup_##name; }
 
72
#ifndef CONFIG_AUFS_DLGT
 
73
#undef AuLkup_DLGT
 
74
#define AuLkup_DLGT     0
 
75
#undef AuLkup_DIRPERM1
 
76
#define AuLkup_DIRPERM1 0
 
77
#endif
343
78
 
344
79
struct au_do_lookup_args {
345
80
        unsigned int            flags;
357
92
                            struct au_do_lookup_args *args)
358
93
{
359
94
        struct dentry *h_dentry;
360
 
        int wh_found, wh_able, opq;
 
95
        int wh_found, wh_able, opq, err;
361
96
        struct inode *h_dir, *h_inode, *inode;
362
97
        struct qstr *name;
363
98
        struct super_block *sb;
364
99
        struct nameidata tmp_nd;
365
 
        struct aufs_ndx ndx = {
 
100
        struct au_ndx ndx = {
366
101
                .flags  = 0,
367
102
                .nd     = args->nd
368
103
        };
382
117
        if (unlikely(au_ftest_lkup(args->flags, DIRPERM1)))
383
118
                au_fset_ndx(ndx.flags, DIRPERM1);
384
119
        LKTRTrace("nfsmnt %p\n", ndx.nfsmnt);
385
 
        ndx.br = stobr(sb, bindex);
386
 
        wh_able = br_whable(ndx.br->br_perm);
 
120
        ndx.br = au_sbr(sb, bindex);
 
121
        wh_able = au_br_whable(ndx.br->br_perm);
387
122
        name = &dentry->d_name;
388
123
        if (unlikely(wh_able))
389
124
                wh_found = au_test_robr_wh(name, h_parent, wh_name,
396
131
                goto out;
397
132
 
398
133
        /* We found a whiteout */
399
 
        //set_dbend(dentry, bindex);
400
 
        set_dbwh(dentry, bindex);
 
134
        //au_set_dbend(dentry, bindex);
 
135
        au_set_dbwh(dentry, bindex);
401
136
        if (!allow_neg)
402
137
                return NULL; /* success */
403
138
        if (unlikely(ndx.nd
423
158
                   || (args->type && args->type != (h_inode->i_mode & S_IFMT)))
424
159
                goto out_neg;
425
160
 
426
 
        if (dbend(dentry) <= bindex)
427
 
                set_dbend(dentry, bindex);
428
 
        if (dbstart(dentry) < 0 || bindex < dbstart(dentry))
429
 
                set_dbstart(dentry, bindex);
430
 
        set_h_dptr(dentry, bindex, h_dentry);
 
161
        if (au_dbend(dentry) <= bindex)
 
162
                au_set_dbend(dentry, bindex);
 
163
        if (au_dbstart(dentry) < 0 || bindex < au_dbstart(dentry))
 
164
                au_set_dbstart(dentry, bindex);
 
165
        au_set_h_dptr(dentry, bindex, h_dentry);
431
166
 
432
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) \
433
 
        && !defined(AuNoNfsBranch)
434
 
        if (unlikely(ndx.nd_file)) {
435
 
                int err;
436
 
                AuDebugOn(!args->nd);
437
 
                err = au_set_h_intent(dentry, bindex,
438
 
                                      args->nd->intent.open.file, ndx.nd_file);
439
 
                if (unlikely(err)) {
440
 
                        fput(ndx.nd_file);
441
 
                        set_h_dptr(dentry, bindex, NULL);
442
 
                        //todo: update bstart and bend
443
 
                        h_dentry = ERR_PTR(err);
444
 
                        goto out;
445
 
                }
 
167
        err = au_br_nfs_h_intent(ndx.nd_file, dentry, bindex, args->nd);
 
168
        if (unlikely(err)) {
 
169
                h_dentry = ERR_PTR(err);
 
170
                goto out;
446
171
        }
447
 
#endif
448
172
 
449
173
        inode = dentry->d_inode;
450
174
        if (!h_inode || !S_ISDIR(h_inode->i_mode) || !wh_able
452
176
                return h_dentry; /* success */
453
177
 
454
178
        vfsub_i_lock_nested(h_inode, AuLsc_I_CHILD);
455
 
        opq = au_test_diropq(h_dentry, &ndx);
 
179
        opq = au_diropq_test(h_dentry, &ndx);
456
180
        //if (LktrCond) opq = -1;
457
181
        vfsub_i_unlock(h_inode);
458
182
        if (opq > 0)
459
 
                set_dbdiropq(dentry, bindex);
 
183
                au_set_dbdiropq(dentry, bindex);
460
184
        else if (unlikely(opq < 0)) {
461
 
                set_h_dptr(dentry, bindex, NULL);
 
185
                au_set_h_dptr(dentry, bindex, NULL);
462
186
                h_dentry = ERR_PTR(opq);
463
187
        }
464
188
        goto out;
485
209
        const struct qstr *name = &dentry->d_name;
486
210
        struct qstr whname;
487
211
        struct super_block *sb;
 
212
        unsigned int mnt_flags;
488
213
        struct inode *inode;
489
214
        struct au_do_lookup_args args = {
490
215
                .type   = type,
501
226
        if (unlikely(err))
502
227
                goto out;
503
228
 
504
 
        err = au_alloc_whname(name->name, name->len, &whname);
505
 
        //if (LktrCond) {au_free_whname(&whname); err = -1;}
 
229
        err = au_wh_name_alloc(name->name, name->len, &whname);
 
230
        //if (LktrCond) {au_wh_name_free(&whname); err = -1;}
506
231
        if (unlikely(err))
507
232
                goto out;
508
233
 
509
234
        sb = dentry->d_sb;
 
235
        mnt_flags = au_mntflags(sb);
510
236
        inode = dentry->d_inode;
511
237
        isdir = (inode && S_ISDIR(inode->i_mode));
512
238
        args.flags = 0;
513
 
        if (unlikely(au_need_dlgt(sb)))
 
239
        if (unlikely(au_opt_test_dlgt(mnt_flags)))
514
240
                au_fset_lkup(args.flags, DLGT);
515
 
        if (unlikely(au_need_dirperm1(sb)))
 
241
        if (unlikely(au_opt_test_dirperm1(mnt_flags)))
516
242
                au_fset_lkup(args.flags, DIRPERM1);
517
243
        if (!type)
518
244
                au_fset_lkup(args.flags, ALLOW_NEG);
519
245
        npositive = 0;
520
 
        btail = dbtaildir(parent);
 
246
        btail = au_dbtaildir(parent);
521
247
        for (bindex = bstart; bindex <= btail; bindex++) {
522
248
                struct dentry *h_parent, *h_dentry;
523
249
                struct inode *h_inode, *h_dir;
548
274
                        goto out_wh;
549
275
                au_fclr_lkup(args.flags, ALLOW_NEG);
550
276
 
551
 
                if (dbwh(dentry) >= 0)
 
277
                if (au_dbwh(dentry) >= 0)
552
278
                        break;
553
279
                if (!h_dentry)
554
280
                        continue;
562
288
                        break;
563
289
                else if (isdir) {
564
290
                        /* the type of lowers may be different */
565
 
                        bdiropq = dbdiropq(dentry);
 
291
                        bdiropq = au_dbdiropq(dentry);
566
292
                        if (bdiropq >= 0 && bdiropq <= bindex)
567
293
                                break;
568
294
                }
575
301
        err = npositive;
576
302
 
577
303
 out_wh:
578
 
        au_free_whname(&whname);
 
304
        au_wh_name_free(&whname);
579
305
 out:
580
306
        dput(parent);
581
307
        AuTraceErr(err);
583
309
}
584
310
 
585
311
struct dentry *au_sio_lkup_one(const char *name, struct dentry *parent, int len,
586
 
                               struct aufs_ndx *ndx)
 
312
                               struct au_ndx *ndx)
587
313
{
588
314
        struct dentry *dentry;
589
315
        int wkq_err;
590
316
 
591
317
        LKTRTrace("%.*s/%.*s\n", AuDLNPair(parent), len, name);
592
318
 
593
 
        if (!au_test_perm_sio(parent->d_inode, MAY_EXEC,
594
 
                              au_ftest_ndx(ndx->flags, DLGT)))
 
319
        if (!au_test_h_perm_sio(parent->d_inode, MAY_EXEC,
 
320
                                au_ftest_ndx(ndx->flags, DLGT)))
595
321
                dentry = au_lkup_one(name, parent, len, ndx);
596
322
        else {
597
323
                // ugly
624
350
        int err;
625
351
        struct dentry *parent, *h_parent, *h_dentry;
626
352
        struct inode *h_dir;
627
 
        struct aufs_ndx ndx = {
 
353
        struct au_ndx ndx = {
628
354
                .flags  = 0,
629
355
                .nd     = NULL,
630
356
                //.br   = NULL
631
357
        };
632
358
        struct super_block *sb;
 
359
        unsigned int mnt_flags;
633
360
 
634
361
        LKTRTrace("%.*s, b%d\n", AuDLNPair(dentry), bindex);
635
362
        /* dir may not be locked */
642
369
        AuDebugOn(!h_dir || !S_ISDIR(h_dir->i_mode));
643
370
 
644
371
        sb = dentry->d_sb;
 
372
        mnt_flags = au_mntflags(sb);
645
373
        ndx.nfsmnt = au_nfsmnt(sb, bindex);
646
 
        if (unlikely(au_need_dlgt(sb)))
 
374
        if (unlikely(au_opt_test_dlgt(mnt_flags)))
647
375
                au_fset_ndx(ndx.flags, DLGT);
648
 
        if (unlikely(au_need_dirperm1(sb)))
 
376
        if (unlikely(au_opt_test_dirperm1(mnt_flags)))
649
377
                au_fset_ndx(ndx.flags, DIRPERM1);
650
378
        h_dentry = au_sio_lkup_one(dentry->d_name.name, h_parent,
651
379
                                   dentry->d_name.len, &ndx);
661
389
                goto out;
662
390
        }
663
391
 
664
 
        if (bindex < dbstart(dentry))
665
 
                set_dbstart(dentry, bindex);
666
 
        if (dbend(dentry) < bindex)
667
 
                set_dbend(dentry, bindex);
668
 
        set_h_dptr(dentry, bindex, h_dentry);
 
392
        if (bindex < au_dbstart(dentry))
 
393
                au_set_dbstart(dentry, bindex);
 
394
        if (au_dbend(dentry) < bindex)
 
395
                au_set_dbend(dentry, bindex);
 
396
        au_set_h_dptr(dentry, bindex, h_dentry);
669
397
        err = 0;
670
398
 
671
399
 out:
681
409
int au_refresh_hdentry(struct dentry *dentry, mode_t type)
682
410
{
683
411
        int npositive, new_sz;
684
 
        struct aufs_dinfo *dinfo;
 
412
        struct au_dinfo *dinfo;
685
413
        struct super_block *sb;
686
414
        struct dentry *parent;
687
415
        aufs_bindex_t bindex, parent_bend, parent_bstart, bwh, bdiropq, bend;
688
 
        struct aufs_hdentry *p;
 
416
        struct au_hdentry *p;
689
417
        au_gen_t sgen;
690
418
 
691
419
        LKTRTrace("%.*s, type 0%o\n", AuDLNPair(dentry), type);
698
426
                  || au_iigen(parent->d_inode) != sgen);
699
427
 
700
428
        npositive = -ENOMEM;
701
 
        new_sz = sizeof(*dinfo->di_hdentry) * (sbend(sb) + 1);
702
 
        dinfo = dtodi(dentry);
 
429
        new_sz = sizeof(*dinfo->di_hdentry) * (au_sbend(sb) + 1);
 
430
        dinfo = au_di(dentry);
703
431
        p = au_kzrealloc(dinfo->di_hdentry, sizeof(*p) * (dinfo->di_bend + 1),
704
432
                         new_sz, GFP_KERNEL);
705
433
        //p = NULL;
713
441
        p += dinfo->di_bstart;
714
442
        for (bindex = dinfo->di_bstart; bindex <= bend; bindex++, p++) {
715
443
                struct dentry *hd, *hdp;
716
 
                struct aufs_hdentry tmp, *q;
 
444
                struct au_hdentry tmp, *q;
717
445
                aufs_bindex_t new_bindex;
718
446
 
719
447
                hd = p->hd_dentry;
733
461
                if (dinfo->di_bdiropq == bindex)
734
462
                        bdiropq = new_bindex;
735
463
                if (new_bindex < 0) { // test here
736
 
                        hdput(p, /*do_free*/0);
 
464
                        au_hdput(p, /*do_free*/0);
737
465
                        p->hd_dentry = NULL;
738
466
                        continue;
739
467
                }
750
478
 
751
479
        // test here
752
480
        dinfo->di_bwh = -1;
753
 
        if (unlikely(bwh >= 0 && bwh <= sbend(sb) && sbr_whable(sb, bwh)))
 
481
        if (unlikely(bwh >= 0 && bwh <= au_sbend(sb) && au_sbr_whable(sb, bwh)))
754
482
                dinfo->di_bwh = bwh;
755
483
        dinfo->di_bdiropq = -1;
756
 
        if (unlikely(bdiropq >= 0 && bdiropq <= sbend(sb)
757
 
                     && sbr_whable(sb, bdiropq)))
 
484
        if (unlikely(bdiropq >= 0 && bdiropq <= au_sbend(sb)
 
485
                     && au_sbr_whable(sb, bdiropq)))
758
486
                dinfo->di_bdiropq = bdiropq;
759
 
        parent_bend = dbend(parent);
 
487
        parent_bend = au_dbend(parent);
760
488
        p = dinfo->di_hdentry;
761
489
        for (bindex = 0; bindex <= parent_bend; bindex++, p++)
762
490
                if (p->hd_dentry) {
772
500
                }
773
501
 
774
502
        npositive = 0;
775
 
        parent_bstart = dbstart(parent);
 
503
        parent_bstart = au_dbstart(parent);
776
504
        if (type != S_IFDIR && dinfo->di_bstart == parent_bstart)
777
505
                goto out_dgen; /* success */
778
506
 
861
589
                mode = (inode->i_mode & S_IFMT);
862
590
                plus = (inode->i_nlink > 0);
863
591
                first = au_h_iptr(inode);
864
 
                ibs = ibstart(inode);
865
 
                ibe = ibend(inode);
 
592
                ibs = au_ibstart(inode);
 
593
                ibe = au_ibend(inode);
866
594
        }
867
595
 
868
 
        bstart = dbstart(dentry);
 
596
        bstart = au_dbstart(dentry);
869
597
        btail = bstart;
870
598
        if (inode && S_ISDIR(inode->i_mode))
871
 
                btail = dbtaildir(dentry);
 
599
                btail = au_dbtaildir(dentry);
872
600
        locked = au_lock_nd(dentry, nd);
873
601
        for (bindex = bstart; bindex <= btail; bindex++) {
874
602
                h_dentry = au_h_dptr_i(dentry, bindex);
906
634
                        if (nd) {
907
635
                                memcpy(&fake_nd, nd, sizeof(*nd));
908
636
                                err = au_fake_intent(&fake_nd,
909
 
                                                     sbr_perm(sb, bindex));
 
637
                                                     au_sbr_perm(sb, bindex));
910
638
                                if (unlikely(err))
911
639
                                        goto err;
912
640
                        }
1067
795
        AuDebugOn(!dentry->d_inode);
1068
796
        DiMustWriteLock(dentry);
1069
797
 
1070
 
        if (!au_ftest_si(stosi(dentry->d_sb), FAILED_REFRESH_DIRS))
 
798
        if (!au_ftest_si(au_sbi(dentry->d_sb), FAILED_REFRESH_DIRS))
1071
799
                return simple_reval_dpath(dentry, sgen);
1072
800
 
1073
801
        /* slow loop, keep it simple and stupid */
1127
855
        au_gen_t sgen;
1128
856
        struct inode *inode;
1129
857
        struct nameidata tmp_nd, *ndp;
1130
 
        struct aufs_sbinfo *sbinfo;
1131
858
        //todo: no more lower nameidata, only here. re-use it.
1132
859
 
1133
860
        LKTRTrace("dentry %.*s\n", AuDLNPair(dentry));
1197
924
        AuDebugOn(au_digen(dentry) != sgen);
1198
925
        AuDebugOn(inode && au_iigen(inode) != sgen);
1199
926
        err = -EINVAL;
1200
 
        sbinfo = stosi(sb);
1201
 
        do_udba = (AuFlag(sbinfo, f_udba) != AuUdba_NONE);
1202
 
        if (do_udba && inode && ibstart(inode) >= 0
 
927
        do_udba = !au_opt_test(au_mntflags(sb), UDBA_NONE);
 
928
        if (do_udba && inode && au_ibstart(inode) >= 0
1203
929
            && au_test_higen(inode, au_h_iptr(inode)))
1204
930
                goto out;
1205
 
        ndp = au_dup_nd(sbinfo, &tmp_nd, nd);
 
931
        ndp = au_dup_nd(au_sbi(sb), &tmp_nd, nd);
1206
932
        err = h_d_revalidate(dentry, inode, ndp, do_udba);
1207
933
        //err = -1;
1208
934
 
1230
956
 
1231
957
static void aufs_d_release(struct dentry *dentry)
1232
958
{
1233
 
        struct aufs_dinfo *dinfo;
 
959
        struct au_dinfo *dinfo;
1234
960
        aufs_bindex_t bend, bindex;
1235
961
 
1236
962
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
1243
969
        /* dentry may not be revalidated */
1244
970
        bindex = dinfo->di_bstart;
1245
971
        if (bindex >= 0) {
1246
 
                struct aufs_hdentry *p;
 
972
                struct au_hdentry *p;
1247
973
                bend = dinfo->di_bend;
1248
974
                AuDebugOn(bend < bindex);
1249
975
                p = dinfo->di_hdentry + bindex;
1250
976
                while (bindex++ <= bend) {
1251
977
                        if (p->hd_dentry)
1252
 
                                hdput(p, /*do_free*/1);
 
978
                                au_hdput(p, /*do_free*/1);
1253
979
                        p++;
1254
980
                }
1255
981
        }