From d635711daa98be86d4c7fd01499c34f566b54ccb Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 10 Jun 2016 05:30:17 -0300 Subject: Linux-libre 4.6.2-gnu --- fs/aufs/branch.c | 209 +++++++++++++++++++++++++-------------------------- fs/aufs/branch.h | 34 ++++++++- fs/aufs/cpup.c | 44 +++++------ fs/aufs/dbgaufs.c | 14 ++-- fs/aufs/debug.c | 76 ++++++++++--------- fs/aufs/dentry.c | 124 +++++++++++++++--------------- fs/aufs/dentry.h | 26 +++---- fs/aufs/dinfo.c | 124 +++++++++++++++--------------- fs/aufs/dir.c | 98 ++++++++++++------------ fs/aufs/dynop.c | 8 +- fs/aufs/export.c | 15 +++- fs/aufs/f_op.c | 12 +-- fs/aufs/fhsm.c | 18 ++--- fs/aufs/file.c | 102 ++++++++++++------------- fs/aufs/file.h | 8 +- fs/aufs/finfo.c | 11 +-- fs/aufs/hfsnotify.c | 3 +- fs/aufs/hnotify.c | 24 +++--- fs/aufs/i_op.c | 90 ++++++++++------------ fs/aufs/i_op_add.c | 66 +++++++--------- fs/aufs/i_op_del.c | 44 +++++------ fs/aufs/i_op_ren.c | 92 +++++++++++------------ fs/aufs/iinfo.c | 95 +++++++++++------------ fs/aufs/inode.c | 90 ++++++++++------------ fs/aufs/inode.h | 41 +++++----- fs/aufs/ioctl.c | 10 +-- fs/aufs/module.c | 44 +++++------ fs/aufs/module.h | 16 ---- fs/aufs/mvdown.c | 48 ++++++------ fs/aufs/opts.c | 38 +++++----- fs/aufs/plink.c | 12 +-- fs/aufs/posix_acl.c | 2 +- fs/aufs/rdu.c | 16 ++-- fs/aufs/rwsem.h | 79 ++++++++++--------- fs/aufs/sbinfo.c | 17 +++-- fs/aufs/super.c | 34 ++++----- fs/aufs/super.h | 36 ++++++--- fs/aufs/sysfs.c | 26 +++---- fs/aufs/vdir.c | 10 +-- fs/aufs/vfsub.c | 2 +- fs/aufs/wbr_policy.c | 76 +++++++++---------- fs/aufs/whout.c | 12 +-- fs/aufs/wkq.c | 11 ++- fs/aufs/wkq.h | 8 +- fs/aufs/xino.c | 71 +++++++++-------- 45 files changed, 1029 insertions(+), 1007 deletions(-) (limited to 'fs/aufs') diff --git a/fs/aufs/branch.c b/fs/aufs/branch.c index 496bdaa99..5259d30d1 100644 --- a/fs/aufs/branch.c +++ b/fs/aufs/branch.c @@ -25,7 +25,8 @@ static void au_br_do_free(struct au_branch *br) fput(br->br_xino.xi_file); mutex_destroy(&br->br_xino.xi_nondir_mtx); - AuDebugOn(atomic_read(&br->br_count)); + AuDebugOn(au_br_count(br)); + au_br_count_fin(br); wbr = br->br_wbr; if (wbr) { @@ -65,7 +66,7 @@ void au_br_free(struct au_sbinfo *sbinfo) AuRwMustWriteLock(&sbinfo->si_rwsem); - bmax = sbinfo->si_bend + 1; + bmax = sbinfo->si_bbot + 1; br = sbinfo->si_branch; while (bmax--) au_br_do_free(*br++); @@ -76,10 +77,10 @@ void au_br_free(struct au_sbinfo *sbinfo) */ int au_br_index(struct super_block *sb, aufs_bindex_t br_id) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) if (au_sbr_id(sb, bindex) == br_id) return bindex; return -1; @@ -144,7 +145,7 @@ static struct au_branch *au_br_alloc(struct super_block *sb, int new_nbranch, err = au_di_realloc(au_di(root), new_nbranch); if (!err) { inode = d_inode(root); - err = au_ii_realloc(au_ii(inode), new_nbranch); + err = au_hinode_realloc(au_ii(inode), new_nbranch); } if (!err) return add_branch; /* success */ @@ -186,13 +187,13 @@ out: static int test_add(struct super_block *sb, struct au_opt_add *add, int remount) { int err; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct dentry *root, *h_dentry; struct inode *inode, *h_inode; root = sb->s_root; - bend = au_sbend(sb); - if (unlikely(bend >= 0 + bbot = au_sbbot(sb); + if (unlikely(bbot >= 0 && au_find_dbindex(root, add->path.dentry) >= 0)) { err = 1; if (!remount) { @@ -204,13 +205,13 @@ static int test_add(struct super_block *sb, struct au_opt_add *add, int remount) err = -ENOSPC; /* -E2BIG; */ if (unlikely(AUFS_BRANCH_MAX <= add->bindex - || AUFS_BRANCH_MAX - 1 <= bend)) { + || AUFS_BRANCH_MAX - 1 <= bbot)) { pr_err("number of branches exceeded %s\n", add->pathname); goto out; } err = -EDOM; - if (unlikely(add->bindex < 0 || bend + 1 < add->bindex)) { + if (unlikely(add->bindex < 0 || bbot + 1 < add->bindex)) { pr_err("bad index %d\n", add->bindex); goto out; } @@ -244,11 +245,11 @@ static int test_add(struct super_block *sb, struct au_opt_add *add, int remount) if (unlikely(err)) goto out; - if (bend < 0) + if (bbot < 0) return 0; /* success */ err = -EINVAL; - for (bindex = 0; bindex <= bend; bindex++) + for (bindex = 0; bindex <= bbot; bindex++) if (unlikely(test_overlap(sb, add->path.dentry, au_h_dptr(root, bindex)))) { pr_err("%s is overlapped\n", add->pathname); @@ -370,7 +371,7 @@ static int au_br_init(struct au_branch *br, struct super_block *sb, br->br_perm = add->perm; br->br_path = add->path; /* set first, path_get() later */ spin_lock_init(&br->br_dykey_lock); - atomic_set(&br->br_count, 0); + au_br_count_init(br); atomic_set(&br->br_xino_running, 0); br->br_id = au_new_br_id(sb); AuDebugOn(br->br_id < 0); @@ -402,7 +403,7 @@ out: } static void au_br_do_add_brp(struct au_sbinfo *sbinfo, aufs_bindex_t bindex, - struct au_branch *br, aufs_bindex_t bend, + struct au_branch *br, aufs_bindex_t bbot, aufs_bindex_t amount) { struct au_branch **brp; @@ -412,13 +413,13 @@ static void au_br_do_add_brp(struct au_sbinfo *sbinfo, aufs_bindex_t bindex, brp = sbinfo->si_branch + bindex; memmove(brp + 1, brp, sizeof(*brp) * amount); *brp = br; - sbinfo->si_bend++; - if (unlikely(bend < 0)) - sbinfo->si_bend = 0; + sbinfo->si_bbot++; + if (unlikely(bbot < 0)) + sbinfo->si_bbot = 0; } static void au_br_do_add_hdp(struct au_dinfo *dinfo, aufs_bindex_t bindex, - aufs_bindex_t bend, aufs_bindex_t amount) + aufs_bindex_t bbot, aufs_bindex_t amount) { struct au_hdentry *hdp; @@ -427,25 +428,24 @@ static void au_br_do_add_hdp(struct au_dinfo *dinfo, aufs_bindex_t bindex, hdp = dinfo->di_hdentry + bindex; memmove(hdp + 1, hdp, sizeof(*hdp) * amount); au_h_dentry_init(hdp); - dinfo->di_bend++; - if (unlikely(bend < 0)) - dinfo->di_bstart = 0; + dinfo->di_bbot++; + if (unlikely(bbot < 0)) + dinfo->di_btop = 0; } static void au_br_do_add_hip(struct au_iinfo *iinfo, aufs_bindex_t bindex, - aufs_bindex_t bend, aufs_bindex_t amount) + aufs_bindex_t bbot, aufs_bindex_t amount) { struct au_hinode *hip; AuRwMustWriteLock(&iinfo->ii_rwsem); - hip = iinfo->ii_hinode + bindex; + hip = au_hinode(iinfo, bindex); memmove(hip + 1, hip, sizeof(*hip) * amount); - hip->hi_inode = NULL; - au_hn_init(hip); - iinfo->ii_bend++; - if (unlikely(bend < 0)) - iinfo->ii_bstart = 0; + au_hinode_init(hip); + iinfo->ii_bbot++; + if (unlikely(bbot < 0)) + iinfo->ii_btop = 0; } static void au_br_do_add(struct super_block *sb, struct au_branch *br, @@ -453,17 +453,17 @@ static void au_br_do_add(struct super_block *sb, struct au_branch *br, { struct dentry *root, *h_dentry; struct inode *root_inode, *h_inode; - aufs_bindex_t bend, amount; + aufs_bindex_t bbot, amount; root = sb->s_root; root_inode = d_inode(root); - bend = au_sbend(sb); - amount = bend + 1 - bindex; + bbot = au_sbbot(sb); + amount = bbot + 1 - bindex; h_dentry = au_br_dentry(br); au_sbilist_lock(); - au_br_do_add_brp(au_sbi(sb), bindex, br, bend, amount); - au_br_do_add_hdp(au_di(root), bindex, bend, amount); - au_br_do_add_hip(au_ii(root_inode), bindex, bend, amount); + au_br_do_add_brp(au_sbi(sb), bindex, br, bbot, amount); + au_br_do_add_hdp(au_di(root), bindex, bbot, amount); + au_br_do_add_hip(au_ii(root_inode), bindex, bbot, amount); au_set_h_dptr(root, bindex, dget(h_dentry)); h_inode = d_inode(h_dentry); au_set_h_iptr(root_inode, bindex, au_igrab(h_inode), /*flags*/0); @@ -473,7 +473,7 @@ static void au_br_do_add(struct super_block *sb, struct au_branch *br, int au_br_add(struct super_block *sb, struct au_opt_add *add, int remount) { int err; - aufs_bindex_t bend, add_bindex; + aufs_bindex_t bbot, add_bindex; struct dentry *root, *h_dentry; struct inode *root_inode; struct au_branch *add_branch; @@ -489,8 +489,8 @@ int au_br_add(struct super_block *sb, struct au_opt_add *add, int remount) goto out; /* success */ } - bend = au_sbend(sb); - add_branch = au_br_alloc(sb, bend + 2, add->perm); + bbot = au_sbbot(sb); + add_branch = au_br_alloc(sb, bbot + 2, add->perm); err = PTR_ERR(add_branch); if (IS_ERR(add_branch)) goto out; @@ -566,7 +566,7 @@ static unsigned long long au_farray_cb(struct super_block *sb, void *a, static struct file **au_farray_alloc(struct super_block *sb, unsigned long long *max) { - *max = atomic_long_read(&au_sbi(sb)->si_nfiles); + *max = au_nfiles(sb); return au_array_alloc(max, au_farray_cb, sb, /*arg*/NULL); } @@ -592,16 +592,16 @@ static void au_farray_free(struct file **a, unsigned long long max) pr_info(fmt, ##__VA_ARGS__); \ } while (0) -static int au_test_ibusy(struct inode *inode, aufs_bindex_t bstart, - aufs_bindex_t bend) +static int au_test_ibusy(struct inode *inode, aufs_bindex_t btop, + aufs_bindex_t bbot) { - return (inode && !S_ISDIR(inode->i_mode)) || bstart == bend; + return (inode && !S_ISDIR(inode->i_mode)) || btop == bbot; } -static int au_test_dbusy(struct dentry *dentry, aufs_bindex_t bstart, - aufs_bindex_t bend) +static int au_test_dbusy(struct dentry *dentry, aufs_bindex_t btop, + aufs_bindex_t bbot) { - return au_test_ibusy(d_inode(dentry), bstart, bend); + return au_test_ibusy(d_inode(dentry), btop, bbot); } /* @@ -611,7 +611,7 @@ static int test_dentry_busy(struct dentry *root, aufs_bindex_t bindex, unsigned int sigen, const unsigned int verbose) { int err, i, j, ndentry; - aufs_bindex_t bstart, bend; + aufs_bindex_t btop, bbot; struct au_dcsub_pages dpages; struct au_dpage *dpage; struct dentry *d; @@ -651,12 +651,12 @@ static int test_dentry_busy(struct dentry *root, aufs_bindex_t bindex, } /* AuDbgDentry(d); */ - bstart = au_dbstart(d); - bend = au_dbend(d); - if (bstart <= bindex - && bindex <= bend + btop = au_dbtop(d); + bbot = au_dbbot(d); + if (btop <= bindex + && bindex <= bbot && au_h_dptr(d, bindex) - && au_test_dbusy(d, bstart, bend)) { + && au_test_dbusy(d, btop, bbot)) { err = -EBUSY; AuVerbose(verbose, "busy %pd\n", d); AuDbgDentry(d); @@ -677,7 +677,7 @@ static int test_inode_busy(struct super_block *sb, aufs_bindex_t bindex, int err; unsigned long long max, ull; struct inode *i, **array; - aufs_bindex_t bstart, bend; + aufs_bindex_t btop, bbot; array = au_iarray_alloc(sb, &max); err = PTR_ERR(array); @@ -708,12 +708,12 @@ static int test_inode_busy(struct super_block *sb, aufs_bindex_t bindex, } } - bstart = au_ibstart(i); - bend = au_ibend(i); - if (bstart <= bindex - && bindex <= bend + btop = au_ibtop(i); + bbot = au_ibbot(i); + if (btop <= bindex + && bindex <= bbot && au_h_iptr(i, bindex) - && au_test_ibusy(i, bstart, bend)) { + && au_test_ibusy(i, btop, bbot)) { err = -EBUSY; AuVerbose(verbose, "busy i%lu\n", i->i_ino); AuDbgInode(i); @@ -749,7 +749,7 @@ static int test_dir_busy(struct file *file, aufs_bindex_t br_id, { int err; unsigned char matched, root; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_fidir *fidir; struct au_hfile *hfile; @@ -765,8 +765,8 @@ static int test_dir_busy(struct file *file, aufs_bindex_t br_id, matched = 0; fidir = au_fi(file)->fi_hdir; AuDebugOn(!fidir); - bend = au_fbend_dir(file); - for (bindex = au_fbstart(file); bindex <= bend; bindex++) { + bbot = au_fbbot_dir(file); + for (bindex = au_fbtop(file); bindex <= bbot; bindex++) { hfile = fidir->fd_hfile + bindex; if (!hfile->hf_file) continue; @@ -788,7 +788,7 @@ static int test_file_busy(struct super_block *sb, aufs_bindex_t br_id, { int err, idx; unsigned long long ull, max; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct file *file, **array; struct dentry *root; struct au_hfile *hfile; @@ -809,7 +809,7 @@ static int test_file_busy(struct super_block *sb, aufs_bindex_t br_id, /* AuDbg("%pD\n", file); */ fi_read_lock(file); - bstart = au_fbstart(file); + btop = au_fbtop(file); if (!d_is_dir(file->f_path.dentry)) { hfile = &au_fi(file)->fi_htop; if (hfile->hf_br->br_id == br_id) @@ -832,7 +832,7 @@ static void br_del_file(struct file **to_free, unsigned long long opened, aufs_bindex_t br_id) { unsigned long long ull; - aufs_bindex_t bindex, bstart, bend, bfound; + aufs_bindex_t bindex, btop, bbot, bfound; struct file *file; struct au_fidir *fidir; struct au_hfile *hfile; @@ -848,9 +848,9 @@ static void br_del_file(struct file **to_free, unsigned long long opened, fidir = au_fi(file)->fi_hdir; AuDebugOn(!fidir); fi_write_lock(file); - bstart = au_fbstart(file); - bend = au_fbend_dir(file); - for (bindex = bstart; bindex <= bend; bindex++) { + btop = au_fbtop(file); + bbot = au_fbbot_dir(file); + for (bindex = btop; bindex <= bbot; bindex++) { hfile = fidir->fd_hfile + bindex; if (!hfile->hf_file) continue; @@ -862,10 +862,10 @@ static void br_del_file(struct file **to_free, unsigned long long opened, } AuDebugOn(bfound < 0); au_set_h_fptr(file, bfound, NULL); - if (bfound == bstart) { - for (bstart++; bstart <= bend; bstart++) - if (au_hf_dir(file, bstart)) { - au_set_fbstart(file, bstart); + if (bfound == btop) { + for (btop++; btop <= bbot; btop++) + if (au_hf_dir(file, btop)) { + au_set_fbtop(file, btop); break; } } @@ -875,59 +875,58 @@ static void br_del_file(struct file **to_free, unsigned long long opened, static void au_br_do_del_brp(struct au_sbinfo *sbinfo, const aufs_bindex_t bindex, - const aufs_bindex_t bend) + const aufs_bindex_t bbot) { struct au_branch **brp, **p; AuRwMustWriteLock(&sbinfo->si_rwsem); brp = sbinfo->si_branch + bindex; - if (bindex < bend) - memmove(brp, brp + 1, sizeof(*brp) * (bend - bindex)); - sbinfo->si_branch[0 + bend] = NULL; - sbinfo->si_bend--; + if (bindex < bbot) + memmove(brp, brp + 1, sizeof(*brp) * (bbot - bindex)); + sbinfo->si_branch[0 + bbot] = NULL; + sbinfo->si_bbot--; - p = krealloc(sbinfo->si_branch, sizeof(*p) * bend, AuGFP_SBILIST); + p = krealloc(sbinfo->si_branch, sizeof(*p) * bbot, AuGFP_SBILIST); if (p) sbinfo->si_branch = p; /* harmless error */ } static void au_br_do_del_hdp(struct au_dinfo *dinfo, const aufs_bindex_t bindex, - const aufs_bindex_t bend) + const aufs_bindex_t bbot) { struct au_hdentry *hdp, *p; AuRwMustWriteLock(&dinfo->di_rwsem); hdp = dinfo->di_hdentry; - if (bindex < bend) + if (bindex < bbot) memmove(hdp + bindex, hdp + bindex + 1, - sizeof(*hdp) * (bend - bindex)); - hdp[0 + bend].hd_dentry = NULL; - dinfo->di_bend--; + sizeof(*hdp) * (bbot - bindex)); + hdp[0 + bbot].hd_dentry = NULL; + dinfo->di_bbot--; - p = krealloc(hdp, sizeof(*p) * bend, AuGFP_SBILIST); + p = krealloc(hdp, sizeof(*p) * bbot, AuGFP_SBILIST); if (p) dinfo->di_hdentry = p; /* harmless error */ } static void au_br_do_del_hip(struct au_iinfo *iinfo, const aufs_bindex_t bindex, - const aufs_bindex_t bend) + const aufs_bindex_t bbot) { struct au_hinode *hip, *p; AuRwMustWriteLock(&iinfo->ii_rwsem); - hip = iinfo->ii_hinode + bindex; - if (bindex < bend) - memmove(hip, hip + 1, sizeof(*hip) * (bend - bindex)); - iinfo->ii_hinode[0 + bend].hi_inode = NULL; - au_hn_init(iinfo->ii_hinode + bend); - iinfo->ii_bend--; + hip = au_hinode(iinfo, bindex); + if (bindex < bbot) + memmove(hip, hip + 1, sizeof(*hip) * (bbot - bindex)); + /* au_hinode_init(au_hinode(iinfo, bbot)); */ + iinfo->ii_bbot--; - p = krealloc(iinfo->ii_hinode, sizeof(*p) * bend, AuGFP_SBILIST); + p = krealloc(iinfo->ii_hinode, sizeof(*p) * bbot, AuGFP_SBILIST); if (p) iinfo->ii_hinode = p; /* harmless error */ @@ -936,7 +935,7 @@ static void au_br_do_del_hip(struct au_iinfo *iinfo, const aufs_bindex_t bindex, static void au_br_do_del(struct super_block *sb, aufs_bindex_t bindex, struct au_branch *br) { - aufs_bindex_t bend; + aufs_bindex_t bbot; struct au_sbinfo *sbinfo; struct dentry *root, *h_root; struct inode *inode, *h_inode; @@ -947,7 +946,7 @@ static void au_br_do_del(struct super_block *sb, aufs_bindex_t bindex, root = sb->s_root; inode = d_inode(root); sbinfo = au_sbi(sb); - bend = sbinfo->si_bend; + bbot = sbinfo->si_bbot; h_root = au_h_dptr(root, bindex); hinode = au_hi(inode, bindex); @@ -955,9 +954,9 @@ static void au_br_do_del(struct super_block *sb, aufs_bindex_t bindex, au_hiput(hinode); au_sbilist_lock(); - au_br_do_del_brp(sbinfo, bindex, bend); - au_br_do_del_hdp(au_di(root), bindex, bend); - au_br_do_del_hip(au_ii(inode), bindex, bend); + au_br_do_del_brp(sbinfo, bindex, bbot); + au_br_do_del_hdp(au_di(root), bindex, bbot); + au_br_do_del_hip(au_ii(inode), bindex, bbot); au_sbilist_unlock(); dput(h_root); @@ -976,7 +975,7 @@ int au_br_del(struct super_block *sb, struct au_opt_del *del, int remount) int err, rerr, i; unsigned long long opened; unsigned int mnt_flags; - aufs_bindex_t bindex, bend, br_id; + aufs_bindex_t bindex, bbot, br_id; unsigned char do_wh, verbose; struct au_branch *br; struct au_wbr *wbr; @@ -1000,8 +999,8 @@ int au_br_del(struct super_block *sb, struct au_opt_del *del, int remount) err = -EBUSY; mnt_flags = au_mntflags(sb); verbose = !!au_opt_test(mnt_flags, VERBOSE); - bend = au_sbend(sb); - if (unlikely(!bend)) { + bbot = au_sbbot(sb); + if (unlikely(!bbot)) { AuVerbose(verbose, "no more branches left\n"); goto out; } @@ -1009,7 +1008,7 @@ int au_br_del(struct super_block *sb, struct au_opt_del *del, int remount) AuDebugOn(!path_equal(&br->br_path, &del->h_path)); br_id = br->br_id; - opened = atomic_read(&br->br_count); + opened = au_br_count(br); if (unlikely(opened)) { to_free = au_array_alloc(&opened, empty_cb, sb, NULL); err = PTR_ERR(to_free); @@ -1089,7 +1088,7 @@ out: static int au_ibusy(struct super_block *sb, struct aufs_ibusy __user *arg) { int err; - aufs_bindex_t bstart, bend; + aufs_bindex_t btop, bbot; struct aufs_ibusy ibusy; struct inode *inode, *h_inode; @@ -1108,7 +1107,7 @@ static int au_ibusy(struct super_block *sb, struct aufs_ibusy __user *arg) err = -EINVAL; si_read_lock(sb, AuLock_FLUSH); - if (unlikely(ibusy.bindex < 0 || ibusy.bindex > au_sbend(sb))) + if (unlikely(ibusy.bindex < 0 || ibusy.bindex > au_sbbot(sb))) goto out_unlock; err = 0; @@ -1120,11 +1119,11 @@ static int au_ibusy(struct super_block *sb, struct aufs_ibusy __user *arg) goto out_unlock; ii_read_lock_child(inode); - bstart = au_ibstart(inode); - bend = au_ibend(inode); - if (bstart <= ibusy.bindex && ibusy.bindex <= bend) { + btop = au_ibtop(inode); + bbot = au_ibbot(inode); + if (btop <= ibusy.bindex && ibusy.bindex <= bbot) { h_inode = au_h_iptr(inode, ibusy.bindex); - if (h_inode && au_test_ibusy(inode, bstart, bend)) + if (h_inode && au_test_ibusy(inode, btop, bbot)) ibusy.h_ino = h_inode->i_ino; } ii_read_unlock(inode); diff --git a/fs/aufs/branch.h b/fs/aufs/branch.h index 4c52ae166..32a4d8f36 100644 --- a/fs/aufs/branch.h +++ b/fs/aufs/branch.h @@ -86,7 +86,7 @@ struct au_branch { struct path br_path; spinlock_t br_dykey_lock; struct au_dykey *br_dykey[AuBrDynOp]; - atomic_t br_count; + struct percpu_counter br_count; struct au_wbr *br_wbr; struct au_br_fhsm *br_fhsm; @@ -121,6 +121,31 @@ static inline struct super_block *au_br_sb(struct au_branch *br) return au_br_mnt(br)->mnt_sb; } +static inline void au_br_get(struct au_branch *br) +{ + percpu_counter_inc(&br->br_count); +} + +static inline void au_br_put(struct au_branch *br) +{ + percpu_counter_dec(&br->br_count); +} + +static inline s64 au_br_count(struct au_branch *br) +{ + return percpu_counter_sum(&br->br_count); +} + +static inline void au_br_count_init(struct au_branch *br) +{ + percpu_counter_init(&br->br_count, 0, GFP_NOFS); +} + +static inline void au_br_count_fin(struct au_branch *br) +{ + percpu_counter_destroy(&br->br_count); +} + static inline int au_br_rdonly(struct au_branch *br) { return ((au_br_sb(br)->s_flags & MS_RDONLY) @@ -216,9 +241,14 @@ struct super_block *au_sbr_sb(struct super_block *sb, aufs_bindex_t bindex) return au_br_sb(au_sbr(sb, bindex)); } +static inline void au_sbr_get(struct super_block *sb, aufs_bindex_t bindex) +{ + au_br_get(au_sbr(sb, bindex)); +} + static inline void au_sbr_put(struct super_block *sb, aufs_bindex_t bindex) { - atomic_dec(&au_sbr(sb, bindex)->br_count); + au_br_put(au_sbr(sb, bindex)); } static inline int au_sbr_perm(struct super_block *sb, aufs_bindex_t bindex) diff --git a/fs/aufs/cpup.c b/fs/aufs/cpup.c index 9ff0963ad..dbf96fd60 100644 --- a/fs/aufs/cpup.c +++ b/fs/aufs/cpup.c @@ -27,7 +27,7 @@ void au_cpup_attr_timesizes(struct inode *inode) { struct inode *h_inode; - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); fsstack_copy_attr_times(inode, h_inode); fsstack_copy_inode_size(inode, h_inode); } @@ -36,10 +36,10 @@ void au_cpup_attr_nlink(struct inode *inode, int force) { struct inode *h_inode; struct super_block *sb; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; sb = inode->i_sb; - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); h_inode = au_h_iptr(inode, bindex); if (!force && !S_ISDIR(h_inode->i_mode) @@ -62,8 +62,8 @@ void au_cpup_attr_nlink(struct inode *inode, int force) * it may includes whplink directory. */ if (S_ISDIR(h_inode->i_mode)) { - bend = au_ibend(inode); - for (bindex++; bindex <= bend; bindex++) { + bbot = au_ibbot(inode); + for (bindex++; bindex <= bbot; bindex++) { h_inode = au_h_iptr(inode, bindex); if (h_inode) au_add_nlink(inode, h_inode); @@ -75,7 +75,7 @@ void au_cpup_attr_changeable(struct inode *inode) { struct inode *h_inode; - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); inode->i_mode = h_inode->i_mode; inode->i_uid = h_inode->i_uid; inode->i_gid = h_inode->i_gid; @@ -97,7 +97,7 @@ void au_cpup_attr_all(struct inode *inode, int force) { struct inode *h_inode; - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); au_cpup_attr_changeable(inode); if (inode->i_nlink > 0) au_cpup_attr_nlink(inode, force); @@ -554,7 +554,7 @@ static int au_do_cpup_dir(struct au_cp_generic *cpg, struct dentry *dst_parent, * particularry setattr case */ dir = d_inode(dst_parent); - if (au_ibstart(dir) == cpg->bdst) + if (au_ibtop(dir) == cpg->bdst) au_cpup_attr_nlink(dir, /*force*/1); inode = d_inode(cpg->dentry); au_cpup_attr_nlink(inode, /*force*/1); @@ -715,7 +715,7 @@ out: static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) { int err, rerr; - aufs_bindex_t old_ibstart; + aufs_bindex_t old_ibtop; unsigned char isdir, plink; struct dentry *h_src, *h_dst, *h_parent; struct inode *dst_inode, *h_dir, *inode, *delegated, *src_inode; @@ -803,7 +803,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) } isdir = S_ISDIR(inode->i_mode); - old_ibstart = au_ibstart(inode); + old_ibtop = au_ibtop(inode); err = cpup_entry(cpg, dst_parent, &a->h_src_attr); if (unlikely(err)) goto out_rev; @@ -820,7 +820,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) goto out_rev; } - if (cpg->bdst < old_ibstart) { + if (cpg->bdst < old_ibtop) { if (S_ISREG(inode->i_mode)) { err = au_dy_iaop(inode, cpg->bdst, dst_inode); if (unlikely(err)) { @@ -830,9 +830,9 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) goto out_rev; } } - au_set_ibstart(inode, cpg->bdst); + au_set_ibtop(inode, cpg->bdst); } else - au_set_ibend(inode, cpg->bdst); + au_set_ibbot(inode, cpg->bdst); au_set_h_iptr(inode, cpg->bdst, au_igrab(dst_inode), au_hi_flags(inode, isdir)); @@ -988,7 +988,7 @@ static int au_cpup_simple(struct au_cp_generic *cpg) /* revert */ au_set_h_dptr(dentry, cpg->bdst, NULL); - au_set_dbstart(dentry, cpg->bsrc); + au_set_dbtop(dentry, cpg->bsrc); } return err; @@ -1050,20 +1050,20 @@ out: int au_sio_cpup_simple(struct au_cp_generic *cpg) { - aufs_bindex_t bsrc, bend; + aufs_bindex_t bsrc, bbot; struct dentry *dentry, *h_dentry; if (cpg->bsrc < 0) { dentry = cpg->dentry; - bend = au_dbend(dentry); - for (bsrc = cpg->bdst + 1; bsrc <= bend; bsrc++) { + bbot = au_dbbot(dentry); + for (bsrc = cpg->bdst + 1; bsrc <= bbot; bsrc++) { h_dentry = au_h_dptr(dentry, bsrc); if (h_dentry) { AuDebugOn(d_is_negative(h_dentry)); break; } } - AuDebugOn(bsrc > bend); + AuDebugOn(bsrc > bbot); cpg->bsrc = bsrc; } AuDebugOn(cpg->bsrc <= cpg->bdst); @@ -1095,10 +1095,10 @@ static int au_do_cpup_wh(struct au_cp_generic *cpg, struct dentry *wh_dentry, AuRwMustWriteLock(&dinfo->di_rwsem); bsrc_orig = cpg->bsrc; - cpg->bsrc = dinfo->di_bstart; + cpg->bsrc = dinfo->di_btop; hdp = dinfo->di_hdentry; h_d_dst = hdp[0 + cpg->bdst].hd_dentry; - dinfo->di_bstart = cpg->bdst; + dinfo->di_btop = cpg->bdst; hdp[0 + cpg->bdst].hd_dentry = wh_dentry; h_d_start = NULL; if (file) { @@ -1115,7 +1115,7 @@ static int au_do_cpup_wh(struct au_cp_generic *cpg, struct dentry *wh_dentry, hdp[0 + cpg->bsrc].hd_dentry = h_d_start; } hdp[0 + cpg->bdst].hd_dentry = h_d_dst; - dinfo->di_bstart = cpg->bsrc; + dinfo->di_btop = cpg->bsrc; cpg->bsrc = bsrc_orig; return err; @@ -1299,7 +1299,7 @@ int au_cp_dirs(struct dentry *dentry, aufs_bindex_t bdst, h_dentry = au_h_dptr(d, bdst); if (!h_dentry || d_is_negative(h_dentry)) { if (h_dentry) - au_update_dbstart(d); + au_update_dbtop(d); au_pin_set_dentry(&pin, d); err = au_do_pin(&pin); diff --git a/fs/aufs/dbgaufs.c b/fs/aufs/dbgaufs.c index 0aefb5ed8..21ac77398 100644 --- a/fs/aufs/dbgaufs.c +++ b/fs/aufs/dbgaufs.c @@ -225,7 +225,7 @@ static int dbgaufs_xino_open(struct inode *inode, struct file *file) sbinfo = inode->i_private; sb = sbinfo->si_sb; si_noflush_read_lock(sb); - if (l <= au_sbend(sb)) { + if (l <= au_sbbot(sb)) { xf = au_sbr(sb, (aufs_bindex_t)l)->br_xino.xi_file; err = dbgaufs_xi_open(xf, file, /*do_fcnt*/1); } else @@ -245,15 +245,15 @@ static const struct file_operations dbgaufs_xino_fop = { void dbgaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex) { - aufs_bindex_t bend; + aufs_bindex_t bbot; struct au_branch *br; struct au_xino_file *xi; if (!au_sbi(sb)->si_dbgaufs) return; - bend = au_sbend(sb); - for (; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); xi = &br->br_xino; debugfs_remove(xi->xi_dbgaufs); @@ -267,7 +267,7 @@ void dbgaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex) struct dentry *parent; struct au_branch *br; struct au_xino_file *xi; - aufs_bindex_t bend; + aufs_bindex_t bbot; char name[sizeof(DbgaufsXi_PREFIX) + 5]; /* "xi" bindex NULL */ sbinfo = au_sbi(sb); @@ -275,8 +275,8 @@ void dbgaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex) if (!parent) return; - bend = au_sbend(sb); - for (; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (; bindex <= bbot; bindex++) { snprintf(name, sizeof(name), DbgaufsXi_PREFIX "%d", bindex); br = au_sbr(sb, bindex); xi = &br->br_xino; diff --git a/fs/aufs/debug.c b/fs/aufs/debug.c index 4529831a9..14e69cbc8 100644 --- a/fs/aufs/debug.c +++ b/fs/aufs/debug.c @@ -128,25 +128,24 @@ static int do_pri_inode(aufs_bindex_t bindex, struct inode *inode, int hn, void au_dpri_inode(struct inode *inode) { struct au_iinfo *iinfo; + struct au_hinode *hi; aufs_bindex_t bindex; int err, hn; err = do_pri_inode(-1, inode, -1, NULL); - if (err || !au_test_aufs(inode->i_sb)) + if (err || !au_test_aufs(inode->i_sb) || is_bad_inode(inode)) return; iinfo = au_ii(inode); - if (!iinfo) - return; - dpri("i-1: bstart %d, bend %d, gen %d\n", - iinfo->ii_bstart, iinfo->ii_bend, au_iigen(inode, NULL)); - if (iinfo->ii_bstart < 0) + dpri("i-1: btop %d, bbot %d, gen %d\n", + iinfo->ii_btop, iinfo->ii_bbot, au_iigen(inode, NULL)); + if (iinfo->ii_btop < 0) return; hn = 0; - for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; bindex++) { - hn = !!au_hn(iinfo->ii_hinode + bindex); - do_pri_inode(bindex, iinfo->ii_hinode[0 + bindex].hi_inode, hn, - iinfo->ii_hinode[0 + bindex].hi_whdentry); + for (bindex = iinfo->ii_btop; bindex <= iinfo->ii_bbot; bindex++) { + hi = au_hinode(iinfo, bindex); + hn = !!au_hn(hi); + do_pri_inode(bindex, hi->hi_inode, hn, hi->hi_whdentry); } } @@ -165,6 +164,8 @@ static int do_pri_dentry(aufs_bindex_t bindex, struct dentry *dentry) struct dentry *wh = NULL; int hn; struct au_iinfo *iinfo; + struct au_hinode *hi; + struct inode *inode; if (!dentry || IS_ERR(dentry)) { dpri("d%d: err %ld\n", bindex, PTR_ERR(dentry)); @@ -178,16 +179,18 @@ static int do_pri_dentry(aufs_bindex_t bindex, struct dentry *dentry) au_dcount(dentry), dentry->d_flags, d_unhashed(dentry) ? "un" : ""); hn = -1; + inode = NULL; if (bindex >= 0 && d_is_positive(dentry) - && au_test_aufs(dentry->d_sb)) { - iinfo = au_ii(d_inode(dentry)); - if (iinfo) { - hn = !!au_hn(iinfo->ii_hinode + bindex); - wh = iinfo->ii_hinode[0 + bindex].hi_whdentry; - } + && au_test_aufs(dentry->d_sb)) + inode = d_inode(dentry); + if (inode && !is_bad_inode(inode)) { + iinfo = au_ii(inode); + hi = au_hinode(iinfo, bindex); + hn = !!au_hn(hi); + wh = hi->hi_whdentry; } - do_pri_inode(bindex, d_inode(dentry), hn, wh); + do_pri_inode(bindex, inode, hn, wh); return 0; } @@ -205,14 +208,14 @@ void au_dpri_dentry(struct dentry *dentry) dinfo = au_di(dentry); if (!dinfo) return; - dpri("d-1: bstart %d, bend %d, bwh %d, bdiropq %d, gen %d, tmp %d\n", - dinfo->di_bstart, dinfo->di_bend, + dpri("d-1: btop %d, bbot %d, bwh %d, bdiropq %d, gen %d, tmp %d\n", + dinfo->di_btop, dinfo->di_bbot, dinfo->di_bwh, dinfo->di_bdiropq, au_digen(dentry), dinfo->di_tmpfile); - if (dinfo->di_bstart < 0) + if (dinfo->di_btop < 0) return; hdp = dinfo->di_hdentry; - for (bindex = dinfo->di_bstart; bindex <= dinfo->di_bend; bindex++) + for (bindex = dinfo->di_btop; bindex <= dinfo->di_bbot; bindex++) do_pri_dentry(bindex, hdp[0 + bindex].hd_dentry); } @@ -284,10 +287,10 @@ static int do_pri_br(aufs_bindex_t bindex, struct au_branch *br) if (!sb || IS_ERR(sb)) goto out; - dpri("s%d: {perm 0x%x, id %d, cnt %d, wbr %p}, " + dpri("s%d: {perm 0x%x, id %d, cnt %lld, wbr %p}, " "%s, dev 0x%02x%02x, flags 0x%lx, cnt %d, active %d, " "xino %d\n", - bindex, br->br_perm, br->br_id, atomic_read(&br->br_count), + bindex, br->br_perm, br->br_id, au_br_count(br), br->br_wbr, au_sbtype(sb), MAJOR(sb->s_dev), MINOR(sb->s_dev), sb->s_flags, sb->s_count, atomic_read(&sb->s_active), !!br->br_xino.xi_file); @@ -318,9 +321,9 @@ void au_dpri_sb(struct super_block *sb) a->mnt.mnt_sb = sb; a->fake.br_path.mnt = &a->mnt; - atomic_set(&a->fake.br_count, 0); - smp_mb(); /* atomic_set */ + au_br_count_init(&a->fake); err = do_pri_br(-1, &a->fake); + au_br_count_fin(&a->fake); kfree(a); dpri("dev 0x%x\n", sb->s_dev); if (err || !au_test_aufs(sb)) @@ -329,10 +332,11 @@ void au_dpri_sb(struct super_block *sb) sbinfo = au_sbi(sb); if (!sbinfo) return; - dpri("nw %d, gen %u, kobj %d\n", - atomic_read(&sbinfo->si_nowait.nw_len), sbinfo->si_generation, + dpri("nw %lld, gen %u, kobj %d\n", + percpu_counter_sum(&sbinfo->si_nowait.nw_len), + sbinfo->si_generation, atomic_read(&sbinfo->si_kobj.kref.refcount)); - for (bindex = 0; bindex <= sbinfo->si_bend; bindex++) + for (bindex = 0; bindex <= sbinfo->si_bbot; bindex++) do_pri_br(bindex, sbinfo->si_branch[0 + bindex]); } @@ -342,21 +346,21 @@ void __au_dbg_verify_dinode(struct dentry *dentry, const char *func, int line) { struct inode *h_inode, *inode = d_inode(dentry); struct dentry *h_dentry; - aufs_bindex_t bindex, bend, bi; + aufs_bindex_t bindex, bbot, bi; if (!inode /* || au_di(dentry)->di_lsc == AuLsc_DI_TMP */) return; - bend = au_dbend(dentry); - bi = au_ibend(inode); - if (bi < bend) - bend = bi; - bindex = au_dbstart(dentry); - bi = au_ibstart(inode); + bbot = au_dbbot(dentry); + bi = au_ibbot(inode); + if (bi < bbot) + bbot = bi; + bindex = au_dbtop(dentry); + bi = au_ibtop(inode); if (bi > bindex) bindex = bi; - for (; bindex <= bend; bindex++) { + for (; bindex <= bbot; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) continue; diff --git a/fs/aufs/dentry.c b/fs/aufs/dentry.c index e65fadd05..ce2a13632 100644 --- a/fs/aufs/dentry.c +++ b/fs/aufs/dentry.c @@ -52,7 +52,7 @@ au_do_lookup(struct dentry *h_parent, struct dentry *dentry, goto out; /* We found a whiteout */ - /* au_set_dbend(dentry, bindex); */ + /* au_set_dbbot(dentry, bindex); */ au_set_dbwh(dentry, bindex); if (!allow_neg) return NULL; /* success */ @@ -77,10 +77,10 @@ real_lookup: || (args->type && args->type != (h_inode->i_mode & S_IFMT))) goto out_neg; - if (au_dbend(dentry) <= bindex) - au_set_dbend(dentry, bindex); - if (au_dbstart(dentry) < 0 || bindex < au_dbstart(dentry)) - au_set_dbstart(dentry, bindex); + if (au_dbbot(dentry) <= bindex) + au_set_dbbot(dentry, bindex); + if (au_dbtop(dentry) < 0 || bindex < au_dbtop(dentry)) + au_set_dbtop(dentry, bindex); au_set_h_dptr(dentry, bindex, h_dentry); if (!d_is_dir(h_dentry) @@ -119,7 +119,7 @@ static int au_test_shwh(struct super_block *sb, const struct qstr *name) * otherwise an error. * can be called at unlinking with @type is zero. */ -int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type) +int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t btop, mode_t type) { int npositive, err; aufs_bindex_t bindex, btail, bdiropq; @@ -150,7 +150,7 @@ int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type) npositive = 0; parent = dget_parent(dentry); btail = au_dbtaildir(parent); - for (bindex = bstart; bindex <= btail; bindex++) { + for (bindex = btop; bindex <= btail; bindex++) { struct dentry *h_parent, *h_dentry; struct inode *h_inode, *h_dir; @@ -201,11 +201,11 @@ int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type) if (npositive) { AuLabel(positive); - au_update_dbstart(dentry); + au_update_dbtop(dentry); } err = npositive; if (unlikely(!au_opt_test(au_mntflags(sb), UDBA_NONE) - && au_dbstart(dentry) < 0)) { + && au_dbtop(dentry) < 0)) { err = -EIO; AuIOErr("both of real entry and whiteout found, %pd, err %d\n", dentry, err); @@ -267,10 +267,10 @@ int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex, int wh) } err = 0; - if (bindex < au_dbstart(dentry)) - au_set_dbstart(dentry, bindex); - if (au_dbend(dentry) < bindex) - au_set_dbend(dentry, bindex); + if (bindex < au_dbtop(dentry)) + au_set_dbtop(dentry, bindex); + if (au_dbbot(dentry) < bindex) + au_set_dbbot(dentry, bindex); au_set_h_dptr(dentry, bindex, h_dentry); out: @@ -382,7 +382,7 @@ int au_h_verify(struct dentry *h_dentry, unsigned int udba, struct inode *h_dir, static int au_do_refresh_hdentry(struct dentry *dentry, struct dentry *parent) { int err; - aufs_bindex_t new_bindex, bindex, bend, bwh, bdiropq; + aufs_bindex_t new_bindex, bindex, bbot, bwh, bdiropq; struct au_hdentry tmp, *p, *q; struct au_dinfo *dinfo; struct super_block *sb; @@ -391,11 +391,11 @@ static int au_do_refresh_hdentry(struct dentry *dentry, struct dentry *parent) sb = dentry->d_sb; dinfo = au_di(dentry); - bend = dinfo->di_bend; + bbot = dinfo->di_bbot; bwh = dinfo->di_bwh; bdiropq = dinfo->di_bdiropq; - p = dinfo->di_hdentry + dinfo->di_bstart; - for (bindex = dinfo->di_bstart; bindex <= bend; bindex++, p++) { + p = dinfo->di_hdentry + dinfo->di_btop; + for (bindex = dinfo->di_btop; bindex <= bbot; bindex++, p++) { if (!p->hd_dentry) continue; @@ -425,31 +425,31 @@ static int au_do_refresh_hdentry(struct dentry *dentry, struct dentry *parent) } dinfo->di_bwh = -1; - if (bwh >= 0 && bwh <= au_sbend(sb) && au_sbr_whable(sb, bwh)) + if (bwh >= 0 && bwh <= au_sbbot(sb) && au_sbr_whable(sb, bwh)) dinfo->di_bwh = bwh; dinfo->di_bdiropq = -1; if (bdiropq >= 0 - && bdiropq <= au_sbend(sb) + && bdiropq <= au_sbbot(sb) && au_sbr_whable(sb, bdiropq)) dinfo->di_bdiropq = bdiropq; err = -EIO; - dinfo->di_bstart = -1; - dinfo->di_bend = -1; - bend = au_dbend(parent); + dinfo->di_btop = -1; + dinfo->di_bbot = -1; + bbot = au_dbbot(parent); p = dinfo->di_hdentry; - for (bindex = 0; bindex <= bend; bindex++, p++) + for (bindex = 0; bindex <= bbot; bindex++, p++) if (p->hd_dentry) { - dinfo->di_bstart = bindex; + dinfo->di_btop = bindex; break; } - if (dinfo->di_bstart >= 0) { - p = dinfo->di_hdentry + bend; - for (bindex = bend; bindex >= 0; bindex--, p--) + if (dinfo->di_btop >= 0) { + p = dinfo->di_hdentry + bbot; + for (bindex = bbot; bindex >= 0; bindex--, p--) if (p->hd_dentry) { - dinfo->di_bend = bindex; + dinfo->di_bbot = bindex; err = 0; break; } @@ -549,7 +549,7 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, struct au_dinfo *tmp) { int err; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct { struct dentry *dentry; struct inode *inode; @@ -562,16 +562,16 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, struct dentry *h_dentry; err = 0; - AuDebugOn(dinfo->di_bstart < 0); + AuDebugOn(dinfo->di_btop < 0); orig_h.mode = 0; - orig_h.dentry = dinfo->di_hdentry[dinfo->di_bstart].hd_dentry; + orig_h.dentry = dinfo->di_hdentry[dinfo->di_btop].hd_dentry; orig_h.inode = NULL; if (d_is_positive(orig_h.dentry)) { orig_h.inode = d_inode(orig_h.dentry); orig_h.mode = orig_h.inode->i_mode & S_IFMT; } - if (tmp->di_bstart >= 0) { - tmp_h.dentry = tmp->di_hdentry[tmp->di_bstart].hd_dentry; + if (tmp->di_btop >= 0) { + tmp_h.dentry = tmp->di_hdentry[tmp->di_btop].hd_dentry; if (d_is_positive(tmp_h.dentry)) { tmp_h.inode = d_inode(tmp_h.dentry); tmp_h.mode = tmp_h.inode->i_mode & S_IFMT; @@ -588,20 +588,20 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, goto out; } AuDebugOn(inode); - AuDebugOn(dinfo->di_bstart != dinfo->di_bend); + AuDebugOn(dinfo->di_btop != dinfo->di_bbot); AuDebugOn(dinfo->di_bdiropq != -1); if (!tmp_h.inode) { AuDbg("negative --> negative\n"); /* should have only one negative lower */ - if (tmp->di_bstart >= 0 - && tmp->di_bstart < dinfo->di_bstart) { - AuDebugOn(tmp->di_bstart != tmp->di_bend); - AuDebugOn(dinfo->di_bstart != dinfo->di_bend); - au_set_h_dptr(dentry, dinfo->di_bstart, NULL); + if (tmp->di_btop >= 0 + && tmp->di_btop < dinfo->di_btop) { + AuDebugOn(tmp->di_btop != tmp->di_bbot); + AuDebugOn(dinfo->di_btop != dinfo->di_bbot); + au_set_h_dptr(dentry, dinfo->di_btop, NULL); au_di_cp(dinfo, tmp); - hd = tmp->di_hdentry + tmp->di_bstart; - au_set_h_dptr(dentry, tmp->di_bstart, + hd = tmp->di_hdentry + tmp->di_btop; + au_set_h_dptr(dentry, tmp->di_btop, dget(hd->hd_dentry)); } au_dbg_verify_dinode(dentry); @@ -626,7 +626,7 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, AuDbg("positive --> negative\n"); /* or bypassing aufs */ au_hide(dentry); - if (tmp->di_bwh >= 0 && tmp->di_bwh <= dinfo->di_bstart) + if (tmp->di_bwh >= 0 && tmp->di_bwh <= dinfo->di_btop) dinfo->di_bwh = tmp->di_bwh; if (inode) err = au_refresh_hinode_self(inode); @@ -634,7 +634,7 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, } else if (orig_h.mode == tmp_h.mode) { AuDbg("positive --> positive, same type\n"); if (!S_ISDIR(orig_h.mode) - && dinfo->di_bstart > tmp->di_bstart) { + && dinfo->di_btop > tmp->di_btop) { /* * similar to the behaviour of removing and * creating. @@ -645,15 +645,15 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo, au_dbg_verify_dinode(dentry); } else { /* fill empty slots */ - if (dinfo->di_bstart > tmp->di_bstart) - dinfo->di_bstart = tmp->di_bstart; - if (dinfo->di_bend < tmp->di_bend) - dinfo->di_bend = tmp->di_bend; + if (dinfo->di_btop > tmp->di_btop) + dinfo->di_btop = tmp->di_btop; + if (dinfo->di_bbot < tmp->di_bbot) + dinfo->di_bbot = tmp->di_bbot; dinfo->di_bwh = tmp->di_bwh; dinfo->di_bdiropq = tmp->di_bdiropq; hd = tmp->di_hdentry; - bend = dinfo->di_bend; - for (bindex = tmp->di_bstart; bindex <= bend; + bbot = dinfo->di_bbot; + for (bindex = tmp->di_btop; bindex <= bbot; bindex++) { if (au_h_dptr(dentry, bindex)) continue; @@ -726,7 +726,7 @@ int au_refresh_dentry(struct dentry *dentry, struct dentry *parent) goto out; dinfo = au_di(dentry); - err = au_di_realloc(dinfo, au_sbend(sb) + 1); + err = au_di_realloc(dinfo, au_sbbot(sb) + 1); if (unlikely(err)) goto out; ebrange = au_dbrange_test(dentry); @@ -734,7 +734,7 @@ int au_refresh_dentry(struct dentry *dentry, struct dentry *parent) ebrange = au_do_refresh_hdentry(dentry, parent); if (d_unhashed(dentry) || ebrange /* || dinfo->di_tmpfile */) { - AuDebugOn(au_dbstart(dentry) < 0 && au_dbend(dentry) >= 0); + AuDebugOn(au_dbtop(dentry) < 0 && au_dbbot(dentry) >= 0); if (d_really_is_positive(dentry)) { inode = d_inode(dentry); err = au_refresh_hinode_self(inode); @@ -757,7 +757,7 @@ int au_refresh_dentry(struct dentry *dentry, struct dentry *parent) * if current working dir is removed, it returns an error. * but the dentry is legal. */ - err = au_lkup_dentry(dentry, /*bstart*/0, /*type*/0); + err = au_lkup_dentry(dentry, /*btop*/0, /*type*/0); AuDbgDentry(dentry); au_di_swap(tmp, dinfo); if (err == -ENOENT) @@ -820,7 +820,7 @@ static int h_d_revalidate(struct dentry *dentry, struct inode *inode, { int err; umode_t mode, h_mode; - aufs_bindex_t bindex, btail, bstart, ibs, ibe; + aufs_bindex_t bindex, btail, btop, ibs, ibe; unsigned char plus, unhashed, is_root, h_plus, h_nfs, tmpfile; struct inode *h_inode, *h_cached_inode; struct dentry *h_dentry; @@ -846,15 +846,15 @@ static int h_d_revalidate(struct dentry *dentry, struct inode *inode, if (do_udba && inode) { mode = (inode->i_mode & S_IFMT); plus = (inode->i_nlink > 0); - ibs = au_ibstart(inode); - ibe = au_ibend(inode); + ibs = au_ibtop(inode); + ibe = au_ibbot(inode); } - bstart = au_dbstart(dentry); - btail = bstart; + btop = au_dbtop(dentry); + btail = btop; if (inode && S_ISDIR(inode->i_mode)) btail = au_dbtaildir(dentry); - for (bindex = bstart; bindex <= btail; bindex++) { + for (bindex = btop; bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) continue; @@ -1069,11 +1069,11 @@ static int aufs_d_revalidate(struct dentry *dentry, unsigned int flags) do_udba = !au_opt_test(au_mntflags(sb), UDBA_NONE); if (do_udba && inode) { - aufs_bindex_t bstart = au_ibstart(inode); + aufs_bindex_t btop = au_ibtop(inode); struct inode *h_inode; - if (bstart >= 0) { - h_inode = au_h_iptr(inode, bstart); + if (btop >= 0) { + h_inode = au_h_iptr(inode, btop); if (h_inode && au_test_higen(inode, h_inode)) { AuTraceErr(err); goto out_inval; @@ -1082,7 +1082,7 @@ static int aufs_d_revalidate(struct dentry *dentry, unsigned int flags) } err = h_d_revalidate(dentry, inode, flags, do_udba); - if (unlikely(!err && do_udba && au_dbstart(dentry) < 0)) { + if (unlikely(!err && do_udba && au_dbtop(dentry) < 0)) { err = -EIO; AuDbg("both of real entry and whiteout found, %p, err %d\n", dentry, err); diff --git a/fs/aufs/dentry.h b/fs/aufs/dentry.h index c794adf59..3e48b5cde 100644 --- a/fs/aufs/dentry.h +++ b/fs/aufs/dentry.h @@ -23,7 +23,7 @@ struct au_dinfo { atomic_t di_generation; struct au_rwsem di_rwsem; - aufs_bindex_t di_bstart, di_bend, di_bwh, di_bdiropq; + aufs_bindex_t di_btop, di_bbot, di_bwh, di_bdiropq; unsigned char di_tmpfile; /* to allow the different name */ struct au_hdentry *di_hdentry; } ____cacheline_aligned_in_smp; @@ -37,7 +37,7 @@ struct dentry *au_sio_lkup_one(struct qstr *name, struct dentry *parent); int au_h_verify(struct dentry *h_dentry, unsigned int udba, struct inode *h_dir, struct dentry *h_parent, struct au_branch *br); -int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type); +int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t btop, mode_t type); int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex, int wh); int au_refresh_dentry(struct dentry *dentry, struct dentry *parent); int au_reval_dpath(struct dentry *dentry, unsigned int sigen); @@ -73,8 +73,8 @@ int au_digen_test(struct dentry *dentry, unsigned int sigen); int au_dbrange_test(struct dentry *dentry); void au_update_digen(struct dentry *dentry); void au_update_dbrange(struct dentry *dentry, int do_put_zero); -void au_update_dbstart(struct dentry *dentry); -void au_update_dbend(struct dentry *dentry); +void au_update_dbtop(struct dentry *dentry); +void au_update_dbbot(struct dentry *dentry); int au_find_dbindex(struct dentry *dentry, struct dentry *h_dentry); /* ---------------------------------------------------------------------- */ @@ -151,16 +151,16 @@ static inline void au_hdput(struct au_hdentry *hd) dput(hd->hd_dentry); } -static inline aufs_bindex_t au_dbstart(struct dentry *dentry) +static inline aufs_bindex_t au_dbtop(struct dentry *dentry) { DiMustAnyLock(dentry); - return au_di(dentry)->di_bstart; + return au_di(dentry)->di_btop; } -static inline aufs_bindex_t au_dbend(struct dentry *dentry) +static inline aufs_bindex_t au_dbbot(struct dentry *dentry) { DiMustAnyLock(dentry); - return au_di(dentry)->di_bend; + return au_di(dentry)->di_bbot; } static inline aufs_bindex_t au_dbwh(struct dentry *dentry) @@ -176,22 +176,22 @@ static inline aufs_bindex_t au_dbdiropq(struct dentry *dentry) } /* todo: hard/soft set? */ -static inline void au_set_dbstart(struct dentry *dentry, aufs_bindex_t bindex) +static inline void au_set_dbtop(struct dentry *dentry, aufs_bindex_t bindex) { DiMustWriteLock(dentry); - au_di(dentry)->di_bstart = bindex; + au_di(dentry)->di_btop = bindex; } -static inline void au_set_dbend(struct dentry *dentry, aufs_bindex_t bindex) +static inline void au_set_dbbot(struct dentry *dentry, aufs_bindex_t bindex) { DiMustWriteLock(dentry); - au_di(dentry)->di_bend = bindex; + au_di(dentry)->di_bbot = bindex; } static inline void au_set_dbwh(struct dentry *dentry, aufs_bindex_t bindex) { DiMustWriteLock(dentry); - /* dbwh can be outside of bstart - bend range */ + /* dbwh can be outside of btop - bbot range */ au_di(dentry)->di_bwh = bindex; } diff --git a/fs/aufs/dinfo.c b/fs/aufs/dinfo.c index ad6d045c4..b2eb8c2de 100644 --- a/fs/aufs/dinfo.c +++ b/fs/aufs/dinfo.c @@ -11,10 +11,8 @@ void au_di_init_once(void *_dinfo) { struct au_dinfo *dinfo = _dinfo; - static struct lock_class_key aufs_di; au_rw_init(&dinfo->di_rwsem); - au_rw_class(&dinfo->di_rwsem, &aufs_di); } struct au_dinfo *au_di_alloc(struct super_block *sb, unsigned int lsc) @@ -26,14 +24,14 @@ struct au_dinfo *au_di_alloc(struct super_block *sb, unsigned int lsc) if (unlikely(!dinfo)) goto out; - nbr = au_sbend(sb) + 1; + nbr = au_sbbot(sb) + 1; if (nbr <= 0) nbr = 1; dinfo->di_hdentry = kcalloc(nbr, sizeof(*dinfo->di_hdentry), GFP_NOFS); if (dinfo->di_hdentry) { au_rw_write_lock_nested(&dinfo->di_rwsem, lsc); - dinfo->di_bstart = -1; - dinfo->di_bend = -1; + dinfo->di_btop = -1; + dinfo->di_bbot = -1; dinfo->di_bwh = -1; dinfo->di_bdiropq = -1; dinfo->di_tmpfile = 0; @@ -52,14 +50,14 @@ out: void au_di_free(struct au_dinfo *dinfo) { struct au_hdentry *p; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; /* dentry may not be revalidated */ - bindex = dinfo->di_bstart; + bindex = dinfo->di_btop; if (bindex >= 0) { - bend = dinfo->di_bend; + bbot = dinfo->di_bbot; p = dinfo->di_hdentry + bindex; - while (bindex++ <= bend) + while (bindex++ <= bbot) au_hdput(p++); } kfree(dinfo->di_hdentry); @@ -82,8 +80,8 @@ void au_di_swap(struct au_dinfo *a, struct au_dinfo *b) } while (0) DiSwap(p, hdentry); - DiSwap(bi, bstart); - DiSwap(bi, bend); + DiSwap(bi, btop); + DiSwap(bi, bbot); DiSwap(bi, bwh); DiSwap(bi, bdiropq); /* smp_mb(); */ @@ -96,8 +94,8 @@ void au_di_cp(struct au_dinfo *dst, struct au_dinfo *src) AuRwMustWriteLock(&dst->di_rwsem); AuRwMustWriteLock(&src->di_rwsem); - dst->di_bstart = src->di_bstart; - dst->di_bend = src->di_bend; + dst->di_btop = src->di_btop; + dst->di_bbot = src->di_bbot; dst->di_bwh = src->di_bwh; dst->di_bdiropq = src->di_bdiropq; /* smp_mb(); */ @@ -139,7 +137,7 @@ int au_di_realloc(struct au_dinfo *dinfo, int nbr) AuRwMustWriteLock(&dinfo->di_rwsem); err = -ENOMEM; - sz = sizeof(*hdp) * (dinfo->di_bend + 1); + sz = sizeof(*hdp) * (dinfo->di_bbot + 1); if (!sz) sz = sizeof(*hdp); hdp = au_kzrealloc(dinfo->di_hdentry, sz, sizeof(*hdp) * nbr, GFP_NOFS); @@ -307,7 +305,7 @@ struct dentry *au_h_dptr(struct dentry *dentry, aufs_bindex_t bindex) DiMustAnyLock(dentry); - if (au_dbstart(dentry) < 0 || bindex < au_dbstart(dentry)) + if (au_dbtop(dentry) < 0 || bindex < au_dbtop(dentry)) return NULL; AuDebugOn(bindex < 0); d = au_di(dentry)->di_hdentry[0 + bindex].hd_dentry; @@ -328,8 +326,8 @@ struct dentry *au_h_d_alias(struct dentry *dentry, aufs_bindex_t bindex) AuDebugOn(d_really_is_negative(dentry)); h_dentry = NULL; - if (au_dbstart(dentry) <= bindex - && bindex <= au_dbend(dentry)) + if (au_dbtop(dentry) <= bindex + && bindex <= au_dbbot(dentry)) h_dentry = au_h_dptr(dentry, bindex); if (h_dentry && !au_d_linkable(h_dentry)) { dget(h_dentry); @@ -337,8 +335,8 @@ struct dentry *au_h_d_alias(struct dentry *dentry, aufs_bindex_t bindex) } inode = d_inode(dentry); - AuDebugOn(bindex < au_ibstart(inode)); - AuDebugOn(au_ibend(inode) < bindex); + AuDebugOn(bindex < au_ibtop(inode)); + AuDebugOn(au_ibbot(inode) < bindex); h_inode = au_h_iptr(inode, bindex); h_dentry = d_find_alias(h_inode); if (h_dentry) { @@ -368,30 +366,30 @@ out: aufs_bindex_t au_dbtail(struct dentry *dentry) { - aufs_bindex_t bend, bwh; + aufs_bindex_t bbot, bwh; - bend = au_dbend(dentry); - if (0 <= bend) { + bbot = au_dbbot(dentry); + if (0 <= bbot) { bwh = au_dbwh(dentry); if (!bwh) return bwh; - if (0 < bwh && bwh < bend) + if (0 < bwh && bwh < bbot) return bwh - 1; } - return bend; + return bbot; } aufs_bindex_t au_dbtaildir(struct dentry *dentry) { - aufs_bindex_t bend, bopq; + aufs_bindex_t bbot, bopq; - bend = au_dbtail(dentry); - if (0 <= bend) { + bbot = au_dbtail(dentry); + if (0 <= bbot) { bopq = au_dbdiropq(dentry); - if (0 <= bopq && bopq < bend) - bend = bopq; + if (0 <= bopq && bopq < bbot) + bbot = bopq; } - return bend; + return bbot; } /* ---------------------------------------------------------------------- */ @@ -415,16 +413,16 @@ void au_set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex, int au_dbrange_test(struct dentry *dentry) { int err; - aufs_bindex_t bstart, bend; + aufs_bindex_t btop, bbot; err = 0; - bstart = au_dbstart(dentry); - bend = au_dbend(dentry); - if (bstart >= 0) - AuDebugOn(bend < 0 && bstart > bend); + btop = au_dbtop(dentry); + bbot = au_dbbot(dentry); + if (btop >= 0) + AuDebugOn(bbot < 0 && btop > bbot); else { err = -EIO; - AuDebugOn(bend >= 0); + AuDebugOn(bbot >= 0); } return err; @@ -457,68 +455,68 @@ void au_update_dbrange(struct dentry *dentry, int do_put_zero) DiMustWriteLock(dentry); dinfo = au_di(dentry); - if (!dinfo || dinfo->di_bstart < 0) + if (!dinfo || dinfo->di_btop < 0) return; hdp = dinfo->di_hdentry; if (do_put_zero) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; - bend = dinfo->di_bend; - for (bindex = dinfo->di_bstart; bindex <= bend; bindex++) { + bbot = dinfo->di_bbot; + for (bindex = dinfo->di_btop; bindex <= bbot; bindex++) { h_d = hdp[0 + bindex].hd_dentry; if (h_d && d_is_negative(h_d)) au_set_h_dptr(dentry, bindex, NULL); } } - dinfo->di_bstart = -1; - while (++dinfo->di_bstart <= dinfo->di_bend) - if (hdp[0 + dinfo->di_bstart].hd_dentry) + dinfo->di_btop = -1; + while (++dinfo->di_btop <= dinfo->di_bbot) + if (hdp[0 + dinfo->di_btop].hd_dentry) break; - if (dinfo->di_bstart > dinfo->di_bend) { - dinfo->di_bstart = -1; - dinfo->di_bend = -1; + if (dinfo->di_btop > dinfo->di_bbot) { + dinfo->di_btop = -1; + dinfo->di_bbot = -1; return; } - dinfo->di_bend++; - while (0 <= --dinfo->di_bend) - if (hdp[0 + dinfo->di_bend].hd_dentry) + dinfo->di_bbot++; + while (0 <= --dinfo->di_bbot) + if (hdp[0 + dinfo->di_bbot].hd_dentry) break; - AuDebugOn(dinfo->di_bstart > dinfo->di_bend || dinfo->di_bend < 0); + AuDebugOn(dinfo->di_btop > dinfo->di_bbot || dinfo->di_bbot < 0); } -void au_update_dbstart(struct dentry *dentry) +void au_update_dbtop(struct dentry *dentry) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct dentry *h_dentry; - bend = au_dbend(dentry); - for (bindex = au_dbstart(dentry); bindex <= bend; bindex++) { + bbot = au_dbbot(dentry); + for (bindex = au_dbtop(dentry); bindex <= bbot; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) continue; if (d_is_positive(h_dentry)) { - au_set_dbstart(dentry, bindex); + au_set_dbtop(dentry, bindex); return; } au_set_h_dptr(dentry, bindex, NULL); } } -void au_update_dbend(struct dentry *dentry) +void au_update_dbbot(struct dentry *dentry) { - aufs_bindex_t bindex, bstart; + aufs_bindex_t bindex, btop; struct dentry *h_dentry; - bstart = au_dbstart(dentry); - for (bindex = au_dbend(dentry); bindex >= bstart; bindex--) { + btop = au_dbtop(dentry); + for (bindex = au_dbbot(dentry); bindex >= btop; bindex--) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) continue; if (d_is_positive(h_dentry)) { - au_set_dbend(dentry, bindex); + au_set_dbbot(dentry, bindex); return; } au_set_h_dptr(dentry, bindex, NULL); @@ -527,10 +525,10 @@ void au_update_dbend(struct dentry *dentry) int au_find_dbindex(struct dentry *dentry, struct dentry *h_dentry) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; - bend = au_dbend(dentry); - for (bindex = au_dbstart(dentry); bindex <= bend; bindex++) + bbot = au_dbbot(dentry); + for (bindex = au_dbtop(dentry); bindex <= bbot; bindex++) if (au_h_dptr(dentry, bindex) == h_dentry) return bindex; return -1; diff --git a/fs/aufs/dir.c b/fs/aufs/dir.c index 4644de4a9..4dc666eb4 100644 --- a/fs/aufs/dir.c +++ b/fs/aufs/dir.c @@ -42,7 +42,7 @@ void au_sub_nlink(struct inode *dir, struct inode *h_dir) loff_t au_dir_size(struct file *file, struct dentry *dentry) { loff_t sz; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct file *h_file; struct dentry *h_dentry; @@ -50,9 +50,9 @@ loff_t au_dir_size(struct file *file, struct dentry *dentry) if (file) { AuDebugOn(!d_is_dir(file->f_path.dentry)); - bend = au_fbend_dir(file); - for (bindex = au_fbstart(file); - bindex <= bend && sz < KMALLOC_MAX_SIZE; + bbot = au_fbbot_dir(file); + for (bindex = au_fbtop(file); + bindex <= bbot && sz < KMALLOC_MAX_SIZE; bindex++) { h_file = au_hf_dir(file, bindex); if (h_file && file_inode(h_file)) @@ -62,9 +62,9 @@ loff_t au_dir_size(struct file *file, struct dentry *dentry) AuDebugOn(!dentry); AuDebugOn(!d_is_dir(dentry)); - bend = au_dbtaildir(dentry); - for (bindex = au_dbstart(dentry); - bindex <= bend && sz < KMALLOC_MAX_SIZE; + bbot = au_dbtaildir(dentry); + for (bindex = au_dbtop(dentry); + bindex <= bbot && sz < KMALLOC_MAX_SIZE; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (h_dentry && d_is_positive(h_dentry)) @@ -97,7 +97,7 @@ static void au_do_dir_ts(void *arg) struct au_branch *br; struct au_hinode *hdir; int err; - aufs_bindex_t bstart, bindex; + aufs_bindex_t btop, bindex; sb = a->dentry->d_sb; if (d_really_is_negative(a->dentry)) @@ -106,9 +106,9 @@ static void au_do_dir_ts(void *arg) aufs_read_lock(a->dentry, AuLock_DW); /* noflush */ dir = d_inode(a->dentry); - bstart = au_ibstart(dir); + btop = au_ibtop(dir); bindex = au_br_index(sb, a->brid); - if (bindex < bstart) + if (bindex < btop) goto out_unlock; br = au_sbr(sb, bindex); @@ -118,17 +118,17 @@ static void au_do_dir_ts(void *arg) h_path.mnt = au_br_mnt(br); au_dtime_store(&dt, a->dentry, &h_path); - br = au_sbr(sb, bstart); + br = au_sbr(sb, btop); if (!au_br_writable(br->br_perm)) goto out_unlock; - h_path.dentry = au_h_dptr(a->dentry, bstart); + h_path.dentry = au_h_dptr(a->dentry, btop); h_path.mnt = au_br_mnt(br); err = vfsub_mnt_want_write(h_path.mnt); if (err) goto out_unlock; - hdir = au_hi(dir, bstart); + hdir = au_hi(dir, btop); au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT); - h_dir = au_h_iptr(dir, bstart); + h_dir = au_h_iptr(dir, btop); if (h_dir->i_nlink && timespec_compare(&h_dir->i_mtime, &dt.dt_mtime) < 0) { dt.dt_h_path = h_path; @@ -149,7 +149,7 @@ out: void au_dir_ts(struct inode *dir, aufs_bindex_t bindex) { int perm, wkq_err; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct au_dir_ts_arg *arg; struct dentry *dentry; struct super_block *sb; @@ -159,13 +159,13 @@ void au_dir_ts(struct inode *dir, aufs_bindex_t bindex) dentry = d_find_any_alias(dir); AuDebugOn(!dentry); sb = dentry->d_sb; - bstart = au_ibstart(dir); - if (bstart == bindex) { + btop = au_ibtop(dir); + if (btop == bindex) { au_cpup_attr_timesizes(dir); goto out; } - perm = au_sbr_perm(sb, bstart); + perm = au_sbr_perm(sb, btop); if (!au_br_writable(perm)) goto out; @@ -192,24 +192,24 @@ static int reopen_dir(struct file *file) { int err; unsigned int flags; - aufs_bindex_t bindex, btail, bstart; + aufs_bindex_t bindex, btail, btop; struct dentry *dentry, *h_dentry; struct file *h_file; /* open all lower dirs */ dentry = file->f_path.dentry; - bstart = au_dbstart(dentry); - for (bindex = au_fbstart(file); bindex < bstart; bindex++) + btop = au_dbtop(dentry); + for (bindex = au_fbtop(file); bindex < btop; bindex++) au_set_h_fptr(file, bindex, NULL); - au_set_fbstart(file, bstart); + au_set_fbtop(file, btop); btail = au_dbtaildir(dentry); - for (bindex = au_fbend_dir(file); btail < bindex; bindex--) + for (bindex = au_fbbot_dir(file); btail < bindex; bindex--) au_set_h_fptr(file, bindex, NULL); - au_set_fbend_dir(file, btail); + au_set_fbbot_dir(file, btail); flags = vfsub_file_flags(file); - for (bindex = bstart; bindex <= btail; bindex++) { + for (bindex = btop; bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) continue; @@ -246,10 +246,10 @@ static int do_open_dir(struct file *file, int flags, struct file *h_file) mnt = file->f_path.mnt; dentry = file->f_path.dentry; file->f_version = d_inode(dentry)->i_version; - bindex = au_dbstart(dentry); - au_set_fbstart(file, bindex); + bindex = au_dbtop(dentry); + au_set_fbtop(file, bindex); btail = au_dbtaildir(dentry); - au_set_fbend_dir(file, btail); + au_set_fbbot_dir(file, btail); for (; !err && bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (!h_dentry) @@ -272,10 +272,10 @@ static int do_open_dir(struct file *file, int flags, struct file *h_file) return 0; /* success */ /* close all */ - for (bindex = au_fbstart(file); bindex <= btail; bindex++) + for (bindex = au_fbtop(file); bindex <= btail; bindex++) au_set_h_fptr(file, bindex, NULL); - au_set_fbstart(file, -1); - au_set_fbend_dir(file, -1); + au_set_fbtop(file, -1); + au_set_fbbot_dir(file, -1); return err; } @@ -310,7 +310,7 @@ static int aufs_release_dir(struct inode *inode __maybe_unused, struct au_vdir *vdir_cache; struct au_finfo *finfo; struct au_fidir *fidir; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; finfo = au_fi(file); fidir = finfo->fi_hdir; @@ -327,8 +327,8 @@ static int aufs_release_dir(struct inode *inode __maybe_unused, * calls fput() instead of filp_close(), * since no dnotify or lock for the lower file. */ - bend = fidir->fd_bbot; - for (; bindex <= bend; bindex++) + bbot = fidir->fd_bbot; + for (; bindex <= bbot; bindex++) au_set_h_fptr(file, bindex, NULL); } kfree(fidir); @@ -343,12 +343,12 @@ static int aufs_release_dir(struct inode *inode __maybe_unused, static int au_do_flush_dir(struct file *file, fl_owner_t id) { int err; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct file *h_file; err = 0; - bend = au_fbend_dir(file); - for (bindex = au_fbstart(file); !err && bindex <= bend; bindex++) { + bbot = au_fbbot_dir(file); + for (bindex = au_fbtop(file); !err && bindex <= bbot; bindex++) { h_file = au_hf_dir(file, bindex); if (h_file) err = vfsub_flush(h_file, id); @@ -366,7 +366,7 @@ static int aufs_flush_dir(struct file *file, fl_owner_t id) static int au_do_fsync_dir_no_file(struct dentry *dentry, int datasync) { int err; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct inode *inode; struct super_block *sb; @@ -374,8 +374,8 @@ static int au_do_fsync_dir_no_file(struct dentry *dentry, int datasync) sb = dentry->d_sb; inode = d_inode(dentry); IMustLock(inode); - bend = au_dbend(dentry); - for (bindex = au_dbstart(dentry); !err && bindex <= bend; bindex++) { + bbot = au_dbbot(dentry); + for (bindex = au_dbtop(dentry); !err && bindex <= bbot; bindex++) { struct path h_path; if (au_test_ro(sb, bindex, inode)) @@ -394,7 +394,7 @@ static int au_do_fsync_dir_no_file(struct dentry *dentry, int datasync) static int au_do_fsync_dir(struct file *file, int datasync) { int err; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct file *h_file; struct super_block *sb; struct inode *inode; @@ -405,8 +405,8 @@ static int au_do_fsync_dir(struct file *file, int datasync) inode = file_inode(file); sb = inode->i_sb; - bend = au_fbend_dir(file); - for (bindex = au_fbstart(file); !err && bindex <= bend; bindex++) { + bbot = au_fbbot_dir(file); + for (bindex = au_fbtop(file); !err && bindex <= bbot; bindex++) { h_file = au_hf_dir(file, bindex); if (!h_file || au_test_ro(sb, bindex, inode)) continue; @@ -478,7 +478,7 @@ static int aufs_iterate(struct file *file, struct dir_context *ctx) if (unlikely(err)) goto out_unlock; - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); if (!au_test_nfsd()) { err = au_vdir_fill_de(file, ctx); fsstack_copy_attr_atime(inode, h_inode); @@ -647,7 +647,7 @@ int au_test_empty_lower(struct dentry *dentry) { int err; unsigned int rdhash; - aufs_bindex_t bindex, bstart, btail; + aufs_bindex_t bindex, btop, btail; struct au_nhash whlist; struct test_empty_arg arg = { .ctx = { @@ -667,20 +667,20 @@ int au_test_empty_lower(struct dentry *dentry) arg.flags = 0; arg.whlist = &whlist; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); if (au_opt_test(au_mntflags(dentry->d_sb), SHWH)) au_fset_testempty(arg.flags, SHWH); test_empty = do_test_empty; if (au_opt_test(au_mntflags(dentry->d_sb), DIRPERM1)) test_empty = sio_test_empty; - arg.bindex = bstart; + arg.bindex = btop; err = test_empty(dentry, &arg); if (unlikely(err)) goto out_whlist; au_fset_testempty(arg.flags, WHONLY); btail = au_dbtaildir(dentry); - for (bindex = bstart + 1; !err && bindex <= btail; bindex++) { + for (bindex = btop + 1; !err && bindex <= btail; bindex++) { struct dentry *h_dentry; h_dentry = au_h_dptr(dentry, bindex); @@ -712,7 +712,7 @@ int au_test_empty(struct dentry *dentry, struct au_nhash *whlist) if (au_opt_test(au_mntflags(dentry->d_sb), SHWH)) au_fset_testempty(arg.flags, SHWH); btail = au_dbtaildir(dentry); - for (bindex = au_dbstart(dentry); !err && bindex <= btail; bindex++) { + for (bindex = au_dbtop(dentry); !err && bindex <= btail; bindex++) { struct dentry *h_dentry; h_dentry = au_h_dptr(dentry, bindex); diff --git a/fs/aufs/dynop.c b/fs/aufs/dynop.c index 53a8b55d8..dfb3a718d 100644 --- a/fs/aufs/dynop.c +++ b/fs/aufs/dynop.c @@ -308,14 +308,14 @@ out: int au_dy_irefresh(struct inode *inode) { int err; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct inode *h_inode; err = 0; if (S_ISREG(inode->i_mode)) { - bstart = au_ibstart(inode); - h_inode = au_h_iptr(inode, bstart); - err = au_dy_iaop(inode, bstart, h_inode); + btop = au_ibtop(inode); + h_inode = au_h_iptr(inode, btop); + err = au_dy_iaop(inode, btop, h_inode); } return err; } diff --git a/fs/aufs/export.c b/fs/aufs/export.c index 69b70f2a1..8755b1ef0 100644 --- a/fs/aufs/export.c +++ b/fs/aufs/export.c @@ -500,9 +500,11 @@ struct dentry *decode_by_path(struct super_block *sb, ino_t ino, __u32 *fh, h_mnt = au_br_mnt(br); h_sb = h_mnt->mnt_sb; /* todo: call lower fh_to_dentry()? fh_to_parent()? */ + lockdep_off(); h_parent = exportfs_decode_fh(h_mnt, (void *)(fh + Fh_tail), fh_len - Fh_tail, fh[Fh_h_type], h_acceptable, /*context*/NULL); + lockdep_on(); dentry = h_parent; if (unlikely(!h_parent || IS_ERR(h_parent))) { AuWarn1("%s decode_fh failed, %ld\n", @@ -606,7 +608,7 @@ aufs_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, /* is the parent dir cached? */ br = au_sbr(sb, nsi_lock.bindex); - atomic_inc(&br->br_count); + au_br_get(br); dentry = decode_by_dir_ino(sb, ino, dir_ino, &nsi_lock); if (IS_ERR(dentry)) goto out_unlock; @@ -630,7 +632,7 @@ accept: dentry = ERR_PTR(-ESTALE); out_unlock: if (br) - atomic_dec(&br->br_count); + au_br_put(br); si_read_unlock(sb); out: AuTraceErrPtr(dentry); @@ -697,7 +699,7 @@ static int aufs_encode_fh(struct inode *inode, __u32 *fh, int *max_len, err = -EIO; parent = NULL; ii_read_lock_child(inode); - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); if (!dir) { dentry = d_find_any_alias(inode); if (unlikely(!dentry)) @@ -772,7 +774,7 @@ static int aufs_commit_metadata(struct inode *inode) sb = inode->i_sb; si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW); ii_write_lock_child(inode); - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); AuDebugOn(bindex < 0); h_inode = au_h_iptr(inode, bindex); @@ -808,6 +810,11 @@ void au_export_init(struct super_block *sb) struct au_sbinfo *sbinfo; __u32 u; + BUILD_BUG_ON_MSG(IS_BUILTIN(CONFIG_AUFS_FS) + && IS_MODULE(CONFIG_EXPORTFS), + AUFS_NAME ": unsupported configuration " + "CONFIG_EXPORTFS=m and CONFIG_AUFS_FS=y"); + sb->s_export_op = &aufs_export_op; sbinfo = au_sbi(sb); sbinfo->si_xigen = NULL; diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c index ac1304a18..b0b0fff5f 100644 --- a/fs/aufs/f_op.c +++ b/fs/aufs/f_op.c @@ -28,7 +28,7 @@ int au_do_open_nondir(struct file *file, int flags, struct file *h_file) finfo = au_fi(file); memset(&finfo->fi_htop, 0, sizeof(finfo->fi_htop)); atomic_set(&finfo->fi_mmapped, 0); - bindex = au_dbstart(dentry); + bindex = au_dbtop(dentry); if (!h_file) { h_dentry = au_h_dptr(dentry, bindex); err = vfsub_test_mntns(file->f_path.mnt, h_dentry->d_sb); @@ -52,7 +52,7 @@ int au_do_open_nondir(struct file *file, int flags, struct file *h_file) h_inode->i_state |= I_LINKABLE; spin_unlock(&h_inode->i_lock); } - au_set_fbstart(file, bindex); + au_set_fbtop(file, bindex); au_set_h_fptr(file, bindex, h_file); au_update_figen(file); /* todo: necessary? */ @@ -154,7 +154,7 @@ static void au_read_post(struct inode *inode, struct file *h_file) struct au_write_pre { blkcnt_t blks; - aufs_bindex_t bstart; + aufs_bindex_t btop; }; /* @@ -187,7 +187,7 @@ static struct file *au_write_pre(struct file *file, int do_ready, di_downgrade_lock(dentry, /*flags*/0); if (wpre) - wpre->bstart = au_fbstart(file); + wpre->btop = au_fbtop(file); h_file = au_hf_top(file); get_file(h_file); if (wpre) @@ -208,7 +208,7 @@ static void au_write_post(struct inode *inode, struct file *h_file, struct inode *h_inode; au_cpup_attr_timesizes(inode); - AuDebugOn(au_ibstart(inode) != wpre->bstart); + AuDebugOn(au_ibtop(inode) != wpre->btop); h_inode = file_inode(h_file); inode->i_mode = h_inode->i_mode; ii_write_unlock(inode); @@ -216,7 +216,7 @@ static void au_write_post(struct inode *inode, struct file *h_file, /* AuDbg("blks %llu, %llu\n", (u64)blks, (u64)h_inode->i_blocks); */ if (written > 0) - au_fhsm_wrote(inode->i_sb, wpre->bstart, + au_fhsm_wrote(inode->i_sb, wpre->btop, /*force*/h_inode->i_blocks > wpre->blks); } diff --git a/fs/aufs/fhsm.c b/fs/aufs/fhsm.c index db079d6ee..e3cb6ed95 100644 --- a/fs/aufs/fhsm.c +++ b/fs/aufs/fhsm.c @@ -141,12 +141,12 @@ void au_fhsm_wrote(struct super_block *sb, aufs_bindex_t bindex, int force) void au_fhsm_wrote_all(struct super_block *sb, int force) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_branch *br; /* exclude the bottom */ - bend = au_fhsm_bottom(sb); - for (bindex = 0; bindex < bend; bindex++) { + bbot = au_fhsm_bottom(sb); + for (bindex = 0; bindex < bbot; bindex++) { br = au_sbr(sb, bindex); if (au_br_fhsm(br->br_perm)) au_fhsm_wrote(sb, bindex, force); @@ -192,15 +192,15 @@ static ssize_t au_fhsm_do_read(struct super_block *sb, { ssize_t err; int nstbr; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_branch *br; struct au_br_fhsm *bf; /* except the bottom branch */ err = 0; nstbr = 0; - bend = au_fhsm_bottom(sb); - for (bindex = 0; !err && bindex < bend; bindex++) { + bbot = au_fhsm_bottom(sb); + for (bindex = 0; !err && bindex < bbot; bindex++) { br = au_sbr(sb, bindex); if (!au_br_fhsm(br->br_perm)) continue; @@ -231,7 +231,7 @@ static ssize_t au_fhsm_read(struct file *file, char __user *buf, size_t count, { ssize_t err; int readable; - aufs_bindex_t nfhsm, bindex, bend; + aufs_bindex_t nfhsm, bindex, bbot; struct au_sbinfo *sbinfo; struct au_fhsm *fhsm; struct au_branch *br; @@ -262,8 +262,8 @@ need_data: AuDebugOn(!sb); /* exclude the bottom branch */ nfhsm = 0; - bend = au_fhsm_bottom(sb); - for (bindex = 0; bindex < bend; bindex++) { + bbot = au_fhsm_bottom(sb); + for (bindex = 0; bindex < bbot; bindex++) { br = au_sbr(sb, bindex); if (au_br_fhsm(br->br_perm)) nfhsm++; diff --git a/fs/aufs/file.c b/fs/aufs/file.c index 6b8a66b4a..27c5bf825 100644 --- a/fs/aufs/file.c +++ b/fs/aufs/file.c @@ -69,7 +69,7 @@ struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags, } } flags &= ~O_CREAT; - atomic_inc(&br->br_count); + au_br_get(br); h_path.dentry = h_dentry; h_path.mnt = au_br_mnt(br); h_file = vfsub_dentry_open(&h_path, flags); @@ -88,7 +88,7 @@ struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags, goto out; /* success */ out_br: - atomic_dec(&br->br_count); + au_br_put(br); out: return h_file; } @@ -122,7 +122,7 @@ static int au_cmoo(struct dentry *dentry) err = 0; if (IS_ROOT(dentry)) goto out; - cpg.bsrc = au_dbstart(dentry); + cpg.bsrc = au_dbtop(dentry); if (!cpg.bsrc) goto out; @@ -237,7 +237,7 @@ int au_do_open(struct file *file, struct au_do_open_args *args) if (!err) err = args->open(file, vfsub_file_flags(file), args->h_file); - if (!err && au_fbstart(file) != au_dbstart(dentry)) + if (!err && au_fbtop(file) != au_dbtop(dentry)) /* * cmoo happens after h_file was opened. * need to refresh file later. @@ -270,49 +270,49 @@ out: int au_reopen_nondir(struct file *file) { int err; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct dentry *dentry; struct file *h_file, *h_file_tmp; dentry = file->f_path.dentry; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); h_file_tmp = NULL; - if (au_fbstart(file) == bstart) { + if (au_fbtop(file) == btop) { h_file = au_hf_top(file); if (file->f_mode == h_file->f_mode) return 0; /* success */ h_file_tmp = h_file; get_file(h_file_tmp); - au_set_h_fptr(file, bstart, NULL); + au_set_h_fptr(file, btop, NULL); } AuDebugOn(au_fi(file)->fi_hdir); /* * it can happen * file exists on both of rw and ro - * open --> dbstart and fbstart are both 0 + * open --> dbtop and fbtop are both 0 * prepend a branch as rw, "rw" become ro * remove rw/file * delete the top branch, "rw" becomes rw again - * --> dbstart is 1, fbstart is still 0 - * write --> fbstart is 0 but dbstart is 1 + * --> dbtop is 1, fbtop is still 0 + * write --> fbtop is 0 but dbtop is 1 */ - /* AuDebugOn(au_fbstart(file) < bstart); */ + /* AuDebugOn(au_fbtop(file) < btop); */ - h_file = au_h_open(dentry, bstart, vfsub_file_flags(file) & ~O_TRUNC, + h_file = au_h_open(dentry, btop, vfsub_file_flags(file) & ~O_TRUNC, file, /*force_wr*/0); err = PTR_ERR(h_file); if (IS_ERR(h_file)) { if (h_file_tmp) { - atomic_inc(&au_sbr(dentry->d_sb, bstart)->br_count); - au_set_h_fptr(file, bstart, h_file_tmp); + au_sbr_get(dentry->d_sb, btop); + au_set_h_fptr(file, btop, h_file_tmp); h_file_tmp = NULL; } goto out; /* todo: close all? */ } err = 0; - au_set_fbstart(file, bstart); - au_set_h_fptr(file, bstart, h_file); + au_set_fbtop(file, btop); + au_set_h_fptr(file, btop, h_file); au_update_figen(file); /* todo: necessary? */ /* file->f_ra = h_file->f_ra; */ @@ -329,7 +329,7 @@ static int au_reopen_wh(struct file *file, aufs_bindex_t btgt, struct dentry *hi_wh) { int err; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct au_dinfo *dinfo; struct dentry *h_dentry; struct au_hdentry *hdp; @@ -337,14 +337,14 @@ static int au_reopen_wh(struct file *file, aufs_bindex_t btgt, dinfo = au_di(file->f_path.dentry); AuRwMustWriteLock(&dinfo->di_rwsem); - bstart = dinfo->di_bstart; - dinfo->di_bstart = btgt; + btop = dinfo->di_btop; + dinfo->di_btop = btgt; hdp = dinfo->di_hdentry; h_dentry = hdp[0 + btgt].hd_dentry; hdp[0 + btgt].hd_dentry = hi_wh; err = au_reopen_nondir(file); hdp[0 + btgt].hd_dentry = h_dentry; - dinfo->di_bstart = bstart; + dinfo->di_btop = btop; return err; } @@ -363,11 +363,11 @@ static int au_ready_to_write_wh(struct file *file, loff_t len, .pin = pin }; - au_update_dbstart(cpg.dentry); + au_update_dbtop(cpg.dentry); inode = d_inode(cpg.dentry); h_inode = NULL; - if (au_dbstart(cpg.dentry) <= bcpup - && au_dbend(cpg.dentry) >= bcpup) { + if (au_dbtop(cpg.dentry) <= bcpup + && au_dbbot(cpg.dentry) >= bcpup) { h_dentry = au_h_dptr(cpg.dentry, bcpup); if (h_dentry && d_is_positive(h_dentry)) h_inode = d_inode(h_dentry); @@ -394,7 +394,7 @@ static int au_ready_to_write_wh(struct file *file, loff_t len, int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin) { int err; - aufs_bindex_t dbstart; + aufs_bindex_t dbtop; struct dentry *parent; struct inode *inode; struct super_block *sb; @@ -410,7 +410,7 @@ int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin) sb = cpg.dentry->d_sb; inode = d_inode(cpg.dentry); - cpg.bsrc = au_fbstart(file); + cpg.bsrc = au_fbtop(file); err = au_test_ro(sb, cpg.bsrc, inode); if (!err && (au_hf_top(file)->f_mode & FMODE_WRITE)) { err = au_pin(pin, cpg.dentry, cpg.bsrc, AuOpt_UDBA_NONE, @@ -438,11 +438,11 @@ int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin) if (unlikely(err)) goto out_dgrade; - dbstart = au_dbstart(cpg.dentry); - if (dbstart <= cpg.bdst) + dbtop = au_dbtop(cpg.dentry); + if (dbtop <= cpg.bdst) cpg.bsrc = cpg.bdst; - if (dbstart <= cpg.bdst /* just reopen */ + if (dbtop <= cpg.bdst /* just reopen */ || !d_unhashed(cpg.dentry) /* copyup and reopen */ ) { h_file = au_h_open_pre(cpg.dentry, cpg.bsrc, /*force_wr*/0); @@ -450,7 +450,7 @@ int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin) err = PTR_ERR(h_file); else { di_downgrade_lock(parent, AuLock_IR); - if (dbstart > cpg.bdst) + if (dbtop > cpg.bdst) err = au_sio_cpup_simple(&cpg); if (!err) err = au_reopen_nondir(file); @@ -531,7 +531,7 @@ static int au_file_refresh_by_inode(struct file *file, int *need_reopen) finfo = au_fi(file); sb = cpg.dentry->d_sb; inode = d_inode(cpg.dentry); - cpg.bdst = au_ibstart(inode); + cpg.bdst = au_ibtop(inode); if (cpg.bdst == finfo->fi_btop || IS_ROOT(cpg.dentry)) goto out; @@ -552,7 +552,7 @@ static int au_file_refresh_by_inode(struct file *file, int *need_reopen) && au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(inode) && !d_unhashed(cpg.dentry) - && cpg.bdst < au_dbstart(cpg.dentry)) { + && cpg.bdst < au_dbtop(cpg.dentry)) { err = au_test_and_cpup_dirs(cpg.dentry, cpg.bdst); if (unlikely(err)) goto out_unlock; @@ -580,7 +580,7 @@ out: static void au_do_refresh_dir(struct file *file) { - aufs_bindex_t bindex, bend, new_bindex, brid; + aufs_bindex_t bindex, bbot, new_bindex, brid; struct au_hfile *p, tmp, *q; struct au_finfo *finfo; struct super_block *sb; @@ -594,8 +594,8 @@ static void au_do_refresh_dir(struct file *file) AuDebugOn(!fidir); p = fidir->fd_hfile + finfo->fi_btop; brid = p->hf_br->br_id; - bend = fidir->fd_bbot; - for (bindex = finfo->fi_btop; bindex <= bend; bindex++, p++) { + bbot = fidir->fd_bbot; + for (bindex = finfo->fi_btop; bindex <= bbot; bindex++, p++) { if (!p->hf_file) continue; @@ -620,8 +620,8 @@ static void au_do_refresh_dir(struct file *file) p = fidir->fd_hfile; if (!au_test_mmapped(file) && !d_unlinked(file->f_path.dentry)) { - bend = au_sbend(sb); - for (finfo->fi_btop = 0; finfo->fi_btop <= bend; + bbot = au_sbbot(sb); + for (finfo->fi_btop = 0; finfo->fi_btop <= bbot; finfo->fi_btop++, p++) if (p->hf_file) { if (file_inode(p->hf_file)) @@ -629,16 +629,16 @@ static void au_do_refresh_dir(struct file *file) au_hfput(p, file); } } else { - bend = au_br_index(sb, brid); - for (finfo->fi_btop = 0; finfo->fi_btop < bend; + bbot = au_br_index(sb, brid); + for (finfo->fi_btop = 0; finfo->fi_btop < bbot; finfo->fi_btop++, p++) if (p->hf_file) au_hfput(p, file); - bend = au_sbend(sb); + bbot = au_sbbot(sb); } - p = fidir->fd_hfile + bend; - for (fidir->fd_bbot = bend; fidir->fd_bbot >= finfo->fi_btop; + p = fidir->fd_hfile + bbot; + for (fidir->fd_bbot = bbot; fidir->fd_bbot >= finfo->fi_btop; fidir->fd_bbot--, p--) if (p->hf_file) { if (file_inode(p->hf_file)) @@ -654,7 +654,7 @@ static void au_do_refresh_dir(struct file *file) static int refresh_file(struct file *file, int (*reopen)(struct file *file)) { int err, need_reopen; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct dentry *dentry; struct au_finfo *finfo; struct au_hfile *hfile; @@ -667,9 +667,9 @@ static int refresh_file(struct file *file, int (*reopen)(struct file *file)) bindex = au_br_index(dentry->d_sb, hfile->hf_br->br_id); AuDebugOn(bindex < 0); if (bindex != finfo->fi_btop) - au_set_fbstart(file, bindex); + au_set_fbtop(file, bindex); } else { - err = au_fidir_realloc(finfo, au_sbend(dentry->d_sb) + 1); + err = au_fidir_realloc(finfo, au_sbbot(dentry->d_sb) + 1); if (unlikely(err)) goto out; au_do_refresh_dir(file); @@ -688,8 +688,8 @@ static int refresh_file(struct file *file, int (*reopen)(struct file *file)) /* error, close all lower files */ if (finfo->fi_hdir) { - bend = au_fbend_dir(file); - for (bindex = au_fbstart(file); bindex <= bend; bindex++) + bbot = au_fbbot_dir(file); + for (bindex = au_fbtop(file); bindex <= bbot; bindex++) au_set_h_fptr(file, bindex, NULL); } @@ -703,7 +703,7 @@ int au_reval_and_lock_fdi(struct file *file, int (*reopen)(struct file *file), { int err; unsigned int sigen, figen; - aufs_bindex_t bstart; + aufs_bindex_t btop; unsigned char pseudo_link; struct dentry *dentry; struct inode *inode; @@ -715,9 +715,9 @@ int au_reval_and_lock_fdi(struct file *file, int (*reopen)(struct file *file), fi_write_lock(file); figen = au_figen(file); di_write_lock_child(dentry); - bstart = au_dbstart(dentry); - pseudo_link = (bstart != au_ibstart(inode)); - if (sigen == figen && !pseudo_link && au_fbstart(file) == bstart) { + btop = au_dbtop(dentry); + pseudo_link = (btop != au_ibtop(inode)); + if (sigen == figen && !pseudo_link && au_fbtop(file) == btop) { if (!wlock) { di_downgrade_lock(dentry, AuLock_IR); fi_downgrade_lock(file); diff --git a/fs/aufs/file.h b/fs/aufs/file.h index 27d802487..96ab0a088 100644 --- a/fs/aufs/file.h +++ b/fs/aufs/file.h @@ -144,13 +144,13 @@ AuSimpleRwsemFuncs(fi, struct file *f, &au_fi(f)->fi_rwsem); /* ---------------------------------------------------------------------- */ /* todo: hard/soft set? */ -static inline aufs_bindex_t au_fbstart(struct file *file) +static inline aufs_bindex_t au_fbtop(struct file *file) { FiMustAnyLock(file); return au_fi(file)->fi_btop; } -static inline aufs_bindex_t au_fbend_dir(struct file *file) +static inline aufs_bindex_t au_fbbot_dir(struct file *file) { FiMustAnyLock(file); AuDebugOn(!au_fi(file)->fi_hdir); @@ -164,13 +164,13 @@ static inline struct au_vdir *au_fvdir_cache(struct file *file) return au_fi(file)->fi_hdir->fd_vdir_cache; } -static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex) +static inline void au_set_fbtop(struct file *file, aufs_bindex_t bindex) { FiMustWriteLock(file); au_fi(file)->fi_btop = bindex; } -static inline void au_set_fbend_dir(struct file *file, aufs_bindex_t bindex) +static inline void au_set_fbbot_dir(struct file *file, aufs_bindex_t bindex) { FiMustWriteLock(file); AuDebugOn(!au_fi(file)->fi_hdir); diff --git a/fs/aufs/finfo.c b/fs/aufs/finfo.c index b5eb55dfb..07f6eb32d 100644 --- a/fs/aufs/finfo.c +++ b/fs/aufs/finfo.c @@ -15,7 +15,7 @@ void au_hfput(struct au_hfile *hf, struct file *file) allow_write_access(hf->hf_file); fput(hf->hf_file); hf->hf_file = NULL; - atomic_dec(&hf->hf_br->br_count); + au_br_put(hf->hf_br); hf->hf_br = NULL; } @@ -55,7 +55,7 @@ struct au_fidir *au_fidir_alloc(struct super_block *sb) struct au_fidir *fidir; int nbr; - nbr = au_sbend(sb) + 1; + nbr = au_sbbot(sb) + 1; if (nbr < 2) nbr = 2; /* initial allocate for 2 branches */ fidir = kzalloc(au_fidir_sz(nbr), GFP_NOFS); @@ -105,10 +105,8 @@ void au_finfo_fin(struct file *file) void au_fi_init_once(void *_finfo) { struct au_finfo *finfo = _finfo; - static struct lock_class_key aufs_fi; au_rw_init(&finfo->fi_rwsem); - au_rw_class(&finfo->fi_rwsem, &aufs_fi); } int au_finfo_init(struct file *file, struct au_fidir *fidir) @@ -125,11 +123,6 @@ int au_finfo_init(struct file *file, struct au_fidir *fidir) err = 0; au_nfiles_inc(dentry->d_sb); - /* verbose coding for lock class name */ - if (!fidir) - au_rw_class(&finfo->fi_rwsem, au_lc_key + AuLcNonDir_FIINFO); - else - au_rw_class(&finfo->fi_rwsem, au_lc_key + AuLcDir_FIINFO); au_rw_write_lock(&finfo->fi_rwsem); finfo->fi_btop = -1; finfo->fi_hdir = fidir; diff --git a/fs/aufs/hfsnotify.c b/fs/aufs/hfsnotify.c index c0a1a63a9..07b4ecc53 100644 --- a/fs/aufs/hfsnotify.c +++ b/fs/aufs/hfsnotify.c @@ -50,8 +50,6 @@ static int au_hfsn_alloc(struct au_hinode *hinode) lockdep_off(); err = fsnotify_add_mark(mark, br->br_hfsn->hfsn_group, hinode->hi_inode, /*mnt*/NULL, /*allow_dups*/1); - /* even if err */ - fsnotify_put_mark(mark); lockdep_on(); return err; @@ -73,6 +71,7 @@ static int au_hfsn_free(struct au_hinode *hinode, struct au_hnotify *hn) spin_unlock(&mark->lock); lockdep_off(); fsnotify_destroy_mark(mark, group); + fsnotify_put_mark(mark); fsnotify_put_group(group); lockdep_on(); diff --git a/fs/aufs/hnotify.c b/fs/aufs/hnotify.c index 92e432b6a..3016c5e73 100644 --- a/fs/aufs/hnotify.c +++ b/fs/aufs/hnotify.c @@ -60,12 +60,12 @@ void au_hn_ctl(struct au_hinode *hinode, int do_set) void au_hn_reset(struct inode *inode, unsigned int flags) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct inode *hi; struct dentry *iwhdentry; - bend = au_ibend(inode); - for (bindex = au_ibstart(inode); bindex <= bend; bindex++) { + bbot = au_ibbot(inode); + for (bindex = au_ibtop(inode); bindex <= bbot; bindex++) { hi = au_h_iptr(inode, bindex); if (!hi) continue; @@ -89,7 +89,7 @@ void au_hn_reset(struct inode *inode, unsigned int flags) static int hn_xino(struct inode *inode, struct inode *h_inode) { int err; - aufs_bindex_t bindex, bend, bfound, bstart; + aufs_bindex_t bindex, bbot, bfound, btop; struct inode *h_i; err = 0; @@ -99,15 +99,15 @@ static int hn_xino(struct inode *inode, struct inode *h_inode) } bfound = -1; - bend = au_ibend(inode); - bstart = au_ibstart(inode); + bbot = au_ibbot(inode); + btop = au_ibtop(inode); #if 0 /* reserved for future use */ - if (bindex == bend) { + if (bindex == bbot) { /* keep this ino in rename case */ goto out; } #endif - for (bindex = bstart; bindex <= bend; bindex++) + for (bindex = btop; bindex <= bbot; bindex++) if (au_h_iptr(inode, bindex) == h_inode) { bfound = bindex; break; @@ -115,7 +115,7 @@ static int hn_xino(struct inode *inode, struct inode *h_inode) if (bfound < 0) goto out; - for (bindex = bstart; bindex <= bend; bindex++) { + for (bindex = btop; bindex <= bbot; bindex++) { h_i = au_h_iptr(inode, bindex); if (!h_i) continue; @@ -420,7 +420,7 @@ static void au_hn_bh(void *_args) { struct au_hnotify_args *a = _args; struct super_block *sb; - aufs_bindex_t bindex, bend, bfound; + aufs_bindex_t bindex, bbot, bfound; unsigned char xino, try_iput; int err; struct inode *inode; @@ -451,8 +451,8 @@ static void au_hn_bh(void *_args) ii_read_lock_parent(a->dir); bfound = -1; - bend = au_ibend(a->dir); - for (bindex = au_ibstart(a->dir); bindex <= bend; bindex++) + bbot = au_ibbot(a->dir); + for (bindex = au_ibtop(a->dir); bindex <= bbot; bindex++) if (au_h_iptr(a->dir, bindex) == a->h_dir) { bfound = bindex; break; diff --git a/fs/aufs/i_op.c b/fs/aufs/i_op.c index a70d5b050..1572a7d4d 100644 --- a/fs/aufs/i_op.c +++ b/fs/aufs/i_op.c @@ -74,7 +74,7 @@ out: static int aufs_permission(struct inode *inode, int mask) { int err; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; const unsigned char isdir = !!S_ISDIR(inode->i_mode), write_mask = !!(mask & (MAY_WRITE | MAY_APPEND)); struct inode *h_inode; @@ -98,14 +98,14 @@ static int aufs_permission(struct inode *inode, int mask) || write_mask || au_opt_test(au_mntflags(sb), DIRPERM1)) { err = au_busy_or_stale(); - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); if (unlikely(!h_inode || (h_inode->i_mode & S_IFMT) != (inode->i_mode & S_IFMT))) goto out; err = 0; - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); br = au_sbr(sb, bindex); err = h_permission(h_inode, mask, au_br_mnt(br), br->br_perm); if (write_mask @@ -124,8 +124,8 @@ static int aufs_permission(struct inode *inode, int mask) /* non-write to dir */ err = 0; - bend = au_ibend(inode); - for (bindex = au_ibstart(inode); !err && bindex <= bend; bindex++) { + bbot = au_ibbot(inode); + for (bindex = au_ibtop(inode); !err && bindex <= bbot; bindex++) { h_inode = au_h_iptr(inode, bindex); if (h_inode) { err = au_busy_or_stale(); @@ -184,7 +184,7 @@ static struct dentry *aufs_lookup(struct inode *dir, struct dentry *dentry, if (!err) err = au_digen_test(parent, au_sigen(sb)); if (!err) { - npositive = au_lkup_dentry(dentry, au_dbstart(parent), + npositive = au_lkup_dentry(dentry, au_dbtop(parent), /*type*/0); err = npositive; } @@ -226,18 +226,6 @@ static struct dentry *aufs_lookup(struct inode *dir, struct dentry *dentry, out_unlock: di_write_unlock(dentry); - if (inode) { - /* verbose coding for lock class name */ - if (unlikely(S_ISLNK(inode->i_mode))) - au_rw_class(&au_di(dentry)->di_rwsem, - au_lc_key + AuLcSymlink_DIINFO); - else if (unlikely(S_ISDIR(inode->i_mode))) - au_rw_class(&au_di(dentry)->di_rwsem, - au_lc_key + AuLcDir_DIINFO); - else /* likely */ - au_rw_class(&au_di(dentry)->di_rwsem, - au_lc_key + AuLcNonDir_DIINFO); - } out_si: si_read_unlock(sb); out: @@ -324,7 +312,7 @@ static int aufs_atomic_open(struct inode *dir, struct dentry *dentry, parent = dentry->d_parent; /* dir is locked */ di_write_lock_parent(parent); - err = au_lkup_dentry(dentry, /*bstart*/0, /*type*/0); + err = au_lkup_dentry(dentry, /*btop*/0, /*type*/0); if (unlikely(err)) goto out_unlock; @@ -391,7 +379,7 @@ out: static int au_wr_dir_cpup(struct dentry *dentry, struct dentry *parent, const unsigned char add_entry, aufs_bindex_t bcpup, - aufs_bindex_t bstart) + aufs_bindex_t btop) { int err; struct dentry *h_parent; @@ -404,9 +392,9 @@ static int au_wr_dir_cpup(struct dentry *dentry, struct dentry *parent, err = 0; if (!au_h_dptr(parent, bcpup)) { - if (bstart > bcpup) + if (btop > bcpup) err = au_cpup_dirs(dentry, bcpup); - else if (bstart < bcpup) + else if (btop < bcpup) err = au_cpdown_dirs(dentry, bcpup); else BUG(); @@ -422,7 +410,7 @@ static int au_wr_dir_cpup(struct dentry *dentry, struct dentry *parent, AuDbg("bcpup %d\n", bcpup); if (!err) { if (d_really_is_negative(dentry)) - au_set_h_dptr(dentry, bstart, NULL); + au_set_h_dptr(dentry, btop, NULL); au_update_dbrange(dentry, /*do_put_zero*/0); } } @@ -446,7 +434,7 @@ int au_wr_dir(struct dentry *dentry, struct dentry *src_dentry, { int err; unsigned int flags; - aufs_bindex_t bcpup, bstart, src_bstart; + aufs_bindex_t bcpup, btop, src_btop; const unsigned char add_entry = au_ftest_wrdir(args->flags, ADD_ENTRY) | au_ftest_wrdir(args->flags, TMPFILE); @@ -457,13 +445,13 @@ int au_wr_dir(struct dentry *dentry, struct dentry *src_dentry, sb = dentry->d_sb; sbinfo = au_sbi(sb); parent = dget_parent(dentry); - bstart = au_dbstart(dentry); - bcpup = bstart; + btop = au_dbtop(dentry); + bcpup = btop; if (args->force_btgt < 0) { if (src_dentry) { - src_bstart = au_dbstart(src_dentry); - if (src_bstart < bstart) - bcpup = src_bstart; + src_btop = au_dbtop(src_dentry); + if (src_btop < btop) + bcpup = src_btop; } else if (add_entry) { flags = 0; if (au_ftest_wrdir(args->flags, ISDIR)) @@ -492,18 +480,18 @@ int au_wr_dir(struct dentry *dentry, struct dentry *src_dentry, AuDebugOn(au_test_ro(sb, bcpup, d_inode(dentry))); } - AuDbg("bstart %d, bcpup %d\n", bstart, bcpup); + AuDbg("btop %d, bcpup %d\n", btop, bcpup); err = bcpup; - if (bcpup == bstart) + if (bcpup == btop) goto out; /* success */ /* copyup the new parent into the branch we process */ - err = au_wr_dir_cpup(dentry, parent, add_entry, bcpup, bstart); + err = au_wr_dir_cpup(dentry, parent, add_entry, bcpup, btop); if (err >= 0) { if (d_really_is_negative(dentry)) { - au_set_h_dptr(dentry, bstart, NULL); - au_set_dbstart(dentry, bcpup); - au_set_dbend(dentry, bcpup); + au_set_h_dptr(dentry, btop, NULL); + au_set_dbtop(dentry, bcpup); + au_set_dbbot(dentry, bcpup); } AuDebugOn(add_entry && !au_ftest_wrdir(args->flags, TMPFILE) @@ -645,7 +633,7 @@ int au_do_pin(struct au_pin *p) } p->h_dentry = NULL; - if (p->bindex <= au_dbend(p->dentry)) + if (p->bindex <= au_dbbot(p->dentry)) p->h_dentry = au_h_dptr(p->dentry, p->bindex); p->parent = dget_parent(p->dentry); @@ -761,7 +749,7 @@ int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia, { int err; loff_t sz; - aufs_bindex_t bstart, ibstart; + aufs_bindex_t btop, ibtop; struct dentry *hi_wh, *parent; struct inode *inode; struct au_wr_dir_args wr_dir_args = { @@ -772,16 +760,16 @@ int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia, if (d_is_dir(dentry)) au_fset_wrdir(wr_dir_args.flags, ISDIR); /* plink or hi_wh() case */ - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); inode = d_inode(dentry); - ibstart = au_ibstart(inode); - if (bstart != ibstart && !au_test_ro(inode->i_sb, ibstart, inode)) - wr_dir_args.force_btgt = ibstart; + ibtop = au_ibtop(inode); + if (btop != ibtop && !au_test_ro(inode->i_sb, ibtop, inode)) + wr_dir_args.force_btgt = ibtop; err = au_wr_dir(dentry, /*src_dentry*/NULL, &wr_dir_args); if (unlikely(err < 0)) goto out; a->btgt = err; - if (err != bstart) + if (err != btop) au_fset_icpup(a->flags, DID_CPUP); err = 0; @@ -797,8 +785,8 @@ int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia, if (unlikely(err)) goto out_parent; - a->h_path.dentry = au_h_dptr(dentry, bstart); sz = -1; + a->h_path.dentry = au_h_dptr(dentry, btop); a->h_inode = d_inode(a->h_path.dentry); if (ia && (ia->ia_valid & ATTR_SIZE)) { inode_lock_nested(a->h_inode, AuLsc_I_CHILD); @@ -839,7 +827,7 @@ int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia, struct au_cp_generic cpg = { .dentry = dentry, .bdst = a->btgt, - .bsrc = bstart, + .bsrc = btop, .len = sz, .pin = &a->pin, .flags = AuCpup_DTIME | AuCpup_HOPEN @@ -976,7 +964,7 @@ out_unlock: inode_unlock(a->h_inode); au_unpin(&a->pin); if (unlikely(err)) - au_update_dbstart(dentry); + au_update_dbtop(dentry); out_dentry: di_write_unlock(dentry); if (file) { @@ -1073,7 +1061,7 @@ ssize_t au_srxattr(struct dentry *dentry, struct au_srxattr *arg) au_unpin(&a->pin); if (unlikely(err)) - au_update_dbstart(dentry); + au_update_dbtop(dentry); out_di: di_write_unlock(dentry); @@ -1165,7 +1153,7 @@ int au_h_path_getattr(struct dentry *dentry, int force, struct path *h_path) di_read_lock_child(dentry, AuLock_IR); inode = d_inode(dentry); - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); h_path->mnt = au_sbr_mnt(sb, bindex); h_sb = h_path->mnt->mnt_sb; if (!force @@ -1173,7 +1161,7 @@ int au_h_path_getattr(struct dentry *dentry, int force, struct path *h_path) && udba_none) goto out; /* success */ - if (au_dbstart(dentry) == bindex) + if (au_dbtop(dentry) == bindex) h_path->dentry = au_h_dptr(dentry, bindex); else if (au_opt_test(mnt_flags, PLINK) && au_plink_test(inode)) { h_path->dentry = au_plink_lkup(inode, bindex); @@ -1258,14 +1246,14 @@ static const char *aufs_get_link(struct dentry *dentry, struct inode *inode, err = -EINVAL; inode = d_inode(dentry); - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); h_inode = au_h_iptr(inode, bindex); if (unlikely(!h_inode->i_op->get_link)) goto out_unlock; err = -EBUSY; h_dentry = NULL; - if (au_dbstart(dentry) <= bindex) { + if (au_dbtop(dentry) <= bindex) { h_dentry = au_h_dptr(dentry, bindex); if (h_dentry) dget(h_dentry); @@ -1311,7 +1299,7 @@ static int aufs_update_time(struct inode *inode, struct timespec *ts, int flags) si_read_lock(sb, AuLock_FLUSH); ii_write_lock_child(inode); lockdep_on(); - h_inode = au_h_iptr(inode, au_ibstart(inode)); + h_inode = au_h_iptr(inode, au_ibtop(inode)); err = vfsub_update_time(h_inode, ts, flags); lockdep_off(); if (!err) diff --git a/fs/aufs/i_op_add.c b/fs/aufs/i_op_add.c index 533b36a2a..8e3fb61e8 100644 --- a/fs/aufs/i_op_add.c +++ b/fs/aufs/i_op_add.c @@ -167,7 +167,7 @@ lock_hdir_lkup_wh(struct dentry *dentry, struct au_dtime *dt, h_parent = au_pinned_h_parent(pin); if (udba != AuOpt_UDBA_NONE - && au_dbstart(dentry) == bcpup) + && au_dbtop(dentry) == bcpup) err = au_may_add(dentry, bcpup, h_parent, au_ftest_wrdir(wr_dir_args->flags, ISDIR)); else if (unlikely(dentry->d_name.len > AUFS_MAX_NAMELEN)) @@ -229,7 +229,7 @@ static int add_simple(struct inode *dir, struct dentry *dentry, struct simple_arg *arg) { int err, rerr; - aufs_bindex_t bstart; + aufs_bindex_t btop; unsigned char created; const unsigned char try_aopen = (arg->type == Creat && arg->u.c.try_aopen); @@ -272,10 +272,10 @@ static int add_simple(struct inode *dir, struct dentry *dentry, if (IS_ERR(wh_dentry)) goto out_parent; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); sb = dentry->d_sb; - br = au_sbr(sb, bstart); - a->h_path.dentry = au_h_dptr(dentry, bstart); + br = au_sbr(sb, btop); + a->h_path.dentry = au_h_dptr(dentry, btop); a->h_path.mnt = au_br_mnt(br); h_dir = au_pinned_h_dir(&a->pin); switch (arg->type) { @@ -300,7 +300,7 @@ static int add_simple(struct inode *dir, struct dentry *dentry, } created = !err; if (!err) - err = epilog(dir, bstart, wh_dentry, dentry); + err = epilog(dir, btop, wh_dentry, dentry); /* revert */ if (unlikely(created && err && d_is_positive(a->h_path.dentry))) { @@ -326,7 +326,7 @@ out_parent: di_write_unlock(parent); out_unlock: if (unlikely(err)) { - au_update_dbstart(dentry); + au_update_dbtop(dentry); d_drop(dentry); } if (!try_aopen) @@ -423,9 +423,9 @@ int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) if (unlikely(err)) goto out_parent; - bindex = au_dbstart(parent); - au_set_dbstart(dentry, bindex); - au_set_dbend(dentry, bindex); + bindex = au_dbtop(parent); + au_set_dbtop(dentry, bindex); + au_set_dbbot(dentry, bindex); err = au_wr_dir(dentry, /*src_dentry*/NULL, &wr_dir_args); bindex = err; if (unlikely(err < 0)) @@ -455,15 +455,15 @@ int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) if (unlikely(err)) goto out_dentry; - au_set_dbstart(dentry, bindex); - au_set_dbend(dentry, bindex); + au_set_dbtop(dentry, bindex); + au_set_dbbot(dentry, bindex); au_set_h_dptr(dentry, bindex, dget(h_dentry)); inode = au_new_inode(dentry, /*must_new*/1); if (IS_ERR(inode)) { err = PTR_ERR(inode); au_set_h_dptr(dentry, bindex, NULL); - au_set_dbstart(dentry, -1); - au_set_dbend(dentry, -1); + au_set_dbtop(dentry, -1); + au_set_dbbot(dentry, -1); } else { if (!inode->i_nlink) set_nlink(inode, 1); @@ -471,7 +471,7 @@ int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) au_di(dentry)->di_tmpfile = 1; /* update without i_mutex */ - if (au_ibstart(dir) == au_dbstart(dentry)) + if (au_ibtop(dir) == au_dbtop(dentry)) au_cpup_attr_timesizes(dir); } @@ -483,15 +483,7 @@ out_parent: di_write_unlock(parent); dput(parent); di_write_unlock(dentry); - if (!err) -#if 0 - /* verbose coding for lock class name */ - au_rw_class(&au_di(dentry)->di_rwsem, - au_lc_key + AuLcNonDir_DIINFO); -#else - ; -#endif - else { + if (unlikely(err)) { au_di_fin(dentry); dentry->d_fsdata = NULL; } @@ -550,7 +542,7 @@ static int au_cpup_or_link(struct dentry *src_dentry, struct dentry *dentry, { int err; unsigned char plink; - aufs_bindex_t bend; + aufs_bindex_t bbot; struct dentry *h_src_dentry; struct inode *h_inode, *inode, *delegated; struct super_block *sb; @@ -560,13 +552,13 @@ static int au_cpup_or_link(struct dentry *src_dentry, struct dentry *dentry, h_inode = NULL; sb = src_dentry->d_sb; inode = d_inode(src_dentry); - if (au_ibstart(inode) <= a->bdst) + if (au_ibtop(inode) <= a->bdst) h_inode = au_h_iptr(inode, a->bdst); if (!h_inode || !h_inode->i_nlink) { /* copyup src_dentry as the name of dentry. */ - bend = au_dbend(dentry); - if (bend < a->bsrc) - au_set_dbend(dentry, a->bsrc); + bbot = au_dbbot(dentry); + if (bbot < a->bsrc) + au_set_dbbot(dentry, a->bsrc); au_set_h_dptr(dentry, a->bsrc, dget(au_h_dptr(src_dentry, a->bsrc))); dget(a->h_path.dentry); @@ -601,7 +593,7 @@ static int au_cpup_or_link(struct dentry *src_dentry, struct dentry *dentry, spin_unlock(&dentry->d_lock); AuDbg("temporary d_inode...done\n"); au_set_h_dptr(dentry, a->bsrc, NULL); - au_set_dbend(dentry, bend); + au_set_dbbot(dentry, bbot); } else { /* the inode of src_dentry already exists on a.bdst branch */ h_src_dentry = d_find_alias(h_inode); @@ -679,7 +671,7 @@ int aufs_link(struct dentry *src_dentry, struct inode *dir, goto out_unlock; a->src_parent = dget_parent(src_dentry); - wr_dir_args.force_btgt = au_ibstart(inode); + wr_dir_args.force_btgt = au_ibtop(inode); di_write_lock_parent(a->parent); wr_dir_args.force_btgt = au_wbr(dentry, wr_dir_args.force_btgt); @@ -691,15 +683,15 @@ int aufs_link(struct dentry *src_dentry, struct inode *dir, err = 0; sb = dentry->d_sb; - a->bdst = au_dbstart(dentry); + a->bdst = au_dbtop(dentry); a->h_path.dentry = au_h_dptr(dentry, a->bdst); a->h_path.mnt = au_sbr_mnt(sb, a->bdst); - a->bsrc = au_ibstart(inode); + a->bsrc = au_ibtop(inode); h_src_dentry = au_h_d_alias(src_dentry, a->bsrc); if (!h_src_dentry && au_di(src_dentry)->di_tmpfile) h_src_dentry = dget(au_hi_wh(inode, a->bsrc)); if (!h_src_dentry) { - a->bsrc = au_dbstart(src_dentry); + a->bsrc = au_dbtop(src_dentry); h_src_dentry = au_h_d_alias(src_dentry, a->bsrc); AuDebugOn(!h_src_dentry); } else if (IS_ERR(h_src_dentry)) { @@ -799,7 +791,7 @@ out_parent: dput(a->src_parent); out_unlock: if (unlikely(err)) { - au_update_dbstart(dentry); + au_update_dbtop(dentry); d_drop(dentry); } aufs_read_and_write_unlock2(dentry, src_dentry); @@ -851,7 +843,7 @@ int aufs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) goto out_parent; sb = dentry->d_sb; - bindex = au_dbstart(dentry); + bindex = au_dbtop(dentry); h_path.dentry = au_h_dptr(dentry, bindex); h_path.mnt = au_sbr_mnt(sb, bindex); err = vfsub_mkdir(au_pinned_h_dir(&a->pin), &h_path, mode); @@ -908,7 +900,7 @@ out_parent: di_write_unlock(parent); out_unlock: if (unlikely(err)) { - au_update_dbstart(dentry); + au_update_dbtop(dentry); d_drop(dentry); } aufs_read_unlock(dentry, AuLock_DW); diff --git a/fs/aufs/i_op_del.c b/fs/aufs/i_op_del.c index 68741aadb..bda70b008 100644 --- a/fs/aufs/i_op_del.c +++ b/fs/aufs/i_op_del.c @@ -21,25 +21,25 @@ int au_wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup) { int need_wh, err; - aufs_bindex_t bstart; + aufs_bindex_t btop; struct super_block *sb; sb = dentry->d_sb; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); if (*bcpup < 0) { - *bcpup = bstart; - if (au_test_ro(sb, bstart, d_inode(dentry))) { + *bcpup = btop; + if (au_test_ro(sb, btop, d_inode(dentry))) { err = AuWbrCopyup(au_sbi(sb), dentry); *bcpup = err; if (unlikely(err < 0)) goto out; } } else - AuDebugOn(bstart < *bcpup + AuDebugOn(btop < *bcpup || au_test_ro(sb, *bcpup, d_inode(dentry))); - AuDbg("bcpup %d, bstart %d\n", *bcpup, bstart); + AuDbg("bcpup %d, btop %d\n", *bcpup, btop); - if (*bcpup != bstart) { + if (*bcpup != btop) { err = au_cpup_dirs(dentry, *bcpup); if (unlikely(err)) goto out; @@ -54,7 +54,7 @@ int au_wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup) au_di_cp(tmp, dinfo); au_di_swap(tmp, dinfo); /* returns the number of positive dentries */ - need_wh = au_lkup_dentry(dentry, bstart + 1, /*type*/0); + need_wh = au_lkup_dentry(dentry, btop + 1, /*type*/0); au_di_swap(tmp, dinfo); au_rw_write_unlock(&tmp->di_rwsem); au_di_free(tmp); @@ -165,7 +165,7 @@ lock_hdir_create_wh(struct dentry *dentry, int isdir, aufs_bindex_t *rbcpup, h_path.dentry = au_pinned_h_parent(pin); if (udba != AuOpt_UDBA_NONE - && au_dbstart(dentry) == bcpup) { + && au_dbtop(dentry) == bcpup) { err = au_may_del(dentry, bcpup, h_path.dentry, isdir); wh_dentry = ERR_PTR(err); if (unlikely(err)) @@ -287,7 +287,7 @@ static int do_revert(int err, struct inode *dir, aufs_bindex_t bindex, int aufs_unlink(struct inode *dir, struct dentry *dentry) { int err; - aufs_bindex_t bwh, bindex, bstart; + aufs_bindex_t bwh, bindex, btop; struct inode *inode, *h_dir, *delegated; struct dentry *parent, *wh_dentry; /* to reuduce stack size */ @@ -316,7 +316,7 @@ int aufs_unlink(struct inode *dir, struct dentry *dentry) if (unlikely(d_is_dir(dentry))) goto out_unlock; /* possible? */ - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); bwh = au_dbwh(dentry); bindex = -1; parent = dentry->d_parent; /* dir inode is locked */ @@ -327,10 +327,10 @@ int aufs_unlink(struct inode *dir, struct dentry *dentry) if (IS_ERR(wh_dentry)) goto out_parent; - a->h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart); - a->h_path.dentry = au_h_dptr(dentry, bstart); + a->h_path.mnt = au_sbr_mnt(dentry->d_sb, btop); + a->h_path.dentry = au_h_dptr(dentry, btop); dget(a->h_path.dentry); - if (bindex == bstart) { + if (bindex == btop) { h_dir = au_pinned_h_dir(&a->pin); delegated = NULL; err = vfsub_unlink(h_dir, &a->h_path, &delegated, /*force*/0); @@ -351,7 +351,7 @@ int aufs_unlink(struct inode *dir, struct dentry *dentry) epilog(dir, dentry, bindex); /* update target timestamps */ - if (bindex == bstart) { + if (bindex == btop) { vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; @@ -388,7 +388,7 @@ out: int aufs_rmdir(struct inode *dir, struct dentry *dentry) { int err, rmdir_later; - aufs_bindex_t bwh, bindex, bstart; + aufs_bindex_t bwh, bindex, btop; struct inode *inode; struct dentry *parent, *wh_dentry, *h_dentry; struct au_whtmp_rmdir *args; @@ -428,7 +428,7 @@ int aufs_rmdir(struct inode *dir, struct dentry *dentry) if (unlikely(err)) goto out_parent; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); bwh = au_dbwh(dentry); bindex = -1; wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/1, &bindex, &a->dt, @@ -437,18 +437,18 @@ int aufs_rmdir(struct inode *dir, struct dentry *dentry) if (IS_ERR(wh_dentry)) goto out_parent; - h_dentry = au_h_dptr(dentry, bstart); + h_dentry = au_h_dptr(dentry, btop); dget(h_dentry); rmdir_later = 0; - if (bindex == bstart) { - err = renwh_and_rmdir(dentry, bstart, &args->whlist, dir); + if (bindex == btop) { + err = renwh_and_rmdir(dentry, btop, &args->whlist, dir); if (err > 0) { rmdir_later = err; err = 0; } } else { /* stop monitoring */ - au_hn_free(au_hi(inode, bstart)); + au_hn_free(au_hi(inode, btop)); /* dir inode is locked */ IMustLock(d_inode(wh_dentry->d_parent)); @@ -461,7 +461,7 @@ int aufs_rmdir(struct inode *dir, struct dentry *dentry) epilog(dir, dentry, bindex); if (rmdir_later) { - au_whtmp_kick_rmdir(dir, bstart, h_dentry, args); + au_whtmp_kick_rmdir(dir, btop, h_dentry, args); args = NULL; } diff --git a/fs/aufs/i_op_ren.c b/fs/aufs/i_op_ren.c index de4e03bf0..fdc299221 100644 --- a/fs/aufs/i_op_ren.c +++ b/fs/aufs/i_op_ren.c @@ -32,7 +32,7 @@ struct au_ren_args { struct inode *dir, *inode; struct au_hinode *hdir; struct au_dtime dt[AuParentChild]; - aufs_bindex_t bstart; + aufs_bindex_t btop; } sd[AuSrcDst]; #define src_dentry sd[AuSRC].dentry @@ -45,7 +45,7 @@ struct au_ren_args { #define src_hdir sd[AuSRC].hdir #define src_h_dir sd[AuSRC].hdir->hi_inode #define src_dt sd[AuSRC].dt -#define src_bstart sd[AuSRC].bstart +#define src_btop sd[AuSRC].btop #define dst_dentry sd[AuDST].dentry #define dst_dir sd[AuDST].dir @@ -57,7 +57,7 @@ struct au_ren_args { #define dst_hdir sd[AuDST].hdir #define dst_h_dir sd[AuDST].hdir->hi_inode #define dst_dt sd[AuDST].dt -#define dst_bstart sd[AuDST].bstart +#define dst_btop sd[AuDST].btop struct dentry *h_trap; struct au_branch *br; @@ -189,12 +189,12 @@ static int au_ren_or_cpup(struct au_ren_args *a) struct inode *delegated; d = a->src_dentry; - if (au_dbstart(d) == a->btgt) { + if (au_dbtop(d) == a->btgt) { a->h_path.dentry = a->dst_h_dentry; if (au_ftest_ren(a->flags, DIROPQ) && au_dbdiropq(d) == a->btgt) au_fclr_ren(a->flags, DIROPQ); - AuDebugOn(au_dbstart(d) != a->btgt); + AuDebugOn(au_dbtop(d) != a->btgt); delegated = NULL; err = vfsub_rename(a->src_h_dir, au_h_dptr(d, a->btgt), a->dst_h_dir, &a->h_path, &delegated); @@ -313,7 +313,7 @@ static int do_rename(struct au_ren_args *a) a->dst_h_dentry = au_h_dptr(d, a->btgt); } - BUG_ON(d_is_positive(a->dst_h_dentry) && a->src_bstart != a->btgt); + BUG_ON(d_is_positive(a->dst_h_dentry) && a->src_btop != a->btgt); /* rename by vfs_rename or cpup */ d = a->dst_dentry; @@ -321,7 +321,7 @@ static int do_rename(struct au_ren_args *a) && (a->dst_wh_dentry || au_dbdiropq(d) == a->btgt /* hide the lower to keep xino */ - || a->btgt < au_dbend(d) + || a->btgt < au_dbbot(d) || au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ))) au_fset_ren(a->flags, DIROPQ); err = au_ren_or_cpup(a); @@ -337,7 +337,7 @@ static int do_rename(struct au_ren_args *a) } /* update target timestamps */ - AuDebugOn(au_dbstart(a->src_dentry) != a->btgt); + AuDebugOn(au_dbtop(a->src_dentry) != a->btgt); a->h_path.dentry = au_h_dptr(a->src_dentry, a->btgt); vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ a->src_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; @@ -410,10 +410,10 @@ static int may_rename_srcdir(struct dentry *dentry, aufs_bindex_t btgt) { int err; unsigned int rdhash; - aufs_bindex_t bstart; + aufs_bindex_t btop; - bstart = au_dbstart(dentry); - if (bstart != btgt) { + btop = au_dbtop(dentry); + if (btop != btgt) { struct au_nhash whlist; SiMustAnyLock(dentry->d_sb); @@ -429,7 +429,7 @@ static int may_rename_srcdir(struct dentry *dentry, aufs_bindex_t btgt) goto out; } - if (bstart == au_dbtaildir(dentry)) + if (btop == au_dbtaildir(dentry)) return 0; /* success */ err = au_test_empty_lower(dentry); @@ -462,16 +462,16 @@ static int au_ren_may_dir(struct au_ren_args *a) if (unlikely(err)) goto out; - au_set_dbstart(d, a->dst_bstart); + au_set_dbtop(d, a->dst_btop); err = may_rename_dstdir(d, &a->whlist); - au_set_dbstart(d, a->btgt); + au_set_dbtop(d, a->btgt); } - a->dst_h_dentry = au_h_dptr(d, au_dbstart(d)); + a->dst_h_dentry = au_h_dptr(d, au_dbtop(d)); if (unlikely(err)) goto out; d = a->src_dentry; - a->src_h_dentry = au_h_dptr(d, au_dbstart(d)); + a->src_h_dentry = au_h_dptr(d, au_dbtop(d)); if (au_ftest_ren(a->flags, ISDIR)) { err = may_rename_srcdir(d, a->btgt); if (unlikely(err)) { @@ -494,7 +494,7 @@ static int au_may_ren(struct au_ren_args *a) int err, isdir; struct inode *h_inode; - if (a->src_bstart == a->btgt) { + if (a->src_btop == a->btgt) { err = au_may_del(a->src_dentry, a->btgt, a->src_h_parent, au_ftest_ren(a->flags, ISDIR)); if (unlikely(err)) @@ -505,7 +505,7 @@ static int au_may_ren(struct au_ren_args *a) } err = 0; - if (a->dst_bstart != a->btgt) + if (a->dst_btop != a->btgt) goto out; err = -ENOTEMPTY; @@ -588,11 +588,11 @@ static int au_ren_lock(struct au_ren_args *a) if (unlikely(a->src_hdir->hi_inode != d_inode(a->src_h_parent) || a->dst_hdir->hi_inode != d_inode(a->dst_h_parent))) err = au_busy_or_stale(); - if (!err && au_dbstart(a->src_dentry) == a->btgt) + if (!err && au_dbtop(a->src_dentry) == a->btgt) err = au_h_verify(a->src_h_dentry, udba, d_inode(a->src_h_parent), a->src_h_parent, a->br); - if (!err && au_dbstart(a->dst_dentry) == a->btgt) + if (!err && au_dbtop(a->dst_dentry) == a->btgt) err = au_h_verify(a->dst_h_dentry, udba, d_inode(a->dst_h_parent), a->dst_h_parent, a->br); @@ -634,7 +634,7 @@ static void au_ren_refresh_dir(struct au_ren_args *a) static void au_ren_refresh(struct au_ren_args *a) { - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct dentry *d, *h_d; struct inode *i, *h_i; struct super_block *sb; @@ -655,32 +655,32 @@ static void au_ren_refresh(struct au_ren_args *a) } au_update_dbrange(d, /*do_put_zero*/1); } else { - bend = a->btgt; - for (bindex = au_dbstart(d); bindex < bend; bindex++) + bbot = a->btgt; + for (bindex = au_dbtop(d); bindex < bbot; bindex++) au_set_h_dptr(d, bindex, NULL); - bend = au_dbend(d); - for (bindex = a->btgt + 1; bindex <= bend; bindex++) + bbot = au_dbbot(d); + for (bindex = a->btgt + 1; bindex <= bbot; bindex++) au_set_h_dptr(d, bindex, NULL); au_update_dbrange(d, /*do_put_zero*/0); } d = a->src_dentry; au_set_dbwh(d, -1); - bend = au_dbend(d); - for (bindex = a->btgt + 1; bindex <= bend; bindex++) { + bbot = au_dbbot(d); + for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { h_d = au_h_dptr(d, bindex); if (h_d) au_set_h_dptr(d, bindex, NULL); } - au_set_dbend(d, a->btgt); + au_set_dbbot(d, a->btgt); sb = d->d_sb; i = a->src_inode; if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i)) return; /* success */ - bend = au_ibend(i); - for (bindex = a->btgt + 1; bindex <= bend; bindex++) { + bbot = au_ibbot(i); + for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { h_i = au_h_iptr(i, bindex); if (h_i) { au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0); @@ -688,7 +688,7 @@ static void au_ren_refresh(struct au_ren_args *a) au_set_h_iptr(i, bindex, NULL, 0); } } - au_set_ibend(i, a->btgt); + au_set_ibbot(i, a->btgt); } /* ---------------------------------------------------------------------- */ @@ -715,7 +715,7 @@ int au_wbr(struct dentry *dentry, aufs_bindex_t btgt) return btgt; } -/* sets src_bstart, dst_bstart and btgt */ +/* sets src_btop, dst_btop and btgt */ static int au_ren_wbr(struct au_ren_args *a) { int err; @@ -724,13 +724,13 @@ static int au_ren_wbr(struct au_ren_args *a) .flags = AuWrDir_ADD_ENTRY }; - a->src_bstart = au_dbstart(a->src_dentry); - a->dst_bstart = au_dbstart(a->dst_dentry); + a->src_btop = au_dbtop(a->src_dentry); + a->dst_btop = au_dbtop(a->dst_dentry); if (au_ftest_ren(a->flags, ISDIR)) au_fset_wrdir(wr_dir_args.flags, ISDIR); - wr_dir_args.force_btgt = a->src_bstart; - if (a->dst_inode && a->dst_bstart < a->src_bstart) - wr_dir_args.force_btgt = a->dst_bstart; + wr_dir_args.force_btgt = a->src_btop; + if (a->dst_inode && a->dst_btop < a->src_btop) + wr_dir_args.force_btgt = a->dst_btop; wr_dir_args.force_btgt = au_wbr(a->dst_dentry, wr_dir_args.force_btgt); err = au_wr_dir(a->dst_dentry, a->src_dentry, &wr_dir_args); a->btgt = err; @@ -880,7 +880,7 @@ int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry, goto out_children; /* prepare the writable parent dir on the same branch */ - if (a->dst_bstart == a->btgt) { + if (a->dst_btop == a->btgt) { au_fset_ren(a->flags, WHDST); } else { err = au_cpup_dirs(a->dst_dentry, a->btgt); @@ -911,7 +911,7 @@ int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry, au_fset_ren(a->flags, WHSRC); /* cpup src */ - if (a->src_bstart != a->btgt) { + if (a->src_btop != a->btgt) { struct au_pin pin; err = au_pin(&pin, a->src_dentry, a->btgt, @@ -921,18 +921,18 @@ int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry, struct au_cp_generic cpg = { .dentry = a->src_dentry, .bdst = a->btgt, - .bsrc = a->src_bstart, + .bsrc = a->src_btop, .len = -1, .pin = &pin, .flags = AuCpup_DTIME | AuCpup_HOPEN }; - AuDebugOn(au_dbstart(a->src_dentry) != a->src_bstart); + AuDebugOn(au_dbtop(a->src_dentry) != a->src_btop); err = au_sio_cpup_simple(&cpg); au_unpin(&pin); } if (unlikely(err)) goto out_children; - a->src_bstart = a->btgt; + a->src_btop = a->btgt; a->src_h_dentry = au_h_dptr(a->src_dentry, a->btgt); au_fset_ren(a->flags, WHSRC); } @@ -972,16 +972,16 @@ out_hdir: au_ren_unlock(a); out_children: au_nhash_wh_free(&a->whlist); - if (err && a->dst_inode && a->dst_bstart != a->btgt) { - AuDbg("bstart %d, btgt %d\n", a->dst_bstart, a->btgt); + if (err && a->dst_inode && a->dst_btop != a->btgt) { + AuDbg("btop %d, btgt %d\n", a->dst_btop, a->btgt); au_set_h_dptr(a->dst_dentry, a->btgt, NULL); - au_set_dbstart(a->dst_dentry, a->dst_bstart); + au_set_dbtop(a->dst_dentry, a->dst_btop); } out_parent: if (!err) d_move(a->src_dentry, a->dst_dentry); else { - au_update_dbstart(a->dst_dentry); + au_update_dbtop(a->dst_dentry); if (!a->dst_inode) d_drop(a->dst_dentry); } diff --git a/fs/aufs/iinfo.c b/fs/aufs/iinfo.c index 67ef672a0..3a10d8f13 100644 --- a/fs/aufs/iinfo.c +++ b/fs/aufs/iinfo.c @@ -11,10 +11,12 @@ struct inode *au_h_iptr(struct inode *inode, aufs_bindex_t bindex) { struct inode *h_inode; + struct au_hinode *hinode; IiMustAnyLock(inode); - h_inode = au_ii(inode)->ii_hinode[0 + bindex].hi_inode; + hinode = au_hinode(au_ii(inode), bindex); + h_inode = hinode->hi_inode; AuDebugOn(h_inode && atomic_read(&h_inode->i_count) <= 0); return h_inode; } @@ -49,7 +51,7 @@ void au_set_h_iptr(struct inode *inode, aufs_bindex_t bindex, IiMustWriteLock(inode); - hinode = iinfo->ii_hinode + bindex; + hinode = au_hinode(iinfo, bindex); hi = hinode->hi_inode; AuDebugOn(h_inode && atomic_read(&h_inode->i_count) <= 0); @@ -64,7 +66,7 @@ void au_set_h_iptr(struct inode *inode, aufs_bindex_t bindex, AuDebugOn(inode->i_mode && (h_inode->i_mode & S_IFMT) != (inode->i_mode & S_IFMT)); - if (bindex == iinfo->ii_bstart) + if (bindex == iinfo->ii_btop) au_cpup_igen(inode, h_inode); br = au_sbr(sb, bindex); hinode->hi_id = br->br_id; @@ -91,7 +93,7 @@ void au_set_hi_wh(struct inode *inode, aufs_bindex_t bindex, IiMustWriteLock(inode); - hinode = au_ii(inode)->ii_hinode + bindex; + hinode = au_hinode(au_ii(inode), bindex); AuDebugOn(hinode->hi_whdentry); hinode->hi_whdentry = h_wh; } @@ -118,20 +120,18 @@ void au_update_iigen(struct inode *inode, int half) void au_update_ibrange(struct inode *inode, int do_put_zero) { struct au_iinfo *iinfo; - aufs_bindex_t bindex, bend; - - iinfo = au_ii(inode); - if (!iinfo) - return; + aufs_bindex_t bindex, bbot; + AuDebugOn(is_bad_inode(inode)); IiMustWriteLock(inode); - if (do_put_zero && iinfo->ii_bstart >= 0) { - for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; + iinfo = au_ii(inode); + if (do_put_zero && iinfo->ii_btop >= 0) { + for (bindex = iinfo->ii_btop; bindex <= iinfo->ii_bbot; bindex++) { struct inode *h_i; - h_i = iinfo->ii_hinode[0 + bindex].hi_inode; + h_i = au_hinode(iinfo, bindex)->hi_inode; if (h_i && !h_i->i_nlink && !(h_i->i_state & I_LINKABLE)) @@ -139,21 +139,21 @@ void au_update_ibrange(struct inode *inode, int do_put_zero) } } - iinfo->ii_bstart = -1; - iinfo->ii_bend = -1; - bend = au_sbend(inode->i_sb); - for (bindex = 0; bindex <= bend; bindex++) - if (iinfo->ii_hinode[0 + bindex].hi_inode) { - iinfo->ii_bstart = bindex; + iinfo->ii_btop = -1; + iinfo->ii_bbot = -1; + bbot = au_sbbot(inode->i_sb); + for (bindex = 0; bindex <= bbot; bindex++) + if (au_hinode(iinfo, bindex)->hi_inode) { + iinfo->ii_btop = bindex; break; } - if (iinfo->ii_bstart >= 0) - for (bindex = bend; bindex >= iinfo->ii_bstart; bindex--) - if (iinfo->ii_hinode[0 + bindex].hi_inode) { - iinfo->ii_bend = bindex; + if (iinfo->ii_btop >= 0) + for (bindex = bbot; bindex >= iinfo->ii_btop; bindex--) + if (au_hinode(iinfo, bindex)->hi_inode) { + iinfo->ii_bbot = bindex; break; } - AuDebugOn(iinfo->ii_bstart > iinfo->ii_bend); + AuDebugOn(iinfo->ii_btop > iinfo->ii_bbot); } /* ---------------------------------------------------------------------- */ @@ -162,14 +162,20 @@ void au_icntnr_init_once(void *_c) { struct au_icntnr *c = _c; struct au_iinfo *iinfo = &c->iinfo; - static struct lock_class_key aufs_ii; spin_lock_init(&iinfo->ii_generation.ig_spin); au_rw_init(&iinfo->ii_rwsem); - au_rw_class(&iinfo->ii_rwsem, &aufs_ii); inode_init_once(&c->vfs_inode); } +void au_hinode_init(struct au_hinode *hinode) +{ + hinode->hi_inode = NULL; + hinode->hi_id = -1; + au_hn_init(hinode); + hinode->hi_whdentry = NULL; +} + int au_iinfo_init(struct inode *inode) { struct au_iinfo *iinfo; @@ -178,37 +184,37 @@ int au_iinfo_init(struct inode *inode) sb = inode->i_sb; iinfo = &(container_of(inode, struct au_icntnr, vfs_inode)->iinfo); - nbr = au_sbend(sb) + 1; + nbr = au_sbbot(sb) + 1; if (unlikely(nbr <= 0)) nbr = 1; - iinfo->ii_hinode = kcalloc(nbr, sizeof(*iinfo->ii_hinode), GFP_NOFS); + iinfo->ii_hinode = kmalloc_array(nbr, sizeof(*iinfo->ii_hinode), + GFP_NOFS); if (iinfo->ii_hinode) { au_ninodes_inc(sb); for (i = 0; i < nbr; i++) - iinfo->ii_hinode[i].hi_id = -1; + au_hinode_init(iinfo->ii_hinode + i); iinfo->ii_generation.ig_generation = au_sigen(sb); - iinfo->ii_bstart = -1; - iinfo->ii_bend = -1; + iinfo->ii_btop = -1; + iinfo->ii_bbot = -1; iinfo->ii_vdir = NULL; return 0; } return -ENOMEM; } -int au_ii_realloc(struct au_iinfo *iinfo, int nbr) +int au_hinode_realloc(struct au_iinfo *iinfo, int nbr) { - int err, sz; + int err, i; struct au_hinode *hip; AuRwMustWriteLock(&iinfo->ii_rwsem); err = -ENOMEM; - sz = sizeof(*hip) * (iinfo->ii_bend + 1); - if (!sz) - sz = sizeof(*hip); - hip = au_kzrealloc(iinfo->ii_hinode, sz, sizeof(*hip) * nbr, GFP_NOFS); + hip = krealloc(iinfo->ii_hinode, sizeof(*hip) * nbr, GFP_NOFS); if (hip) { + for (i = iinfo->ii_bbot + 1; i < nbr; i++) + au_hinode_init(hip + i); iinfo->ii_hinode = hip; err = 0; } @@ -221,13 +227,10 @@ void au_iinfo_fin(struct inode *inode) struct au_iinfo *iinfo; struct au_hinode *hi; struct super_block *sb; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; const unsigned char unlinked = !inode->i_nlink; - iinfo = au_ii(inode); - /* bad_inode case */ - if (!iinfo) - return; + AuDebugOn(is_bad_inode(inode)); sb = inode->i_sb; au_ninodes_dec(sb); @@ -245,20 +248,20 @@ void au_iinfo_fin(struct inode *inode) lockdep_on(); } + iinfo = au_ii(inode); if (iinfo->ii_vdir) au_vdir_free(iinfo->ii_vdir); - bindex = iinfo->ii_bstart; + bindex = iinfo->ii_btop; if (bindex >= 0) { - hi = iinfo->ii_hinode + bindex; - bend = iinfo->ii_bend; - while (bindex++ <= bend) { + hi = au_hinode(iinfo, bindex); + bbot = iinfo->ii_bbot; + while (bindex++ <= bbot) { if (hi->hi_inode) au_hiput(hi); hi++; } } kfree(iinfo->ii_hinode); - iinfo->ii_hinode = NULL; AuRwDestroy(&iinfo->ii_rwsem); } diff --git a/fs/aufs/inode.c b/fs/aufs/inode.c index 5a87727ba..d599b4c80 100644 --- a/fs/aufs/inode.c +++ b/fs/aufs/inode.c @@ -34,19 +34,20 @@ static int au_ii_refresh(struct inode *inode, int *update) struct au_iinfo *iinfo; struct au_hinode *p, *q, tmp; + AuDebugOn(is_bad_inode(inode)); IiMustWriteLock(inode); *update = 0; sb = inode->i_sb; type = inode->i_mode & S_IFMT; iinfo = au_ii(inode); - err = au_ii_realloc(iinfo, au_sbend(sb) + 1); + err = au_hinode_realloc(iinfo, au_sbbot(sb) + 1); if (unlikely(err)) goto out; - AuDebugOn(iinfo->ii_bstart < 0); - p = iinfo->ii_hinode + iinfo->ii_bstart; - for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; + AuDebugOn(iinfo->ii_btop < 0); + p = au_hinode(iinfo, iinfo->ii_btop); + for (bindex = iinfo->ii_btop; bindex <= iinfo->ii_bbot; bindex++, p++) { if (!p->hi_inode) continue; @@ -63,12 +64,12 @@ static int au_ii_refresh(struct inode *inode, int *update) continue; } - if (new_bindex < iinfo->ii_bstart) - iinfo->ii_bstart = new_bindex; - if (iinfo->ii_bend < new_bindex) - iinfo->ii_bend = new_bindex; + if (new_bindex < iinfo->ii_btop) + iinfo->ii_btop = new_bindex; + if (iinfo->ii_bbot < new_bindex) + iinfo->ii_bbot = new_bindex; /* swap two lower inode, and loop again */ - q = iinfo->ii_hinode + new_bindex; + q = au_hinode(iinfo, new_bindex); tmp = *q; *q = *p; *p = tmp; @@ -130,7 +131,7 @@ int au_refresh_hinode(struct inode *inode, struct dentry *dentry) int err, e, update; unsigned int flags; umode_t mode; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; unsigned char isdir; struct au_hinode *p; struct au_iinfo *iinfo; @@ -141,12 +142,12 @@ int au_refresh_hinode(struct inode *inode, struct dentry *dentry) update = 0; iinfo = au_ii(inode); - p = iinfo->ii_hinode + iinfo->ii_bstart; + p = au_hinode(iinfo, iinfo->ii_btop); mode = (inode->i_mode & S_IFMT); isdir = S_ISDIR(mode); flags = au_hi_flags(inode, isdir); - bend = au_dbend(dentry); - for (bindex = au_dbstart(dentry); bindex <= bend; bindex++) { + bbot = au_dbbot(dentry); + for (bindex = au_dbtop(dentry); bindex <= bbot; bindex++) { struct inode *h_i, *h_inode; struct dentry *h_d; @@ -156,7 +157,7 @@ int au_refresh_hinode(struct inode *inode, struct dentry *dentry) h_inode = d_inode(h_d); AuDebugOn(mode != (h_inode->i_mode & S_IFMT)); - if (iinfo->ii_bstart <= bindex && bindex <= iinfo->ii_bend) { + if (iinfo->ii_btop <= bindex && bindex <= iinfo->ii_bbot) { h_i = au_h_iptr(inode, bindex); if (h_i) { if (h_i == h_inode) @@ -165,10 +166,10 @@ int au_refresh_hinode(struct inode *inode, struct dentry *dentry) break; } } - if (bindex < iinfo->ii_bstart) - iinfo->ii_bstart = bindex; - if (iinfo->ii_bend < bindex) - iinfo->ii_bend = bindex; + if (bindex < iinfo->ii_btop) + iinfo->ii_btop = bindex; + if (iinfo->ii_bbot < bindex) + iinfo->ii_bbot = bindex; au_set_h_iptr(inode, bindex, au_igrab(h_inode), flags); update = 1; } @@ -189,7 +190,7 @@ static int set_inode(struct inode *inode, struct dentry *dentry) int err; unsigned int flags; umode_t mode; - aufs_bindex_t bindex, bstart, btail; + aufs_bindex_t bindex, btop, btail; unsigned char isdir; struct dentry *h_dentry; struct inode *h_inode; @@ -201,8 +202,8 @@ static int set_inode(struct inode *inode, struct dentry *dentry) err = 0; isdir = 0; iop = au_sbi(inode->i_sb)->si_iop_array; - bstart = au_dbstart(dentry); - h_dentry = au_h_dptr(dentry, bstart); + btop = au_dbtop(dentry); + h_dentry = au_h_dptr(dentry, btop); h_inode = d_inode(h_dentry); mode = h_inode->i_mode; switch (mode & S_IFMT) { @@ -210,7 +211,7 @@ static int set_inode(struct inode *inode, struct dentry *dentry) btail = au_dbtail(dentry); inode->i_op = iop + AuIop_OTHER; inode->i_fop = &aufs_file_fop; - err = au_dy_iaop(inode, bstart, h_inode); + err = au_dy_iaop(inode, btop, h_inode); if (unlikely(err)) goto out; break; @@ -246,9 +247,9 @@ static int set_inode(struct inode *inode, struct dentry *dentry) && !memcmp(dentry->d_name.name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) au_fclr_hi(flags, HNOTIFY); iinfo = au_ii(inode); - iinfo->ii_bstart = bstart; - iinfo->ii_bend = btail; - for (bindex = bstart; bindex <= btail; bindex++) { + iinfo->ii_btop = btop; + iinfo->ii_bbot = btail; + for (bindex = btop; bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (h_dentry) au_set_h_iptr(inode, bindex, @@ -274,7 +275,7 @@ static int reval_inode(struct inode *inode, struct dentry *dentry) { int err; unsigned int gen, igflags; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct inode *h_inode, *h_dinode; struct dentry *h_dentry; @@ -289,10 +290,10 @@ static int reval_inode(struct inode *inode, struct dentry *dentry) err = 1; ii_write_lock_new_child(inode); - h_dentry = au_h_dptr(dentry, au_dbstart(dentry)); + h_dentry = au_h_dptr(dentry, au_dbtop(dentry)); h_dinode = d_inode(h_dentry); - bend = au_ibend(inode); - for (bindex = au_ibstart(inode); bindex <= bend; bindex++) { + bbot = au_ibbot(inode); + for (bindex = au_ibtop(inode); bindex <= bbot; bindex++) { h_inode = au_h_iptr(inode, bindex); if (!h_inode || h_inode != h_dinode) continue; @@ -358,11 +359,11 @@ struct inode *au_new_inode(struct dentry *dentry, int must_new) struct mutex *mtx; ino_t h_ino, ino; int err; - aufs_bindex_t bstart; + aufs_bindex_t btop; sb = dentry->d_sb; - bstart = au_dbstart(dentry); - h_dentry = au_h_dptr(dentry, bstart); + btop = au_dbtop(dentry); + h_dentry = au_h_dptr(dentry, btop); h_inode = d_inode(h_dentry); h_ino = h_inode->i_ino; @@ -372,12 +373,12 @@ struct inode *au_new_inode(struct dentry *dentry, int must_new) */ mtx = NULL; if (!d_is_dir(h_dentry)) - mtx = &au_sbr(sb, bstart)->br_xino.xi_nondir_mtx; + mtx = &au_sbr(sb, btop)->br_xino.xi_nondir_mtx; new_ino: if (mtx) mutex_lock(mtx); - err = au_xino_read(sb, bstart, h_ino, &ino); + err = au_xino_read(sb, btop, h_ino, &ino); inode = ERR_PTR(err); if (unlikely(err)) goto out; @@ -398,17 +399,6 @@ new_ino: AuDbg("%lx, new %d\n", inode->i_state, !!(inode->i_state & I_NEW)); if (inode->i_state & I_NEW) { - /* verbose coding for lock class name */ - if (unlikely(d_is_symlink(h_dentry))) - au_rw_class(&au_ii(inode)->ii_rwsem, - au_lc_key + AuLcSymlink_IIINFO); - else if (unlikely(d_is_dir(h_dentry))) - au_rw_class(&au_ii(inode)->ii_rwsem, - au_lc_key + AuLcDir_IIINFO); - else /* likely */ - au_rw_class(&au_ii(inode)->ii_rwsem, - au_lc_key + AuLcNonDir_IIINFO); - ii_write_lock_new_child(inode); err = set_inode(inode, dentry); if (!err) { @@ -424,7 +414,7 @@ new_ino: atomic_inc(&inode->i_count); iget_failed(inode); ii_write_unlock(inode); - au_xino_write(sb, bstart, h_ino, /*ino*/0); + au_xino_write(sb, btop, h_ino, /*ino*/0); /* ignore this error */ goto out_iput; } else if (!must_new && !IS_DEADDIR(inode) && inode->i_nlink) { @@ -450,10 +440,10 @@ new_ino: if (unlikely(au_test_fs_unique_ino(h_inode))) AuWarn1("Warning: Un-notified UDBA or repeatedly renamed dir," " b%d, %s, %pd, hi%lu, i%lu.\n", - bstart, au_sbtype(h_dentry->d_sb), dentry, + btop, au_sbtype(h_dentry->d_sb), dentry, (unsigned long)h_ino, (unsigned long)ino); ino = 0; - err = au_xino_write(sb, bstart, h_ino, /*ino*/0); + err = au_xino_write(sb, btop, h_ino, /*ino*/0); if (!err) { iput(inode); if (mtx) @@ -483,8 +473,8 @@ int au_test_ro(struct super_block *sb, aufs_bindex_t bindex, /* pseudo-link after flushed may happen out of bounds */ if (!err && inode - && au_ibstart(inode) <= bindex - && bindex <= au_ibend(inode)) { + && au_ibtop(inode) <= bindex + && bindex <= au_ibbot(inode)) { /* * permission check is unnecessary since vfsub routine * will be called later diff --git a/fs/aufs/inode.h b/fs/aufs/inode.h index e694be498..0d654e83a 100644 --- a/fs/aufs/inode.h +++ b/fs/aufs/inode.h @@ -56,7 +56,7 @@ struct au_iinfo { struct super_block *ii_hsb1; /* no get/put */ struct au_rwsem ii_rwsem; - aufs_bindex_t ii_bstart, ii_bend; + aufs_bindex_t ii_btop, ii_bbot; __u32 ii_higen; struct au_hinode *ii_hinode; struct au_vdir *ii_vdir; @@ -106,12 +106,8 @@ void au_pin_hdir_release(struct au_pin *p); static inline struct au_iinfo *au_ii(struct inode *inode) { - struct au_iinfo *iinfo; - - iinfo = &(container_of(inode, struct au_icntnr, vfs_inode)->iinfo); - if (iinfo->ii_hinode) - return iinfo; - return NULL; /* debugging bad_inode case */ + BUG_ON(is_bad_inode(inode)); + return &(container_of(inode, struct au_icntnr, vfs_inode)->iinfo); } /* ---------------------------------------------------------------------- */ @@ -254,9 +250,10 @@ void au_update_iigen(struct inode *inode, int half); void au_update_ibrange(struct inode *inode, int do_put_zero); void au_icntnr_init_once(void *_c); +void au_hinode_init(struct au_hinode *hinode); int au_iinfo_init(struct inode *inode); void au_iinfo_fin(struct inode *inode); -int au_ii_realloc(struct au_iinfo *iinfo, int nbr); +int au_hinode_realloc(struct au_iinfo *iinfo, int nbr); #ifdef CONFIG_PROC_FS /* plink.c */ @@ -464,23 +461,29 @@ static inline int au_iigen_test(struct inode *inode, unsigned int sigen) /* ---------------------------------------------------------------------- */ +static inline struct au_hinode *au_hinode(struct au_iinfo *iinfo, + aufs_bindex_t bindex) +{ + return iinfo->ii_hinode + bindex; +} + static inline aufs_bindex_t au_ii_br_id(struct inode *inode, aufs_bindex_t bindex) { IiMustAnyLock(inode); - return au_ii(inode)->ii_hinode[0 + bindex].hi_id; + return au_hinode(au_ii(inode), bindex)->hi_id; } -static inline aufs_bindex_t au_ibstart(struct inode *inode) +static inline aufs_bindex_t au_ibtop(struct inode *inode) { IiMustAnyLock(inode); - return au_ii(inode)->ii_bstart; + return au_ii(inode)->ii_btop; } -static inline aufs_bindex_t au_ibend(struct inode *inode) +static inline aufs_bindex_t au_ibbot(struct inode *inode) { IiMustAnyLock(inode); - return au_ii(inode)->ii_bend; + return au_ii(inode)->ii_bbot; } static inline struct au_vdir *au_ivdir(struct inode *inode) @@ -492,19 +495,19 @@ static inline struct au_vdir *au_ivdir(struct inode *inode) static inline struct dentry *au_hi_wh(struct inode *inode, aufs_bindex_t bindex) { IiMustAnyLock(inode); - return au_ii(inode)->ii_hinode[0 + bindex].hi_whdentry; + return au_hinode(au_ii(inode), bindex)->hi_whdentry; } -static inline void au_set_ibstart(struct inode *inode, aufs_bindex_t bindex) +static inline void au_set_ibtop(struct inode *inode, aufs_bindex_t bindex) { IiMustWriteLock(inode); - au_ii(inode)->ii_bstart = bindex; + au_ii(inode)->ii_btop = bindex; } -static inline void au_set_ibend(struct inode *inode, aufs_bindex_t bindex) +static inline void au_set_ibbot(struct inode *inode, aufs_bindex_t bindex) { IiMustWriteLock(inode); - au_ii(inode)->ii_bend = bindex; + au_ii(inode)->ii_bbot = bindex; } static inline void au_set_ivdir(struct inode *inode, struct au_vdir *vdir) @@ -516,7 +519,7 @@ static inline void au_set_ivdir(struct inode *inode, struct au_vdir *vdir) static inline struct au_hinode *au_hi(struct inode *inode, aufs_bindex_t bindex) { IiMustAnyLock(inode); - return au_ii(inode)->ii_hinode + bindex; + return au_hinode(au_ii(inode), bindex); } /* ---------------------------------------------------------------------- */ diff --git a/fs/aufs/ioctl.c b/fs/aufs/ioctl.c index 6528fb911..2ebfdc4c1 100644 --- a/fs/aufs/ioctl.c +++ b/fs/aufs/ioctl.c @@ -17,7 +17,7 @@ static int au_wbr_fd(struct path *path, struct aufs_wbr_fd __user *arg) { int err, fd; - aufs_bindex_t wbi, bindex, bend; + aufs_bindex_t wbi, bindex, bbot; struct file *h_file; struct super_block *sb; struct dentry *root; @@ -57,10 +57,10 @@ static int au_wbr_fd(struct path *path, struct aufs_wbr_fd __user *arg) sb = path->dentry->d_sb; root = sb->s_root; aufs_read_lock(root, AuLock_IR); - bend = au_sbend(sb); + bbot = au_sbbot(sb); if (wbrfd.brid >= 0) { wbi = au_br_index(sb, wbrfd.brid); - if (unlikely(wbi < 0 || wbi > bend)) + if (unlikely(wbi < 0 || wbi > bbot)) goto out_unlock; } @@ -72,7 +72,7 @@ static int au_wbr_fd(struct path *path, struct aufs_wbr_fd __user *arg) bindex = wbi + 1; wbi = -1; - for (; bindex <= bend; bindex++) { + for (; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (au_br_writable(br->br_perm)) { wbi = bindex; @@ -92,7 +92,7 @@ out_unlock: if (IS_ERR(h_file)) goto out_fd; - atomic_dec(&br->br_count); /* cf. au_h_open() */ + au_br_put(br); /* cf. au_h_open() */ fd_install(fd, h_file); err = fd; goto out; /* success */ diff --git a/fs/aufs/module.c b/fs/aufs/module.c index 317fde014..88f8f4123 100644 --- a/fs/aufs/module.c +++ b/fs/aufs/module.c @@ -26,7 +26,28 @@ void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp) /* * aufs caches */ -struct kmem_cache *au_cachep[AuCache_Last]; +struct kmem_cache *au_cachep[AuCache_Last] = { + [0] = NULL +}; + +static void au_cache_fin(void) +{ + int i; + + /* + * Make sure all delayed rcu free inodes are flushed before we + * destroy cache. + */ + rcu_barrier(); + + /* excluding AuCache_HNOTIFY */ + BUILD_BUG_ON(AuCache_HNOTIFY + 1 != AuCache_Last); + for (i = 0; i < AuCache_HNOTIFY; i++) { + kmem_cache_destroy(au_cachep[i]); + au_cachep[i] = NULL; + } +} + static int __init au_cache_init(void) { au_cachep[AuCache_DINFO] = AuCacheCtor(au_dinfo, au_di_init_once); @@ -44,27 +65,10 @@ static int __init au_cache_init(void) if (au_cachep[AuCache_DEHSTR]) return 0; + au_cache_fin(); return -ENOMEM; } -static void au_cache_fin(void) -{ - int i; - - /* - * Make sure all delayed rcu free inodes are flushed before we - * destroy cache. - */ - rcu_barrier(); - - /* excluding AuCache_HNOTIFY */ - BUILD_BUG_ON(AuCache_HNOTIFY + 1 != AuCache_Last); - for (i = 0; i < AuCache_HNOTIFY; i++) { - kmem_cache_destroy(au_cachep[i]); - au_cachep[i] = NULL; - } -} - /* ---------------------------------------------------------------------- */ int au_dir_roflags; @@ -77,8 +81,6 @@ int au_dir_roflags; struct au_sphlhead au_sbilist; #endif -struct lock_class_key au_lc_key[AuLcKey_Last]; - /* * functions for module interface. */ diff --git a/fs/aufs/module.h b/fs/aufs/module.h index bb8644730..1383e3da9 100644 --- a/fs/aufs/module.h +++ b/fs/aufs/module.h @@ -24,22 +24,6 @@ extern bool au_userns; extern int au_dir_roflags; -enum { - AuLcNonDir_FIINFO, - AuLcNonDir_DIINFO, - AuLcNonDir_IIINFO, - - AuLcDir_FIINFO, - AuLcDir_DIINFO, - AuLcDir_IIINFO, - - AuLcSymlink_DIINFO, - AuLcSymlink_IIINFO, - - AuLcKey_Last -}; -extern struct lock_class_key au_lc_key[AuLcKey_Last]; - void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp); int au_seq_path(struct seq_file *seq, struct path *path); diff --git a/fs/aufs/mvdown.c b/fs/aufs/mvdown.c index d8415422b..334f25c13 100644 --- a/fs/aufs/mvdown.c +++ b/fs/aufs/mvdown.c @@ -53,27 +53,27 @@ struct au_mvd_args { static int find_lower_writable(struct au_mvd_args *a) { struct super_block *sb; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_branch *br; sb = a->sb; bindex = a->mvd_bsrc; - bend = au_sbend(sb); + bbot = au_sbbot(sb); if (a->mvdown.flags & AUFS_MVDOWN_FHSM_LOWER) - for (bindex++; bindex <= bend; bindex++) { + for (bindex++; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (au_br_fhsm(br->br_perm) && (!(au_br_sb(br)->s_flags & MS_RDONLY))) return bindex; } else if (!(a->mvdown.flags & AUFS_MVDOWN_ROLOWER)) - for (bindex++; bindex <= bend; bindex++) { + for (bindex++; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (!au_br_rdonly(br)) return bindex; } else - for (bindex++; bindex <= bend; bindex++) { + for (bindex++; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (!(au_br_sb(br)->s_flags & MS_RDONLY)) { if (au_br_rdonly(br)) @@ -96,7 +96,7 @@ static int au_do_mkdir(const unsigned char dmsg, struct au_mvd_args *a) a->mvd_hdir_dst = au_hi(a->dir, a->mvd_bdst); a->mvd_h_src_parent = au_h_dptr(a->parent, a->mvd_bsrc); a->mvd_h_dst_parent = NULL; - if (au_dbend(a->parent) >= a->mvd_bdst) + if (au_dbbot(a->parent) >= a->mvd_bdst) a->mvd_h_dst_parent = au_h_dptr(a->parent, a->mvd_bdst); if (!a->mvd_h_dst_parent) { err = au_cpdown_dirs(a->dentry, a->mvd_bdst); @@ -350,20 +350,20 @@ static int au_do_mvdown(const unsigned char dmsg, struct au_mvd_args *a) /* maintain internal array */ if (!(a->mvdown.flags & AUFS_MVDOWN_KUPPER)) { au_set_h_dptr(a->dentry, a->mvd_bsrc, NULL); - au_set_dbstart(a->dentry, a->mvd_bdst); + au_set_dbtop(a->dentry, a->mvd_bdst); au_set_h_iptr(a->inode, a->mvd_bsrc, NULL, /*flags*/0); - au_set_ibstart(a->inode, a->mvd_bdst); + au_set_ibtop(a->inode, a->mvd_bdst); } else { /* hide the lower */ au_set_h_dptr(a->dentry, a->mvd_bdst, NULL); - au_set_dbend(a->dentry, a->mvd_bsrc); + au_set_dbbot(a->dentry, a->mvd_bsrc); au_set_h_iptr(a->inode, a->mvd_bdst, NULL, /*flags*/0); - au_set_ibend(a->inode, a->mvd_bsrc); + au_set_ibbot(a->inode, a->mvd_bsrc); } - if (au_dbend(a->dentry) < a->mvd_bdst) - au_set_dbend(a->dentry, a->mvd_bdst); - if (au_ibend(a->inode) < a->mvd_bdst) - au_set_ibend(a->inode, a->mvd_bdst); + if (au_dbbot(a->dentry) < a->mvd_bdst) + au_set_dbbot(a->dentry, a->mvd_bdst); + if (au_ibbot(a->inode) < a->mvd_bdst) + au_set_ibbot(a->inode, a->mvd_bdst); out_unlock: au_do_unlock(dmsg, a); @@ -381,7 +381,7 @@ static int au_mvd_args_busy(const unsigned char dmsg, struct au_mvd_args *a) err = 0; plinked = !!au_opt_test(au_mntflags(a->sb), PLINK); - if (au_dbstart(a->dentry) == a->mvd_bsrc + if (au_dbtop(a->dentry) == a->mvd_bsrc && au_dcount(a->dentry) == 1 && atomic_read(&a->inode->i_count) == 1 /* && a->mvd_h_src_inode->i_nlink == 1 */ @@ -392,7 +392,7 @@ static int au_mvd_args_busy(const unsigned char dmsg, struct au_mvd_args *a) err = -EBUSY; AU_MVD_PR(dmsg, "b%d, d{b%d, c%d?}, i{c%d?, l%u}, hi{l%u}, p{%d, %d}\n", - a->mvd_bsrc, au_dbstart(a->dentry), au_dcount(a->dentry), + a->mvd_bsrc, au_dbtop(a->dentry), au_dcount(a->dentry), atomic_read(&a->inode->i_count), a->inode->i_nlink, a->mvd_h_src_inode->i_nlink, plinked, plinked ? au_plink_test(a->inode) : 0); @@ -455,7 +455,7 @@ static int au_mvd_args_intermediate(const unsigned char dmsg, if (!err) a->bwh = au_dbwh(a->dentry); else if (err > 0) - a->bfound = au_dbstart(a->dentry); + a->bfound = au_dbtop(a->dentry); au_di_swap(tmp, dinfo); au_rw_write_unlock(&tmp->di_rwsem); @@ -542,22 +542,22 @@ static int au_mvd_args(const unsigned char dmsg, struct au_mvd_args *a) err = -EINVAL; if (!(a->mvdown.flags & AUFS_MVDOWN_BRID_UPPER)) - a->mvd_bsrc = au_ibstart(a->inode); + a->mvd_bsrc = au_ibtop(a->inode); else { a->mvd_bsrc = au_br_index(a->sb, a->mvd_src_brid); if (unlikely(a->mvd_bsrc < 0 - || (a->mvd_bsrc < au_dbstart(a->dentry) - || au_dbend(a->dentry) < a->mvd_bsrc + || (a->mvd_bsrc < au_dbtop(a->dentry) + || au_dbbot(a->dentry) < a->mvd_bsrc || !au_h_dptr(a->dentry, a->mvd_bsrc)) - || (a->mvd_bsrc < au_ibstart(a->inode) - || au_ibend(a->inode) < a->mvd_bsrc + || (a->mvd_bsrc < au_ibtop(a->inode) + || au_ibbot(a->inode) < a->mvd_bsrc || !au_h_iptr(a->inode, a->mvd_bsrc)))) { a->mvd_errno = EAU_MVDOWN_NOUPPER; AU_MVD_PR(dmsg, "no upper\n"); goto out; } } - if (unlikely(a->mvd_bsrc == au_sbend(a->sb))) { + if (unlikely(a->mvd_bsrc == au_sbbot(a->sb))) { a->mvd_errno = EAU_MVDOWN_BOTTOM; AU_MVD_PR(dmsg, "on the bottom\n"); goto out; @@ -587,7 +587,7 @@ static int au_mvd_args(const unsigned char dmsg, struct au_mvd_args *a) } else { a->mvd_bdst = au_br_index(a->sb, a->mvd_dst_brid); if (unlikely(a->mvd_bdst < 0 - || au_sbend(a->sb) < a->mvd_bdst)) { + || au_sbbot(a->sb) < a->mvd_bdst)) { a->mvd_errno = EAU_MVDOWN_NOLOWERBR; AU_MVD_PR(dmsg, "no lower brid\n"); goto out; diff --git a/fs/aufs/opts.c b/fs/aufs/opts.c index fc90b657a..23a146d17 100644 --- a/fs/aufs/opts.c +++ b/fs/aufs/opts.c @@ -824,7 +824,7 @@ static int au_opts_parse_idel(struct super_block *sb, aufs_bindex_t bindex, err = -EINVAL; root = sb->s_root; aufs_read_lock(root, AuLock_FLUSH); - if (bindex < 0 || au_sbend(sb) < bindex) { + if (bindex < 0 || au_sbbot(sb) < bindex) { pr_err("out of bounds, %d\n", bindex); goto out; } @@ -880,7 +880,7 @@ static int au_opts_parse_imod(struct super_block *sb, aufs_bindex_t bindex, err = -EINVAL; root = sb->s_root; aufs_read_lock(root, AuLock_FLUSH); - if (bindex < 0 || au_sbend(sb) < bindex) { + if (bindex < 0 || au_sbbot(sb) < bindex) { pr_err("out of bounds, %d\n", bindex); goto out; } @@ -929,7 +929,7 @@ au_opts_parse_xino_itrunc_path(struct super_block *sb, substring_t args[]) { int err; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct path path; struct dentry *root; @@ -942,8 +942,8 @@ au_opts_parse_xino_itrunc_path(struct super_block *sb, xino_itrunc->bindex = -1; root = sb->s_root; aufs_read_lock(root, AuLock_FLUSH); - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { if (au_h_dptr(root, bindex) == path.dentry) { xino_itrunc->bindex = bindex; break; @@ -1087,7 +1087,7 @@ int au_opts_parse(struct super_block *sb, char *str, struct au_opts *opts) } u.xino_itrunc->bindex = n; aufs_read_lock(root, AuLock_FLUSH); - if (n < 0 || au_sbend(sb) < n) { + if (n < 0 || au_sbbot(sb) < n) { pr_err("out of bounds, %d\n", n); aufs_read_unlock(root, !AuLock_IR); break; @@ -1465,7 +1465,7 @@ static int au_opt_br(struct super_block *sb, struct au_opt *opt, err = 0; switch (opt->type) { case Opt_append: - opt->add.bindex = au_sbend(sb) + 1; + opt->add.bindex = au_sbbot(sb) + 1; if (opt->add.bindex < 0) opt->add.bindex = 0; goto add; @@ -1513,7 +1513,7 @@ static int au_opt_xino(struct super_block *sb, struct au_opt *opt, struct au_opts *opts) { int err; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct dentry *root, *parent, *h_root; err = 0; @@ -1530,8 +1530,8 @@ static int au_opt_xino(struct super_block *sb, struct au_opt *opt, /* safe d_parent access */ parent = opt->xino.file->f_path.dentry->d_parent; root = sb->s_root; - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { h_root = au_h_dptr(root, bindex); if (h_root == parent) { au_xino_brid_set(sb, au_sbr_id(sb, bindex)); @@ -1554,7 +1554,7 @@ int au_opts_verify(struct super_block *sb, unsigned long sb_flags, unsigned int pending) { int err, fhsm; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; unsigned char do_plink, skip, do_free, can_no_dreval; struct au_branch *br; struct au_wbr *wbr; @@ -1590,8 +1590,8 @@ int au_opts_verify(struct super_block *sb, unsigned long sb_flags, do_plink = !!au_opt_test(sbinfo->si_mntflags, PLINK); can_no_dreval = !!au_opt_test((sbinfo->si_mntflags | pending), UDBA_NONE); - bend = au_sbend(sb); - for (bindex = 0; !err && bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; !err && bindex <= bbot; bindex++) { skip = 0; h_dir = au_h_iptr(dir, bindex); br = au_sbr(sb, bindex); @@ -1677,7 +1677,7 @@ int au_opts_verify(struct super_block *sb, unsigned long sb_flags, if (fhsm >= 2) { au_fset_si(sbinfo, FHSM); - for (bindex = bend; bindex >= 0; bindex--) { + for (bindex = bbot; bindex >= 0; bindex--) { br = au_sbr(sb, bindex); if (au_br_fhsm(br->br_perm)) { au_fhsm_set_bottom(sb, bindex); @@ -1696,7 +1696,7 @@ int au_opts_mount(struct super_block *sb, struct au_opts *opts) { int err; unsigned int tmp; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_opt *opt; struct au_opt_xino *opt_xino, xino; struct au_sbinfo *sbinfo; @@ -1729,8 +1729,8 @@ int au_opts_mount(struct super_block *sb, struct au_opts *opts) else if (unlikely(err < 0)) goto out; - bend = au_sbend(sb); - if (unlikely(bend < 0)) { + bbot = au_sbbot(sb); + if (unlikely(bbot < 0)) { err = -EINVAL; pr_err("no branches\n"); goto out; @@ -1765,8 +1765,8 @@ int au_opts_mount(struct super_block *sb, struct au_opts *opts) tmp &= AuOptMask_UDBA; sbinfo->si_mntflags &= ~AuOptMask_UDBA; sbinfo->si_mntflags |= tmp; - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); err = au_hnotify_reset_br(tmp, br, br->br_perm); if (unlikely(err)) diff --git a/fs/aufs/plink.c b/fs/aufs/plink.c index b6d63269c..c42734dd4 100644 --- a/fs/aufs/plink.c +++ b/fs/aufs/plink.c @@ -429,13 +429,13 @@ void au_plink_clean(struct super_block *sb, int verbose) static int au_plink_do_half_refresh(struct inode *inode, aufs_bindex_t br_id) { int do_put; - aufs_bindex_t bstart, bend, bindex; + aufs_bindex_t btop, bbot, bindex; do_put = 0; - bstart = au_ibstart(inode); - bend = au_ibend(inode); - if (bstart >= 0) { - for (bindex = bstart; bindex <= bend; bindex++) { + btop = au_ibtop(inode); + bbot = au_ibbot(inode); + if (btop >= 0) { + for (bindex = btop; bindex <= bbot; bindex++) { if (!au_h_iptr(inode, bindex) || au_ii_br_id(inode, bindex) != br_id) continue; @@ -444,7 +444,7 @@ static int au_plink_do_half_refresh(struct inode *inode, aufs_bindex_t br_id) break; } if (do_put) - for (bindex = bstart; bindex <= bend; bindex++) + for (bindex = btop; bindex <= bbot; bindex++) if (au_h_iptr(inode, bindex)) { do_put = 0; break; diff --git a/fs/aufs/posix_acl.c b/fs/aufs/posix_acl.c index d6eeebdec..0ddd46997 100644 --- a/fs/aufs/posix_acl.c +++ b/fs/aufs/posix_acl.c @@ -24,7 +24,7 @@ struct posix_acl *aufs_get_acl(struct inode *inode, int type) if (!(sb->s_flags & MS_POSIXACL)) goto out; - bindex = au_ibstart(inode); + bindex = au_ibtop(inode); h_inode = au_h_iptr(inode, bindex); if (unlikely(!h_inode || ((h_inode->i_mode & S_IFMT) diff --git a/fs/aufs/rdu.c b/fs/aufs/rdu.c index ec0844673..7180f18e6 100644 --- a/fs/aufs/rdu.c +++ b/fs/aufs/rdu.c @@ -109,7 +109,7 @@ out: static int au_rdu(struct file *file, struct aufs_rdu *rdu) { int err; - aufs_bindex_t bend; + aufs_bindex_t bbot; struct au_rdu_arg arg = { .ctx = { .actor = au_rdu_fill @@ -176,12 +176,12 @@ static int au_rdu(struct file *file, struct aufs_rdu *rdu) if (!rdu->blk) rdu->blk = au_dir_size(file, /*dentry*/NULL); } - bend = au_fbstart(file); - if (cookie->bindex < bend) - cookie->bindex = bend; - bend = au_fbend_dir(file); - /* AuDbg("b%d, b%d\n", cookie->bindex, bend); */ - for (; !err && cookie->bindex <= bend; + bbot = au_fbtop(file); + if (cookie->bindex < bbot) + cookie->bindex = bbot; + bbot = au_fbbot_dir(file); + /* AuDbg("b%d, b%d\n", cookie->bindex, bbot); */ + for (; !err && cookie->bindex <= bbot; cookie->bindex++, cookie->h_pos = 0) { h_file = au_hf_dir(file, cookie->bindex); if (!h_file) @@ -202,7 +202,7 @@ static int au_rdu(struct file *file, struct aufs_rdu *rdu) } ii_read_lock_child(inode); - fsstack_copy_attr_atime(inode, au_h_iptr(inode, au_ibstart(inode))); + fsstack_copy_attr_atime(inode, au_h_iptr(inode, au_ibtop(inode))); ii_read_unlock(inode); out_unlock: diff --git a/fs/aufs/rwsem.h b/fs/aufs/rwsem.h index ef50c2ccb..6c0d5a902 100644 --- a/fs/aufs/rwsem.h +++ b/fs/aufs/rwsem.h @@ -21,6 +21,15 @@ struct au_rwsem { #endif }; +#ifdef CONFIG_LOCKDEP +#define au_lockdep_set_name(rw) \ + lockdep_set_class_and_name(&(rw)->rwsem, \ + /*original key*/(rw)->rwsem.dep_map.key, \ + /*name*/#rw) +#else +#define au_lockdep_set_name(rw) do {} while (0) +#endif + #ifdef CONFIG_AUFS_DEBUG #define AuDbgCntInit(rw) do { \ atomic_set(&(rw)->rcnt, 0); \ @@ -28,11 +37,15 @@ struct au_rwsem { smp_mb(); /* atomic set */ \ } while (0) -#define AuDbgRcntInc(rw) atomic_inc(&(rw)->rcnt) -#define AuDbgRcntDec(rw) WARN_ON(atomic_dec_return(&(rw)->rcnt) < 0) -#define AuDbgWcntInc(rw) atomic_inc(&(rw)->wcnt) -#define AuDbgWcntDec(rw) WARN_ON(atomic_dec_return(&(rw)->wcnt) < 0) +#define AuDbgCnt(rw, cnt) atomic_read(&(rw)->cnt) +#define AuDbgCntInc(rw, cnt) atomic_inc(&(rw)->cnt) +#define AuDbgCntDec(rw, cnt) WARN_ON(atomic_dec_return(&(rw)->cnt) < 0) +#define AuDbgRcntInc(rw) AuDbgCntInc(rw, rcnt) +#define AuDbgRcntDec(rw) AuDbgCntDec(rw, rcnt) +#define AuDbgWcntInc(rw) AuDbgCntInc(rw, wcnt) +#define AuDbgWcntDec(rw) AuDbgCntDec(rw, wcnt) #else +#define AuDbgCnt(rw, cnt) 0 #define AuDbgCntInit(rw) do {} while (0) #define AuDbgRcntInc(rw) do {} while (0) #define AuDbgRcntDec(rw) do {} while (0) @@ -41,37 +54,32 @@ struct au_rwsem { #endif /* CONFIG_AUFS_DEBUG */ /* to debug easier, do not make them inlined functions */ -#define AuRwMustNoWaiters(rw) AuDebugOn(!list_empty(&(rw)->rwsem.wait_list)) +#define AuRwMustNoWaiters(rw) AuDebugOn(rwsem_is_contended(&(rw)->rwsem)) /* rwsem_is_locked() is unusable */ -#define AuRwMustReadLock(rw) AuDebugOn(atomic_read(&(rw)->rcnt) <= 0) -#define AuRwMustWriteLock(rw) AuDebugOn(atomic_read(&(rw)->wcnt) <= 0) -#define AuRwMustAnyLock(rw) AuDebugOn(atomic_read(&(rw)->rcnt) <= 0 \ - && atomic_read(&(rw)->wcnt) <= 0) -#define AuRwDestroy(rw) AuDebugOn(atomic_read(&(rw)->rcnt) \ - || atomic_read(&(rw)->wcnt)) - -#define au_rw_class(rw, key) lockdep_set_class(&(rw)->rwsem, key) - -static inline void au_rw_init(struct au_rwsem *rw) -{ - AuDbgCntInit(rw); - init_rwsem(&rw->rwsem); -} - -static inline void au_rw_init_wlock(struct au_rwsem *rw) -{ - au_rw_init(rw); - down_write(&rw->rwsem); - AuDbgWcntInc(rw); -} - -static inline void au_rw_init_wlock_nested(struct au_rwsem *rw, - unsigned int lsc) -{ - au_rw_init(rw); - down_write_nested(&rw->rwsem, lsc); - AuDbgWcntInc(rw); -} +#define AuRwMustReadLock(rw) AuDebugOn(AuDbgCnt(rw, rcnt) <= 0) +#define AuRwMustWriteLock(rw) AuDebugOn(AuDbgCnt(rw, wcnt) <= 0) +#define AuRwMustAnyLock(rw) AuDebugOn(AuDbgCnt(rw, rcnt) <= 0 \ + && AuDbgCnt(rw, wcnt) <= 0) +#define AuRwDestroy(rw) AuDebugOn(AuDbgCnt(rw, rcnt) \ + || AuDbgCnt(rw, wcnt)) + +#define au_rw_init(rw) do { \ + AuDbgCntInit(rw); \ + init_rwsem(&(rw)->rwsem); \ + au_lockdep_set_name(rw); \ + } while (0) + +#define au_rw_init_wlock(rw) do { \ + au_rw_init(rw); \ + down_write(&(rw)->rwsem); \ + AuDbgWcntInc(rw); \ + } while (0) + +#define au_rw_init_wlock_nested(rw, lsc) do { \ + au_rw_init(rw); \ + down_write_nested(&(rw)->rwsem, lsc); \ + AuDbgWcntInc(rw); \ + } while (0) static inline void au_rw_read_lock(struct au_rwsem *rw) { @@ -141,10 +149,9 @@ static inline int au_rw_write_trylock(struct au_rwsem *rw) return ret; } -#undef AuDbgCntInit +#undef AuDbgCntDec #undef AuDbgRcntInc #undef AuDbgRcntDec -#undef AuDbgWcntInc #undef AuDbgWcntDec #define AuSimpleLockRwsemFuncs(prefix, param, rwsem) \ diff --git a/fs/aufs/sbinfo.c b/fs/aufs/sbinfo.c index a9d782e43..aa970593a 100644 --- a/fs/aufs/sbinfo.c +++ b/fs/aufs/sbinfo.c @@ -20,7 +20,12 @@ void au_si_free(struct kobject *kobj) sbinfo = container_of(kobj, struct au_sbinfo, si_kobj); for (i = 0; i < AuPlink_NHASH; i++) AuDebugOn(!hlist_empty(&sbinfo->si_plink[i].head)); - AuDebugOn(atomic_read(&sbinfo->si_nowait.nw_len)); + au_nwt_fin(&sbinfo->si_nowait); + + AuDebugOn(percpu_counter_sum(&sbinfo->si_ninodes)); + percpu_counter_destroy(&sbinfo->si_ninodes); + AuDebugOn(percpu_counter_sum(&sbinfo->si_nfiles)); + percpu_counter_destroy(&sbinfo->si_nfiles); au_rw_write_lock(&sbinfo->si_rwsem); au_br_free(sbinfo); @@ -40,7 +45,6 @@ int au_si_alloc(struct super_block *sb) { int err, i; struct au_sbinfo *sbinfo; - static struct lock_class_key aufs_si; err = -ENOMEM; sbinfo = kzalloc(sizeof(*sbinfo), GFP_NOFS); @@ -58,13 +62,12 @@ int au_si_alloc(struct super_block *sb) au_nwt_init(&sbinfo->si_nowait); au_rw_init_wlock(&sbinfo->si_rwsem); - au_rw_class(&sbinfo->si_rwsem, &aufs_si); mutex_init(&sbinfo->au_si_pid.pid_mtx); - atomic_long_set(&sbinfo->si_ninodes, 0); - atomic_long_set(&sbinfo->si_nfiles, 0); + percpu_counter_init(&sbinfo->si_ninodes, 0, GFP_NOFS); + percpu_counter_init(&sbinfo->si_nfiles, 0, GFP_NOFS); - sbinfo->si_bend = -1; + sbinfo->si_bbot = -1; sbinfo->si_last_br_id = AUFS_BRANCH_MAX / 2; sbinfo->si_wbr_copyup = AuWbrCopyup_Def; @@ -122,7 +125,7 @@ int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr) AuRwMustWriteLock(&sbinfo->si_rwsem); err = -ENOMEM; - sz = sizeof(*brp) * (sbinfo->si_bend + 1); + sz = sizeof(*brp) * (sbinfo->si_bbot + 1); if (unlikely(!sz)) sz = sizeof(*brp); brp = au_kzrealloc(sbinfo->si_branch, sz, sizeof(*brp) * nbr, GFP_NOFS); diff --git a/fs/aufs/super.c b/fs/aufs/super.c index 7928a5031..18190aa5f 100644 --- a/fs/aufs/super.c +++ b/fs/aufs/super.c @@ -23,7 +23,6 @@ static struct inode *aufs_alloc_inode(struct super_block *sb __maybe_unused) if (c) { au_icntnr_init(c); c->vfs_inode.i_version = 1; /* sigen(sb); */ - c->iinfo.ii_hinode = NULL; return &c->vfs_inode; } return NULL; @@ -39,7 +38,8 @@ static void aufs_destroy_inode_cb(struct rcu_head *head) static void aufs_destroy_inode(struct inode *inode) { - au_iinfo_fin(inode); + if (!is_bad_inode(inode)) + au_iinfo_fin(inode); call_rcu(&inode->i_rcu, aufs_destroy_inode_cb); } @@ -77,16 +77,16 @@ out: static int au_show_brs(struct seq_file *seq, struct super_block *sb) { int err; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct path path; struct au_hdentry *hdp; struct au_branch *br; au_br_perm_str_t perm; err = 0; - bend = au_sbend(sb); + bbot = au_sbbot(sb); hdp = au_di(sb->s_root)->di_hdentry; - for (bindex = 0; !err && bindex <= bend; bindex++) { + for (bindex = 0; !err && bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); path.mnt = au_br_mnt(br); path.dentry = hdp[bindex].hd_dentry; @@ -94,7 +94,7 @@ static int au_show_brs(struct seq_file *seq, struct super_block *sb) if (!err) { au_optstr_br_perm(&perm, br->br_perm); seq_printf(seq, "=%s", perm.a); - if (bindex != bend) + if (bindex != bbot) seq_putc(seq, ':'); } } @@ -318,7 +318,7 @@ static int au_statfs_sum(struct super_block *sb, struct kstatfs *buf) int err; long bsize, factor; u64 blocks, bfree, bavail, files, ffree; - aufs_bindex_t bend, bindex, i; + aufs_bindex_t bbot, bindex, i; unsigned char shared; struct path h_path; struct super_block *h_sb; @@ -330,8 +330,8 @@ static int au_statfs_sum(struct super_block *sb, struct kstatfs *buf) blocks = 0; bfree = 0; bavail = 0; - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { h_path.mnt = au_sbr_mnt(sb, bindex); h_sb = h_path.mnt->mnt_sb; shared = 0; @@ -414,14 +414,14 @@ static int aufs_statfs(struct dentry *dentry, struct kstatfs *buf) static int aufs_sync_fs(struct super_block *sb, int wait) { int err, e; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct au_branch *br; struct super_block *h_sb; err = 0; si_noflush_read_lock(sb); - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (!au_br_writable(br->br_perm)) continue; @@ -504,7 +504,7 @@ static unsigned long long au_iarray_cb(struct super_block *sb, void *a, spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, head, i_sb_list) { if (!is_bad_inode(inode) - && au_ii(inode)->ii_bstart >= 0) { + && au_ii(inode)->ii_btop >= 0) { spin_lock(&inode->i_lock); if (atomic_read(&inode->i_count)) { au_igrab(inode); @@ -522,7 +522,7 @@ static unsigned long long au_iarray_cb(struct super_block *sb, void *a, struct inode **au_iarray_alloc(struct super_block *sb, unsigned long long *max) { - *max = atomic_long_read(&au_sbi(sb)->si_ninodes); + *max = au_ninodes(sb); return au_array_alloc(max, au_iarray_cb, sb, &sb->s_inodes); } @@ -681,7 +681,7 @@ static void au_remount_refresh(struct super_block *sb, unsigned int do_idop) { int err, e; unsigned int udba; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct dentry *root; struct inode *inode; struct au_branch *br; @@ -697,8 +697,8 @@ static void au_remount_refresh(struct super_block *sb, unsigned int do_idop) IiMustNoWaiters(inode); udba = au_opt_udba(sb); - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); err = au_hnotify_reset_br(udba, br, br->br_perm); if (unlikely(err)) diff --git a/fs/aufs/super.h b/fs/aufs/super.h index 23d03a067..b8ca14994 100644 --- a/fs/aufs/super.h +++ b/fs/aufs/super.h @@ -91,7 +91,7 @@ struct au_sbinfo { * dirty approach to protect sb->sb_inodes and ->s_files (gone) from * remount. */ - atomic_long_t si_ninodes, si_nfiles; + struct percpu_counter si_ninodes, si_nfiles; /* branch management */ unsigned int si_generation; @@ -99,7 +99,7 @@ struct au_sbinfo { /* see AuSi_ flags */ unsigned char au_si_status; - aufs_bindex_t si_bend; + aufs_bindex_t si_bbot; /* dirty trick to keep br_id plus */ unsigned int si_last_br_id : @@ -285,7 +285,7 @@ extern struct au_wbr_copyup_operations au_wbr_copyup_ops[]; extern struct au_wbr_create_operations au_wbr_create_ops[]; int au_cpdown_dirs(struct dentry *dentry, aufs_bindex_t bdst); int au_wbr_nonopq(struct dentry *dentry, aufs_bindex_t bindex); -int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t bstart); +int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t btop); /* mvdown.c */ int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *arg); @@ -548,10 +548,10 @@ static inline void si_downgrade_lock(struct super_block *sb) /* ---------------------------------------------------------------------- */ -static inline aufs_bindex_t au_sbend(struct super_block *sb) +static inline aufs_bindex_t au_sbbot(struct super_block *sb) { SiMustAnyLock(sb); - return au_sbi(sb)->si_bend; + return au_sbi(sb)->si_bbot; } static inline unsigned int au_mntflags(struct super_block *sb) @@ -566,26 +566,40 @@ static inline unsigned int au_sigen(struct super_block *sb) return au_sbi(sb)->si_generation; } +static inline unsigned long long au_ninodes(struct super_block *sb) +{ + s64 n = percpu_counter_sum(&au_sbi(sb)->si_ninodes); + + BUG_ON(n < 0); + return n; +} + static inline void au_ninodes_inc(struct super_block *sb) { - atomic_long_inc(&au_sbi(sb)->si_ninodes); + percpu_counter_inc(&au_sbi(sb)->si_ninodes); } static inline void au_ninodes_dec(struct super_block *sb) { - AuDebugOn(!atomic_long_read(&au_sbi(sb)->si_ninodes)); - atomic_long_dec(&au_sbi(sb)->si_ninodes); + percpu_counter_dec(&au_sbi(sb)->si_ninodes); +} + +static inline unsigned long long au_nfiles(struct super_block *sb) +{ + s64 n = percpu_counter_sum(&au_sbi(sb)->si_nfiles); + + BUG_ON(n < 0); + return n; } static inline void au_nfiles_inc(struct super_block *sb) { - atomic_long_inc(&au_sbi(sb)->si_nfiles); + percpu_counter_inc(&au_sbi(sb)->si_nfiles); } static inline void au_nfiles_dec(struct super_block *sb) { - AuDebugOn(!atomic_long_read(&au_sbi(sb)->si_nfiles)); - atomic_long_dec(&au_sbi(sb)->si_nfiles); + percpu_counter_dec(&au_sbi(sb)->si_nfiles); } static inline struct au_branch *au_sbr(struct super_block *sb, diff --git a/fs/aufs/sysfs.c b/fs/aufs/sysfs.c index ed42f53d0..0efb77a4e 100644 --- a/fs/aufs/sysfs.c +++ b/fs/aufs/sysfs.c @@ -106,7 +106,7 @@ ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr, ssize_t err; int idx; long l; - aufs_bindex_t bend; + aufs_bindex_t bbot; struct au_sbinfo *sbinfo; struct super_block *sb; struct seq_file *seq; @@ -159,8 +159,8 @@ ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr, err = kstrtol(name, 10, &l); if (!err) { - bend = au_sbend(sb); - if (l <= bend) + bbot = au_sbbot(sb); + if (l <= bbot) err = sysaufs_si_br(seq, sb, (aufs_bindex_t)l, idx); else err = -ENOENT; @@ -186,15 +186,15 @@ static int au_brinfo(struct super_block *sb, union aufs_brinfo __user *arg) { int err; int16_t brid; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; size_t sz; char *buf; struct seq_file *seq; struct au_branch *br; si_read_lock(sb, AuLock_FLUSH); - bend = au_sbend(sb); - err = bend + 1; + bbot = au_sbbot(sb); + err = bbot + 1; if (!arg) goto out; @@ -209,7 +209,7 @@ static int au_brinfo(struct super_block *sb, union aufs_brinfo __user *arg) goto out_buf; sz = sizeof(*arg) - offsetof(union aufs_brinfo, path); - for (bindex = 0; bindex <= bend; bindex++, arg++) { + for (bindex = 0; bindex <= bbot; bindex++, arg++) { err = !access_ok(VERIFY_WRITE, arg, sizeof(*arg)); if (unlikely(err)) break; @@ -288,7 +288,7 @@ void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex) struct kobject *kobj; struct au_brsysfs *br_sysfs; int i; - aufs_bindex_t bend; + aufs_bindex_t bbot; dbgaufs_brs_del(sb, bindex); @@ -296,8 +296,8 @@ void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex) return; kobj = &au_sbi(sb)->si_kobj; - bend = au_sbend(sb); - for (; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); br_sysfs = br->br_sysfs; for (i = 0; i < ARRAY_SIZE(br->br_sysfs); i++) { @@ -310,7 +310,7 @@ void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex) void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex) { int err, i; - aufs_bindex_t bend; + aufs_bindex_t bbot; struct kobject *kobj; struct au_branch *br; struct au_brsysfs *br_sysfs; @@ -321,8 +321,8 @@ void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex) return; kobj = &au_sbi(sb)->si_kobj; - bend = au_sbend(sb); - for (; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); br_sysfs = br->br_sysfs; snprintf(br_sysfs[AuBrSysfs_BR].name, sizeof(br_sysfs->name), diff --git a/fs/aufs/vdir.c b/fs/aufs/vdir.c index f64cc2b7a..feddcc204 100644 --- a/fs/aufs/vdir.c +++ b/fs/aufs/vdir.c @@ -538,7 +538,7 @@ static int au_do_read_vdir(struct fillvdir_arg *arg) int err; unsigned int rdhash; loff_t offset; - aufs_bindex_t bend, bindex, bstart; + aufs_bindex_t bbot, bindex, btop; unsigned char shwh; struct file *hf, *file; struct super_block *sb; @@ -564,9 +564,9 @@ static int au_do_read_vdir(struct fillvdir_arg *arg) shwh = 1; au_fset_fillvdir(arg->flags, SHWH); } - bstart = au_fbstart(file); - bend = au_fbend_dir(file); - for (bindex = bstart; !err && bindex <= bend; bindex++) { + btop = au_fbtop(file); + bbot = au_fbbot_dir(file); + for (bindex = btop; !err && bindex <= bbot; bindex++) { hf = au_hf_dir(file, bindex); if (!hf) continue; @@ -579,7 +579,7 @@ static int au_do_read_vdir(struct fillvdir_arg *arg) arg->bindex = bindex; au_fclr_fillvdir(arg->flags, WHABLE); if (shwh - || (bindex != bend + || (bindex != bbot && au_br_whable(au_sbr_perm(sb, bindex)))) au_fset_fillvdir(arg->flags, WHABLE); do { diff --git a/fs/aufs/vfsub.c b/fs/aufs/vfsub.c index 29e0bbc32..2e54bad6a 100644 --- a/fs/aufs/vfsub.c +++ b/fs/aufs/vfsub.c @@ -125,7 +125,7 @@ int vfsub_atomic_open(struct inode *dir, struct dentry *dentry, goto out; } - atomic_inc(&br->br_count); + au_br_get(br); fsnotify_open(file); out: diff --git a/fs/aufs/wbr_policy.c b/fs/aufs/wbr_policy.c index 994316302..91a010a11 100644 --- a/fs/aufs/wbr_policy.c +++ b/fs/aufs/wbr_policy.c @@ -94,13 +94,13 @@ static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst, struct dentry *h_parent, void *arg) { int err, rerr; - aufs_bindex_t bopq, bstart; + aufs_bindex_t bopq, btop; struct path h_path; struct dentry *parent; struct inode *h_dir, *h_inode, *inode, *dir; unsigned int *flags = arg; - bstart = au_dbstart(dentry); + btop = au_dbtop(dentry); /* dentry is di-locked */ parent = dget_parent(dentry); dir = d_inode(parent); @@ -136,7 +136,7 @@ static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst, } } - err = au_cpdown_attr(&h_path, au_h_dptr(dentry, bstart)); + err = au_cpdown_attr(&h_path, au_h_dptr(dentry, btop)); inode_unlock(h_inode); if (unlikely(err)) goto out_opq; @@ -148,8 +148,8 @@ static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst, } inode = d_inode(dentry); - if (au_ibend(inode) < bdst) - au_set_ibend(inode, bdst); + if (au_ibbot(inode) < bdst) + au_set_ibbot(inode, bdst); au_set_h_iptr(inode, bdst, au_igrab(h_inode), au_hi_flags(inode, /*isdir*/1)); au_fhsm_wrote(dentry->d_sb, bdst, /*force*/0); @@ -179,8 +179,8 @@ out_dir: } out_put: au_set_h_dptr(dentry, bdst, NULL); - if (au_dbend(dentry) == bdst) - au_update_dbend(dentry); + if (au_dbbot(dentry) == bdst) + au_update_dbbot(dentry); out: dput(parent); return err; @@ -252,19 +252,19 @@ static int au_wbr_create_tdp(struct dentry *dentry, unsigned int flags __maybe_unused) { int err; - aufs_bindex_t bstart, bindex; + aufs_bindex_t btop, bindex; struct super_block *sb; struct dentry *parent, *h_parent; sb = dentry->d_sb; - bstart = au_dbstart(dentry); - err = bstart; - if (!au_br_rdonly(au_sbr(sb, bstart))) + btop = au_dbtop(dentry); + err = btop; + if (!au_br_rdonly(au_sbr(sb, btop))) goto out; err = -EROFS; parent = dget_parent(dentry); - for (bindex = au_dbstart(parent); bindex < bstart; bindex++) { + for (bindex = au_dbtop(parent); bindex < btop; bindex++) { h_parent = au_h_dptr(parent, bindex); if (!h_parent || d_is_negative(h_parent)) continue; @@ -278,7 +278,7 @@ static int au_wbr_create_tdp(struct dentry *dentry, /* bottom up here */ if (unlikely(err < 0)) { - err = au_wbr_bu(sb, bstart - 1); + err = au_wbr_bu(sb, btop - 1); if (err >= 0) err = au_wbr_nonopq(dentry, err); } @@ -330,7 +330,7 @@ static int au_wbr_create_init_rr(struct super_block *sb) { int err; - err = au_wbr_bu(sb, au_sbend(sb)); + err = au_wbr_bu(sb, au_sbbot(sb)); atomic_set(&au_sbi(sb)->si_wbr_rr_next, -err); /* less important */ /* smp_mb(); */ @@ -342,7 +342,7 @@ static int au_wbr_create_rr(struct dentry *dentry, unsigned int flags) { int err, nbr; unsigned int u; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct super_block *sb; atomic_t *next; @@ -352,9 +352,9 @@ static int au_wbr_create_rr(struct dentry *dentry, unsigned int flags) sb = dentry->d_sb; next = &au_sbi(sb)->si_wbr_rr_next; - bend = au_sbend(sb); - nbr = bend + 1; - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + nbr = bbot + 1; + for (bindex = 0; bindex <= bbot; bindex++) { if (!au_ftest_wbr(flags, DIR)) { err = atomic_dec_return(next) + 1; /* modulo for 0 is meaningless */ @@ -388,7 +388,7 @@ static void au_mfs(struct dentry *dentry, struct dentry *parent) struct au_branch *br; struct au_wbr_mfs *mfs; struct dentry *h_parent; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; int err; unsigned long long b, bavail; struct path h_path; @@ -409,13 +409,13 @@ static void au_mfs(struct dentry *dentry, struct dentry *parent) mfs->mfsrr_bytes = 0; if (!parent) { bindex = 0; - bend = au_sbend(sb); + bbot = au_sbbot(sb); } else { - bindex = au_dbstart(parent); - bend = au_dbtaildir(parent); + bindex = au_dbtop(parent); + bbot = au_dbtaildir(parent); } - for (; bindex <= bend; bindex++) { + for (; bindex <= bbot; bindex++) { if (parent) { h_parent = au_h_dptr(parent, bindex); if (!h_parent || d_is_negative(h_parent)) @@ -540,7 +540,7 @@ static int au_wbr_create_pmfs(struct dentry *dentry, unsigned int flags) { int err, e2; unsigned long long b; - aufs_bindex_t bindex, bstart, bend; + aufs_bindex_t bindex, btop, bbot; struct super_block *sb; struct dentry *parent, *h_parent; struct au_branch *br; @@ -549,9 +549,9 @@ static int au_wbr_create_pmfs(struct dentry *dentry, unsigned int flags) if (unlikely(err < 0)) goto out; parent = dget_parent(dentry); - bstart = au_dbstart(parent); - bend = au_dbtaildir(parent); - if (bstart == bend) + btop = au_dbtop(parent); + bbot = au_dbtaildir(parent); + if (btop == bbot) goto out_parent; /* success */ e2 = au_wbr_create_mfs(dentry, flags); @@ -564,7 +564,7 @@ static int au_wbr_create_pmfs(struct dentry *dentry, unsigned int flags) b = br->br_wbr->wbr_bytes; AuDbg("b%d, %llu\n", err, b); - for (bindex = bstart; bindex <= bend; bindex++) { + for (bindex = btop; bindex <= bbot; bindex++) { h_parent = au_h_dptr(parent, bindex); if (!h_parent || d_is_negative(h_parent)) continue; @@ -635,15 +635,15 @@ static int au_wbr_copyup_tdp(struct dentry *dentry) static int au_wbr_copyup_bup(struct dentry *dentry) { int err; - aufs_bindex_t bindex, bstart; + aufs_bindex_t bindex, btop; struct dentry *parent, *h_parent; struct super_block *sb; err = -EROFS; sb = dentry->d_sb; parent = dget_parent(dentry); - bstart = au_dbstart(parent); - for (bindex = au_dbstart(dentry); bindex >= bstart; bindex--) { + btop = au_dbtop(parent); + for (bindex = au_dbtop(dentry); bindex >= btop; bindex--) { h_parent = au_h_dptr(parent, bindex); if (!h_parent || d_is_negative(h_parent)) continue; @@ -657,20 +657,20 @@ static int au_wbr_copyup_bup(struct dentry *dentry) /* bottom up here */ if (unlikely(err < 0)) - err = au_wbr_bu(sb, bstart - 1); + err = au_wbr_bu(sb, btop - 1); AuDbg("b%d\n", err); return err; } /* bottom up */ -int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t bstart) +int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t btop) { int err; - err = au_wbr_bu(dentry->d_sb, bstart); + err = au_wbr_bu(dentry->d_sb, btop); AuDbg("b%d\n", err); - if (err > bstart) + if (err > btop) err = au_wbr_nonopq(dentry, err); AuDbg("b%d\n", err); @@ -680,10 +680,10 @@ int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t bstart) static int au_wbr_copyup_bu(struct dentry *dentry) { int err; - aufs_bindex_t bstart; + aufs_bindex_t btop; - bstart = au_dbstart(dentry); - err = au_wbr_do_copyup_bu(dentry, bstart); + btop = au_dbtop(dentry); + err = au_wbr_do_copyup_bu(dentry, btop); return err; } diff --git a/fs/aufs/whout.c b/fs/aufs/whout.c index fdda85eef..78f97ed60 100644 --- a/fs/aufs/whout.c +++ b/fs/aufs/whout.c @@ -585,7 +585,7 @@ static void reinit_br_wh(void *arg) out: if (wbr) atomic_dec(&wbr->wbr_wh_running); - atomic_dec(&a->br->br_count); + au_br_put(a->br); si_write_unlock(a->sb); au_nwt_done(&au_sbi(a->sb)->si_nowait); kfree(arg); @@ -611,11 +611,11 @@ static void kick_reinit_br_wh(struct super_block *sb, struct au_branch *br) */ arg->sb = sb; arg->br = br; - atomic_inc(&br->br_count); + au_br_get(br); wkq_err = au_wkq_nowait(reinit_br_wh, arg, sb, /*flags*/0); if (unlikely(wkq_err)) { atomic_dec(&br->br_wbr->wbr_wh_running); - atomic_dec(&br->br_count); + au_br_put(br); kfree(arg); } do_dec = 0; @@ -904,7 +904,7 @@ out: void au_whtmp_rmdir_free(struct au_whtmp_rmdir *whtmp) { if (whtmp->br) - atomic_dec(&whtmp->br->br_count); + au_br_put(whtmp->br); dput(whtmp->wh_dentry); iput(whtmp->dir); au_nhash_wh_free(&whtmp->whlist); @@ -963,7 +963,7 @@ int au_whtmp_rmdir(struct inode *dir, aufs_bindex_t bindex, } if (!err) { - if (au_ibstart(dir) == bindex) { + if (au_ibtop(dir) == bindex) { /* todo: dir->i_mutex is necessary */ au_cpup_attr_timesizes(dir); if (h_nlink) @@ -1037,7 +1037,7 @@ void au_whtmp_kick_rmdir(struct inode *dir, aufs_bindex_t bindex, sb = dir->i_sb; args->dir = au_igrab(dir); args->br = au_sbr(sb, bindex); - atomic_inc(&args->br->br_count); + au_br_get(args->br); args->wh_dentry = dget(wh_dentry); wkq_err = au_wkq_nowait(call_rmdir_whtmp, args, sb, /*flags*/0); if (unlikely(wkq_err)) { diff --git a/fs/aufs/wkq.c b/fs/aufs/wkq.c index 0f1500e93..65c0137a5 100644 --- a/fs/aufs/wkq.c +++ b/fs/aufs/wkq.c @@ -145,7 +145,7 @@ int au_wkq_nowait(au_wkq_func_t func, void *args, struct super_block *sb, int err; struct au_wkinfo *wkinfo; - atomic_inc(&au_sbi(sb)->si_nowait.nw_len); + percpu_counter_inc(&au_sbi(sb)->si_nowait.nw_len); /* * wkq_func() must free this wkinfo. @@ -175,11 +175,16 @@ int au_wkq_nowait(au_wkq_func_t func, void *args, struct super_block *sb, void au_nwt_init(struct au_nowait_tasks *nwt) { - atomic_set(&nwt->nw_len, 0); - /* smp_mb(); */ /* atomic_set */ + percpu_counter_init(&nwt->nw_len, 0, GFP_NOFS); init_waitqueue_head(&nwt->nw_wq); } +void au_nwt_fin(struct au_nowait_tasks *nwt) +{ + AuDebugOn(percpu_counter_sum(&nwt->nw_len)); + percpu_counter_destroy(&nwt->nw_len); +} + void au_wkq_fin(void) { destroy_workqueue(au_wkq); diff --git a/fs/aufs/wkq.h b/fs/aufs/wkq.h index f6c9b9902..752b9c52d 100644 --- a/fs/aufs/wkq.h +++ b/fs/aufs/wkq.h @@ -20,7 +20,7 @@ struct super_block; * in the next operation, wait for the 'nowait' tasks in system-wide workqueue */ struct au_nowait_tasks { - atomic_t nw_len; + struct percpu_counter nw_len; wait_queue_head_t nw_wq; }; @@ -47,6 +47,7 @@ int au_wkq_do_wait(unsigned int flags, au_wkq_func_t func, void *args); int au_wkq_nowait(au_wkq_func_t func, void *args, struct super_block *sb, unsigned int flags); void au_nwt_init(struct au_nowait_tasks *nwt); +void au_nwt_fin(struct au_nowait_tasks *nwt); int __init au_wkq_init(void); void au_wkq_fin(void); @@ -64,13 +65,14 @@ static inline int au_wkq_wait(au_wkq_func_t func, void *args) static inline void au_nwt_done(struct au_nowait_tasks *nwt) { - if (atomic_dec_and_test(&nwt->nw_len)) + percpu_counter_dec(&nwt->nw_len); + if (!percpu_counter_sum(&nwt->nw_len)) wake_up_all(&nwt->nw_wq); } static inline int au_nwt_flush(struct au_nowait_tasks *nwt) { - wait_event(nwt->nw_wq, !atomic_read(&nwt->nw_len)); + wait_event(nwt->nw_wq, !percpu_counter_sum(&nwt->nw_len)); return 0; } diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c index 2773caedc..c0eb51f3c 100644 --- a/fs/aufs/xino.c +++ b/fs/aufs/xino.c @@ -259,7 +259,7 @@ int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex) int err; unsigned long jiffy; blkcnt_t blocks; - aufs_bindex_t bi, bend; + aufs_bindex_t bi, bbot; struct kstatfs *st; struct au_branch *br; struct file *new_xino, *file; @@ -272,8 +272,8 @@ int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex) goto out; err = -EINVAL; - bend = au_sbend(sb); - if (unlikely(bindex < 0 || bend < bindex)) + bbot = au_sbbot(sb); + if (unlikely(bindex < 0 || bbot < bindex)) goto out_st; br = au_sbr(sb, bindex); file = br->br_xino.xi_file; @@ -302,7 +302,7 @@ int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex) br->br_xino.xi_file = new_xino; h_sb = au_br_sb(br); - for (bi = 0; bi <= bend; bi++) { + for (bi = 0; bi <= bbot; bi++) { if (unlikely(bi == bindex)) continue; br = au_sbr(sb, bi); @@ -357,7 +357,7 @@ static void xino_do_trunc(void *_args) if (unlikely(err)) pr_warn("err b%d, (%d)\n", bindex, err); atomic_dec(&br->br_xino_running); - atomic_dec(&br->br_count); + au_br_put(br); si_write_unlock(sb); au_nwt_done(&au_sbi(sb)->si_nowait); kfree(args); @@ -405,7 +405,7 @@ static void xino_try_trunc(struct super_block *sb, struct au_branch *br) goto out_args; } - atomic_inc(&br->br_count); + au_br_get(br); args->sb = sb; args->br = br; wkq_err = au_wkq_nowait(xino_do_trunc, args, sb, /*flags*/0); @@ -413,7 +413,7 @@ static void xino_try_trunc(struct super_block *sb, struct au_branch *br) return; /* success */ pr_err("wkq %d\n", wkq_err); - atomic_dec(&br->br_count); + au_br_put(br); out_args: kfree(args); @@ -576,7 +576,7 @@ void au_xino_delete_inode(struct inode *inode, const int unlinked) { int err; unsigned int mnt_flags; - aufs_bindex_t bindex, bend, bi; + aufs_bindex_t bindex, bbot, bi; unsigned char try_trunc; struct au_iinfo *iinfo; struct super_block *sb; @@ -585,6 +585,8 @@ void au_xino_delete_inode(struct inode *inode, const int unlinked) struct au_branch *br; vfs_writef_t xwrite; + AuDebugOn(is_bad_inode(inode)); + sb = inode->i_sb; mnt_flags = au_mntflags(sb); if (!au_opt_test(mnt_flags, XINO) @@ -597,18 +599,15 @@ void au_xino_delete_inode(struct inode *inode, const int unlinked) } iinfo = au_ii(inode); - if (!iinfo) - return; - - bindex = iinfo->ii_bstart; + bindex = iinfo->ii_btop; if (bindex < 0) return; xwrite = au_sbi(sb)->si_xwrite; try_trunc = !!au_opt_test(mnt_flags, TRUNC_XINO); - hi = iinfo->ii_hinode + bindex; - bend = iinfo->ii_bend; - for (; bindex <= bend; bindex++, hi++) { + hi = au_hinode(iinfo, bindex); + bbot = iinfo->ii_bbot; + for (; bindex <= bbot; bindex++, hi++) { h_inode = hi->hi_inode; if (!h_inode || (!unlinked && h_inode->i_nlink)) @@ -797,10 +796,10 @@ out: /* * find another branch who is on the same filesystem of the specified - * branch{@btgt}. search until @bend. + * branch{@btgt}. search until @bbot. */ static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt, - aufs_bindex_t bend) + aufs_bindex_t bbot) { aufs_bindex_t bindex; struct super_block *tgt_sb = au_sbr_sb(sb, btgt); @@ -808,7 +807,7 @@ static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt, for (bindex = 0; bindex < btgt; bindex++) if (unlikely(tgt_sb == au_sbr_sb(sb, bindex))) return bindex; - for (bindex++; bindex <= bend; bindex++) + for (bindex++; bindex <= bbot; bindex++) if (unlikely(tgt_sb == au_sbr_sb(sb, bindex))) return bindex; return -1; @@ -827,16 +826,16 @@ int au_xino_br(struct super_block *sb, struct au_branch *br, ino_t h_ino, { int err; ino_t ino; - aufs_bindex_t bend, bindex; + aufs_bindex_t bbot, bindex; struct au_branch *shared_br, *b; struct file *file; struct super_block *tgt_sb; shared_br = NULL; - bend = au_sbend(sb); + bbot = au_sbbot(sb); if (do_test) { tgt_sb = au_br_sb(br); - for (bindex = 0; bindex <= bend; bindex++) { + for (bindex = 0; bindex <= bbot; bindex++) { b = au_sbr(sb, bindex); if (tgt_sb == au_br_sb(b)) { shared_br = b; @@ -924,7 +923,7 @@ out: static int xib_restore(struct super_block *sb) { int err; - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; void *page; err = -ENOMEM; @@ -933,8 +932,8 @@ static int xib_restore(struct super_block *sb) goto out; err = 0; - bend = au_sbend(sb); - for (bindex = 0; !err && bindex <= bend; bindex++) + bbot = au_sbbot(sb); + for (bindex = 0; !err && bindex <= bbot; bindex++) if (!bindex || is_sb_shared(sb, bindex, bindex - 1) < 0) err = do_xib_restore (sb, au_sbr(sb, bindex)->br_xino.xi_file, page); @@ -1076,11 +1075,11 @@ out: /* xino for each branch */ static void xino_clear_br(struct super_block *sb) { - aufs_bindex_t bindex, bend; + aufs_bindex_t bindex, bbot; struct au_branch *br; - bend = au_sbend(sb); - for (bindex = 0; bindex <= bend; bindex++) { + bbot = au_sbbot(sb); + for (bindex = 0; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (!br || !br->br_xino.xi_file) continue; @@ -1094,7 +1093,7 @@ static int au_xino_set_br(struct super_block *sb, struct file *base) { int err; ino_t ino; - aufs_bindex_t bindex, bend, bshared; + aufs_bindex_t bindex, bbot, bshared; struct { struct file *old, *new; } *fpair, *p; @@ -1105,15 +1104,15 @@ static int au_xino_set_br(struct super_block *sb, struct file *base) SiMustWriteLock(sb); err = -ENOMEM; - bend = au_sbend(sb); - fpair = kcalloc(bend + 1, sizeof(*fpair), GFP_NOFS); + bbot = au_sbbot(sb); + fpair = kcalloc(bbot + 1, sizeof(*fpair), GFP_NOFS); if (unlikely(!fpair)) goto out; inode = d_inode(sb->s_root); ino = AUFS_ROOT_INO; writef = au_sbi(sb)->si_xwrite; - for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++) { + for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++) { br = au_sbr(sb, bindex); bshared = is_sb_shared(sb, bindex, bindex - 1); if (bshared >= 0) { @@ -1139,7 +1138,7 @@ static int au_xino_set_br(struct super_block *sb, struct file *base) goto out_pair; } - for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++) { + for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++) { br = au_sbr(sb, bindex); if (br->br_xino.xi_file) fput(br->br_xino.xi_file); @@ -1148,7 +1147,7 @@ static int au_xino_set_br(struct super_block *sb, struct file *base) } out_pair: - for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++) + for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++) if (p->new) fput(p->new); else @@ -1234,12 +1233,12 @@ struct file *au_xino_def(struct super_block *sb) struct au_branch *br; struct super_block *h_sb; struct path path; - aufs_bindex_t bend, bindex, bwr; + aufs_bindex_t bbot, bindex, bwr; br = NULL; - bend = au_sbend(sb); + bbot = au_sbbot(sb); bwr = -1; - for (bindex = 0; bindex <= bend; bindex++) { + for (bindex = 0; bindex <= bbot; bindex++) { br = au_sbr(sb, bindex); if (au_br_writable(br->br_perm) && !au_test_fs_bad_xino(au_br_sb(br))) { -- cgit v1.2.3-54-g00ecf