summaryrefslogtreecommitdiff
path: root/fs/aufs/xino.c
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-06-10 05:30:17 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-06-10 05:30:17 -0300
commitd635711daa98be86d4c7fd01499c34f566b54ccb (patch)
treeaa5cc3760a27c3d57146498cb82fa549547de06c /fs/aufs/xino.c
parentc91265cd0efb83778f015b4d4b1129bd2cfd075e (diff)
Linux-libre 4.6.2-gnu
Diffstat (limited to 'fs/aufs/xino.c')
-rw-r--r--fs/aufs/xino.c71
1 files changed, 35 insertions, 36 deletions
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))) {