aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-09 00:59:08 -0400
committerZiyan <jaraidaniel@gmail.com>2016-04-03 14:55:49 +0200
commit9e2fa431613b6e8100fc4c517dbf66f535e097eb (patch)
tree1314937b12fca5be1cc27293cb3d553acad87c70 /fs
parente695969cd545652b59f34992ef6538cf1a49da16 (diff)
downloadkernel_samsung_tuna-9e2fa431613b6e8100fc4c517dbf66f535e097eb.zip
kernel_samsung_tuna-9e2fa431613b6e8100fc4c517dbf66f535e097eb.tar.gz
kernel_samsung_tuna-9e2fa431613b6e8100fc4c517dbf66f535e097eb.tar.bz2
get rid of ->mnt_longterm
it's enough to set ->mnt_ns of internal vfsmounts to something distinct from all struct mnt_namespace out there; then we can just use the check for ->mnt_ns != NULL in the fast path of mntput_no_expire() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> (cherry picked from commit f7a99c5b7c8bd3d3f533c8b38274e33f3da9096e)
Diffstat (limited to 'fs')
-rw-r--r--fs/fs_struct.c34
-rw-r--r--fs/internal.h3
-rw-r--r--fs/namespace.c46
3 files changed, 14 insertions, 69 deletions
diff --git a/fs/fs_struct.c b/fs/fs_struct.c
index 78b519c..251ebe8 100644
--- a/fs/fs_struct.c
+++ b/fs/fs_struct.c
@@ -6,18 +6,6 @@
#include <linux/fs_struct.h>
#include "internal.h"
-static inline void path_get_longterm(struct path *path)
-{
- path_get(path);
- mnt_make_longterm(path->mnt);
-}
-
-static inline void path_put_longterm(struct path *path)
-{
- mnt_make_shortterm(path->mnt);
- path_put(path);
-}
-
/*
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block.
@@ -30,11 +18,11 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
write_seqcount_begin(&fs->seq);
old_root = fs->root;
fs->root = *path;
- path_get_longterm(path);
+ path_get(path);
write_seqcount_end(&fs->seq);
spin_unlock(&fs->lock);
if (old_root.dentry)
- path_put_longterm(&old_root);
+ path_put(&old_root);
}
/*
@@ -49,12 +37,12 @@ void set_fs_pwd(struct fs_struct *fs, struct path *path)
write_seqcount_begin(&fs->seq);
old_pwd = fs->pwd;
fs->pwd = *path;
- path_get_longterm(path);
+ path_get(path);
write_seqcount_end(&fs->seq);
spin_unlock(&fs->lock);
if (old_pwd.dentry)
- path_put_longterm(&old_pwd);
+ path_put(&old_pwd);
}
void chroot_fs_refs(struct path *old_root, struct path *new_root)
@@ -72,13 +60,13 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
write_seqcount_begin(&fs->seq);
if (fs->root.dentry == old_root->dentry
&& fs->root.mnt == old_root->mnt) {
- path_get_longterm(new_root);
+ path_get(new_root);
fs->root = *new_root;
count++;
}
if (fs->pwd.dentry == old_root->dentry
&& fs->pwd.mnt == old_root->mnt) {
- path_get_longterm(new_root);
+ path_get(new_root);
fs->pwd = *new_root;
count++;
}
@@ -89,13 +77,13 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
while (count--)
- path_put_longterm(old_root);
+ path_put(old_root);
}
void free_fs_struct(struct fs_struct *fs)
{
- path_put_longterm(&fs->root);
- path_put_longterm(&fs->pwd);
+ path_put(&fs->root);
+ path_put(&fs->pwd);
kmem_cache_free(fs_cachep, fs);
}
@@ -131,9 +119,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
spin_lock(&old->lock);
fs->root = old->root;
- path_get_longterm(&fs->root);
+ path_get(&fs->root);
fs->pwd = old->pwd;
- path_get_longterm(&fs->pwd);
+ path_get(&fs->pwd);
spin_unlock(&old->lock);
}
return fs;
diff --git a/fs/internal.h b/fs/internal.h
index 552ca03..4e194bb 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -72,9 +72,6 @@ extern void umount_tree(struct vfsmount *, int, struct list_head *);
extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int);
extern int finish_automount(struct vfsmount *, struct path *);
-extern void mnt_make_longterm(struct vfsmount *);
-extern void mnt_make_shortterm(struct vfsmount *);
-
extern void __init mnt_init(void);
extern struct lglock vfsmount_lock;
diff --git a/fs/namespace.c b/fs/namespace.c
index 33ad187..0fd3f8a 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -609,21 +609,6 @@ static void attach_mnt(struct vfsmount *mnt, struct path *path)
list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts);
}
-static inline void __mnt_make_longterm(struct vfsmount *mnt)
-{
-#ifdef CONFIG_SMP
- atomic_inc(&mnt->mnt_longterm);
-#endif
-}
-
-/* needs vfsmount lock for write */
-static inline void __mnt_make_shortterm(struct vfsmount *mnt)
-{
-#ifdef CONFIG_SMP
- atomic_dec(&mnt->mnt_longterm);
-#endif
-}
-
/*
* vfsmount lock must be held for write
*/
@@ -637,10 +622,8 @@ static void commit_tree(struct vfsmount *mnt)
BUG_ON(parent == mnt);
list_add_tail(&head, &mnt->mnt_list);
- list_for_each_entry(m, &head, mnt_list) {
+ list_for_each_entry(m, &head, mnt_list)
m->mnt_ns = n;
- __mnt_make_longterm(m);
- }
list_splice(&head, n->list.prev);
@@ -785,7 +768,8 @@ static void mntput_no_expire(struct vfsmount *mnt)
put_again:
#ifdef CONFIG_SMP
br_read_lock(&vfsmount_lock);
- if (likely(atomic_read(&mnt->mnt_longterm))) {
+ if (likely(mnt->mnt_ns)) {
+ /* shouldn't be the last one */
mnt_dec_count(mnt);
br_read_unlock(&vfsmount_lock);
return;
@@ -1250,8 +1234,6 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
list_del_init(&p->mnt_expire);
list_del_init(&p->mnt_list);
__touch_mnt_namespace(p->mnt_ns);
- if (p->mnt_ns)
- __mnt_make_shortterm(p);
p->mnt_ns = NULL;
list_del_init(&p->mnt_child);
if (p->mnt_parent != p) {
@@ -2375,22 +2357,6 @@ static struct mnt_namespace *alloc_mnt_ns(void)
return new_ns;
}
-void mnt_make_longterm(struct vfsmount *mnt)
-{
- __mnt_make_longterm(mnt);
-}
-
-void mnt_make_shortterm(struct vfsmount *mnt)
-{
-#ifdef CONFIG_SMP
- if (atomic_add_unless(&mnt->mnt_longterm, -1, 1))
- return;
- br_write_lock(&vfsmount_lock);
- atomic_dec(&mnt->mnt_longterm);
- br_write_unlock(&vfsmount_lock);
-#endif
-}
-
/*
* Allocate a new namespace structure and populate it with contents
* copied from the namespace of the passed in task structure.
@@ -2428,18 +2394,13 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
q = new_ns->root;
while (p) {
q->mnt_ns = new_ns;
- __mnt_make_longterm(q);
if (fs) {
if (p == fs->root.mnt) {
fs->root.mnt = mntget(q);
- __mnt_make_longterm(q);
- mnt_make_shortterm(p);
rootmnt = p;
}
if (p == fs->pwd.mnt) {
fs->pwd.mnt = mntget(q);
- __mnt_make_longterm(q);
- mnt_make_shortterm(p);
pwdmnt = p;
}
}
@@ -2484,7 +2445,6 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
new_ns = alloc_mnt_ns();
if (!IS_ERR(new_ns)) {
mnt->mnt_ns = new_ns;
- __mnt_make_longterm(mnt);
new_ns->root = mnt;
list_add(&new_ns->list, &new_ns->root->mnt_list);
}