summaryrefslogtreecommitdiff
path: root/fs/aufs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/aufs')
-rw-r--r--fs/aufs/branch.c16
-rw-r--r--fs/aufs/debug.c2
-rw-r--r--fs/aufs/dentry.c6
-rw-r--r--fs/aufs/finfo.c1
-rw-r--r--fs/aufs/iinfo.c6
-rw-r--r--fs/aufs/inode.h24
-rw-r--r--fs/aufs/super.c22
-rw-r--r--fs/aufs/super.h1
-rw-r--r--fs/aufs/whout.c5
-rw-r--r--fs/aufs/xino.c2
10 files changed, 34 insertions, 51 deletions
diff --git a/fs/aufs/branch.c b/fs/aufs/branch.c
index 72a8ee665..f49142260 100644
--- a/fs/aufs/branch.c
+++ b/fs/aufs/branch.c
@@ -117,7 +117,7 @@ static struct au_branch *au_br_alloc(struct super_block *sb, int new_nbranch,
err = -ENOMEM;
root = sb->s_root;
- add_branch = kmalloc(sizeof(*add_branch), GFP_NOFS);
+ add_branch = kzalloc(sizeof(*add_branch), GFP_NOFS);
if (unlikely(!add_branch))
goto out;
@@ -125,16 +125,14 @@ static struct au_branch *au_br_alloc(struct super_block *sb, int new_nbranch,
if (unlikely(err))
goto out_br;
- add_branch->br_wbr = NULL;
if (au_br_writable(perm)) {
/* may be freed separately at changing the branch permission */
- add_branch->br_wbr = kmalloc(sizeof(*add_branch->br_wbr),
+ add_branch->br_wbr = kzalloc(sizeof(*add_branch->br_wbr),
GFP_NOFS);
if (unlikely(!add_branch->br_wbr))
goto out_hnotify;
}
- add_branch->br_fhsm = NULL;
if (au_br_fhsm(perm)) {
err = au_fhsm_br_alloc(add_branch);
if (unlikely(err))
@@ -339,9 +337,7 @@ static int au_wbr_init(struct au_branch *br, struct super_block *sb,
wbr = br->br_wbr;
au_rw_init(&wbr->wbr_wh_rwsem);
- memset(wbr->wbr_wh, 0, sizeof(wbr->wbr_wh));
atomic_set(&wbr->wbr_wh_running, 0);
- wbr->wbr_bytes = 0;
/*
* a limit for rmdir/rename a dir
@@ -370,12 +366,10 @@ static int au_br_init(struct au_branch *br, struct super_block *sb,
struct inode *h_inode;
err = 0;
- memset(&br->br_xino, 0, sizeof(br->br_xino));
mutex_init(&br->br_xino.xi_nondir_mtx);
br->br_perm = add->perm;
br->br_path = add->path; /* set first, path_get() later */
spin_lock_init(&br->br_dykey_lock);
- memset(br->br_dykey, 0, sizeof(br->br_dykey));
atomic_set(&br->br_count, 0);
atomic_set(&br->br_xino_running, 0);
br->br_id = au_new_br_id(sb);
@@ -583,7 +577,7 @@ static void au_farray_free(struct file **a, unsigned long long max)
for (ull = 0; ull < max; ull++)
if (a[ull])
fput(a[ull]);
- au_array_free(a);
+ kvfree(a);
}
/* ---------------------------------------------------------------------- */
@@ -1333,7 +1327,7 @@ int au_br_mod(struct super_block *sb, struct au_opt_mod *mod, int remount,
if (unlikely(err)) {
rerr = -ENOMEM;
- br->br_wbr = kmalloc(sizeof(*br->br_wbr),
+ br->br_wbr = kzalloc(sizeof(*br->br_wbr),
GFP_NOFS);
if (br->br_wbr)
rerr = au_wbr_init(br, sb, br->br_perm);
@@ -1347,7 +1341,7 @@ int au_br_mod(struct super_block *sb, struct au_opt_mod *mod, int remount,
} else if (au_br_writable(mod->perm)) {
/* ro --> rw */
err = -ENOMEM;
- br->br_wbr = kmalloc(sizeof(*br->br_wbr), GFP_NOFS);
+ br->br_wbr = kzalloc(sizeof(*br->br_wbr), GFP_NOFS);
if (br->br_wbr) {
err = au_wbr_init(br, sb, mod->perm);
if (unlikely(err)) {
diff --git a/fs/aufs/debug.c b/fs/aufs/debug.c
index e553cef1a..42053aa7f 100644
--- a/fs/aufs/debug.c
+++ b/fs/aufs/debug.c
@@ -317,9 +317,7 @@ void au_dpri_sb(struct super_block *sb)
}
a->mnt.mnt_sb = sb;
- a->fake.br_perm = 0;
a->fake.br_path.mnt = &a->mnt;
- a->fake.br_xino.xi_file = NULL;
atomic_set(&a->fake.br_count, 0);
smp_mb(); /* atomic_set */
err = do_pri_br(-1, &a->fake);
diff --git a/fs/aufs/dentry.c b/fs/aufs/dentry.c
index c33fb8318..aad25be88 100644
--- a/fs/aufs/dentry.c
+++ b/fs/aufs/dentry.c
@@ -554,7 +554,9 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo,
struct dentry *dentry;
struct inode *inode;
mode_t mode;
- } orig_h, tmp_h;
+ } orig_h, tmp_h = {
+ .dentry = NULL
+ };
struct au_hdentry *hd;
struct inode *inode, *h_inode;
struct dentry *h_dentry;
@@ -568,10 +570,8 @@ static int au_refresh_by_dinfo(struct dentry *dentry, struct au_dinfo *dinfo,
orig_h.inode = d_inode(orig_h.dentry);
orig_h.mode = orig_h.inode->i_mode & S_IFMT;
}
- memset(&tmp_h, 0, sizeof(tmp_h));
if (tmp->di_bstart >= 0) {
tmp_h.dentry = tmp->di_hdentry[tmp->di_bstart].hd_dentry;
- tmp_h.inode = NULL;
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;
diff --git a/fs/aufs/finfo.c b/fs/aufs/finfo.c
index 05732c97b..e709205b5 100644
--- a/fs/aufs/finfo.c
+++ b/fs/aufs/finfo.c
@@ -62,7 +62,6 @@ struct au_fidir *au_fidir_alloc(struct super_block *sb)
if (fidir) {
fidir->fd_bbot = -1;
fidir->fd_nent = nbr;
- fidir->fd_vdir_cache = NULL;
}
return fidir;
diff --git a/fs/aufs/iinfo.c b/fs/aufs/iinfo.c
index b8efd4586..c604f6987 100644
--- a/fs/aufs/iinfo.c
+++ b/fs/aufs/iinfo.c
@@ -105,13 +105,13 @@ void au_update_iigen(struct inode *inode, int half)
sigen = au_sigen(inode->i_sb);
iinfo = au_ii(inode);
iigen = &iinfo->ii_generation;
- spin_lock(&iinfo->ii_genspin);
+ spin_lock(&iigen->ig_spin);
iigen->ig_generation = sigen;
if (half)
au_ig_fset(iigen->ig_flags, HALF_REFRESHED);
else
au_ig_fclr(iigen->ig_flags, HALF_REFRESHED);
- spin_unlock(&iinfo->ii_genspin);
+ spin_unlock(&iigen->ig_spin);
}
/* it may be called at remount time, too */
@@ -164,7 +164,7 @@ void au_icntnr_init_once(void *_c)
struct au_iinfo *iinfo = &c->iinfo;
static struct lock_class_key aufs_ii;
- spin_lock_init(&iinfo->ii_genspin);
+ 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);
diff --git a/fs/aufs/inode.h b/fs/aufs/inode.h
index a3a187616..31e31f43a 100644
--- a/fs/aufs/inode.h
+++ b/fs/aufs/inode.h
@@ -46,12 +46,12 @@ struct au_hinode {
do { (flags) &= ~AuIG_##name; } while (0)
struct au_iigen {
+ spinlock_t ig_spin;
__u32 ig_generation, ig_flags;
};
struct au_vdir;
struct au_iinfo {
- spinlock_t ii_genspin;
struct au_iigen ii_generation;
struct super_block *ii_hsb1; /* no get/put */
@@ -409,17 +409,19 @@ static inline void au_icntnr_init(struct au_icntnr *c)
#endif
}
-static inline unsigned int au_iigen(struct inode *inode, struct au_iigen *iigen)
+static inline unsigned int au_iigen(struct inode *inode, struct au_iigen *iigen_arg)
{
unsigned int gen;
struct au_iinfo *iinfo;
+ struct au_iigen *iigen;
iinfo = au_ii(inode);
- spin_lock(&iinfo->ii_genspin);
- if (iigen)
- *iigen = iinfo->ii_generation;
- gen = iinfo->ii_generation.ig_generation;
- spin_unlock(&iinfo->ii_genspin);
+ iigen = &iinfo->ii_generation;
+ spin_lock(&iigen->ig_spin);
+ if (iigen_arg)
+ *iigen_arg = *iigen;
+ gen = iigen->ig_generation;
+ spin_unlock(&iigen->ig_spin);
return gen;
}
@@ -439,11 +441,13 @@ static inline int au_test_higen(struct inode *inode, struct inode *h_inode)
static inline void au_iigen_dec(struct inode *inode)
{
struct au_iinfo *iinfo;
+ struct au_iigen *iigen;
iinfo = au_ii(inode);
- spin_lock(&iinfo->ii_genspin);
- iinfo->ii_generation.ig_generation--;
- spin_unlock(&iinfo->ii_genspin);
+ iigen = &iinfo->ii_generation;
+ spin_lock(&iigen->ig_spin);
+ iigen->ig_generation--;
+ spin_unlock(&iigen->ig_spin);
}
static inline int au_iigen_test(struct inode *inode, unsigned int sigen)
diff --git a/fs/aufs/super.c b/fs/aufs/super.c
index 3fe10d35d..98cfd64dd 100644
--- a/fs/aufs/super.c
+++ b/fs/aufs/super.c
@@ -456,16 +456,6 @@ static void aufs_put_super(struct super_block *sb)
/* ---------------------------------------------------------------------- */
-void au_array_free(void *array)
-{
- if (array) {
- if (!is_vmalloc_addr(array))
- kfree(array);
- else
- vfree(array);
- }
-}
-
void *au_array_alloc(unsigned long long *hint, au_arraycb_t cb,
struct super_block *sb, void *arg)
{
@@ -542,7 +532,7 @@ void au_iarray_free(struct inode **a, unsigned long long max)
for (ull = 0; ull < max; ull++)
iput(a[ull]);
- au_array_free(a);
+ kvfree(a);
}
/* ---------------------------------------------------------------------- */
@@ -767,7 +757,9 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
{
int err, do_dx;
unsigned int mntflags;
- struct au_opts opts;
+ struct au_opts opts = {
+ .opt = NULL
+ };
struct dentry *root;
struct inode *inode;
struct au_sbinfo *sbinfo;
@@ -785,7 +777,6 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
}
err = -ENOMEM;
- memset(&opts, 0, sizeof(opts));
opts.opt = (void *)__get_free_page(GFP_NOFS);
if (unlikely(!opts.opt))
goto out;
@@ -886,7 +877,9 @@ static int aufs_fill_super(struct super_block *sb, void *raw_data,
int silent __maybe_unused)
{
int err;
- struct au_opts opts;
+ struct au_opts opts = {
+ .opt = NULL
+ };
struct au_sbinfo *sbinfo;
struct dentry *root;
struct inode *inode;
@@ -899,7 +892,6 @@ static int aufs_fill_super(struct super_block *sb, void *raw_data,
}
err = -ENOMEM;
- memset(&opts, 0, sizeof(opts));
opts.opt = (void *)__get_free_page(GFP_NOFS);
if (unlikely(!opts.opt))
goto out;
diff --git a/fs/aufs/super.h b/fs/aufs/super.h
index e0f588ef2..d15172962 100644
--- a/fs/aufs/super.h
+++ b/fs/aufs/super.h
@@ -266,7 +266,6 @@ extern struct file_system_type aufs_fs_type;
struct inode *au_iget_locked(struct super_block *sb, ino_t ino);
typedef unsigned long long (*au_arraycb_t)(struct super_block *sb, void *array,
unsigned long long max, void *arg);
-void au_array_free(void *array);
void *au_array_alloc(unsigned long long *hint, au_arraycb_t cb,
struct super_block *sb, void *arg);
struct inode **au_iarray_alloc(struct super_block *sb, unsigned long long *max);
diff --git a/fs/aufs/whout.c b/fs/aufs/whout.c
index a7f160efb..05ba0857b 100644
--- a/fs/aufs/whout.c
+++ b/fs/aufs/whout.c
@@ -881,15 +881,12 @@ struct au_whtmp_rmdir *au_whtmp_rmdir_alloc(struct super_block *sb, gfp_t gfp)
SiMustAnyLock(sb);
- whtmp = kmalloc(sizeof(*whtmp), gfp);
+ whtmp = kzalloc(sizeof(*whtmp), gfp);
if (unlikely(!whtmp)) {
whtmp = ERR_PTR(-ENOMEM);
goto out;
}
- whtmp->dir = NULL;
- whtmp->br = NULL;
- whtmp->wh_dentry = NULL;
/* no estimation for dir size */
rdhash = au_sbi(sb)->si_rdhash;
if (!rdhash)
diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c
index f377ce591..90de8c56d 100644
--- a/fs/aufs/xino.c
+++ b/fs/aufs/xino.c
@@ -245,7 +245,7 @@ int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex)
struct au_xino_lock_dir ldir;
err = -ENOMEM;
- st = kzalloc(sizeof(*st), GFP_NOFS);
+ st = kmalloc(sizeof(*st), GFP_NOFS);
if (unlikely(!st))
goto out;