diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-25 07:53:09 +0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-04 07:57:06 +0400 |
commit | 68e8a9feab251f9d3c8fd9e9893c97843bcd4bd0 (patch) | |
tree | 22fac61a982587cd53ccf05513fbe4ffe60c860d /fs | |
parent | 83adc7532229f1909cf37c429780f02f06fe05ee (diff) | |
download | linux-68e8a9feab251f9d3c8fd9e9893c97843bcd4bd0.tar.xz |
vfs: all counters taken to struct mount
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/mount.h | 12 | ||||
-rw-r--r-- | fs/namespace.c | 40 |
2 files changed, 32 insertions, 20 deletions
diff --git a/fs/mount.h b/fs/mount.h index 853738f5897f..452ae41e0131 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -1,10 +1,22 @@ #include <linux/mount.h> +struct mnt_pcp { + int mnt_count; + int mnt_writers; +}; + struct mount { struct list_head mnt_hash; struct mount *mnt_parent; struct dentry *mnt_mountpoint; struct vfsmount mnt; +#ifdef CONFIG_SMP + struct mnt_pcp __percpu *mnt_pcp; + atomic_t mnt_longterm; /* how many of the refs are longterm */ +#else + int mnt_count; + int mnt_writers; +#endif }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index a13165c871c2..3fdd30add4f9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -144,10 +144,10 @@ void mnt_release_group_id(struct mount *mnt) static inline void mnt_add_count(struct mount *mnt, int n) { #ifdef CONFIG_SMP - this_cpu_add(mnt->mnt.mnt_pcp->mnt_count, n); + this_cpu_add(mnt->mnt_pcp->mnt_count, n); #else preempt_disable(); - mnt->mnt.mnt_count += n; + mnt->mnt_count += n; preempt_enable(); #endif } @@ -162,12 +162,12 @@ unsigned int mnt_get_count(struct mount *mnt) int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_count; + count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; } return count; #else - return mnt->mnt.mnt_count; + return mnt->mnt_count; #endif } @@ -189,14 +189,14 @@ static struct mount *alloc_vfsmnt(const char *name) } #ifdef CONFIG_SMP - mnt->mnt_pcp = alloc_percpu(struct mnt_pcp); - if (!mnt->mnt_pcp) + p->mnt_pcp = alloc_percpu(struct mnt_pcp); + if (!p->mnt_pcp) goto out_free_devname; - this_cpu_add(mnt->mnt_pcp->mnt_count, 1); + this_cpu_add(p->mnt_pcp->mnt_count, 1); #else - mnt->mnt_count = 1; - mnt->mnt_writers = 0; + p->mnt_count = 1; + p->mnt_writers = 0; #endif INIT_LIST_HEAD(&p->mnt_hash); @@ -256,18 +256,18 @@ EXPORT_SYMBOL_GPL(__mnt_is_readonly); static inline void mnt_inc_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_inc(mnt->mnt.mnt_pcp->mnt_writers); + this_cpu_inc(mnt->mnt_pcp->mnt_writers); #else - mnt->mnt.mnt_writers++; + mnt->mnt_writers++; #endif } static inline void mnt_dec_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_dec(mnt->mnt.mnt_pcp->mnt_writers); + this_cpu_dec(mnt->mnt_pcp->mnt_writers); #else - mnt->mnt.mnt_writers--; + mnt->mnt_writers--; #endif } @@ -278,7 +278,7 @@ static unsigned int mnt_get_writers(struct mount *mnt) int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_writers; + count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_writers; } return count; @@ -454,7 +454,7 @@ static void free_vfsmnt(struct mount *mnt) kfree(mnt->mnt.mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP - free_percpu(mnt->mnt.mnt_pcp); + free_percpu(mnt->mnt_pcp); #endif kmem_cache_free(mnt_cache, mnt); } @@ -594,7 +594,7 @@ static void attach_mnt(struct mount *mnt, struct path *path) static inline void __mnt_make_longterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_inc(&mnt->mnt.mnt_longterm); + atomic_inc(&mnt->mnt_longterm); #endif } @@ -602,7 +602,7 @@ static inline void __mnt_make_longterm(struct mount *mnt) static inline void __mnt_make_shortterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_dec(&mnt->mnt.mnt_longterm); + atomic_dec(&mnt->mnt_longterm); #endif } @@ -769,7 +769,7 @@ static void mntput_no_expire(struct vfsmount *m) put_again: #ifdef CONFIG_SMP br_read_lock(vfsmount_lock); - if (likely(atomic_read(&mnt->mnt.mnt_longterm))) { + if (likely(atomic_read(&mnt->mnt_longterm))) { mnt_add_count(mnt, -1); br_read_unlock(vfsmount_lock); return; @@ -2375,10 +2375,10 @@ void mnt_make_shortterm(struct vfsmount *m) { #ifdef CONFIG_SMP struct mount *mnt = real_mount(m); - if (atomic_add_unless(&mnt->mnt.mnt_longterm, -1, 1)) + if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) return; br_write_lock(vfsmount_lock); - atomic_dec(&mnt->mnt.mnt_longterm); + atomic_dec(&mnt->mnt_longterm); br_write_unlock(vfsmount_lock); #endif } |