diff options
author | Ram Pai <linuxram@us.ibm.com> | 2005-11-07 17:16:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 21:18:10 -0500 |
commit | 5b83d2c5c0afcf5a3517cf00d9ceb41b8345e01b (patch) | |
tree | ae92239c963b2d3cb12e2a561913451a77752d55 /fs | |
parent | b58fed8b1959d6b9e4c951a54adc8960e1401b18 (diff) |
[PATCH] sanitize the interface of graft_tree().
Old semantics: graft_tree() grabs a reference on the vfsmount before
returning success.
New one: graft_tree() leaves that to caller.
All the callers of graft_tree() immediately dropped that reference
anyway. Changing the interface takes care of this unnecessary overhead.
Idea proposed by Al Viro.
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namespace.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 685687dccbf1..dfeeab964e84 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -650,7 +650,6 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd) | |||
650 | attach_mnt(mnt, nd); | 650 | attach_mnt(mnt, nd); |
651 | list_add_tail(&head, &mnt->mnt_list); | 651 | list_add_tail(&head, &mnt->mnt_list); |
652 | list_splice(&head, current->namespace->list.prev); | 652 | list_splice(&head, current->namespace->list.prev); |
653 | mntget(mnt); | ||
654 | err = 0; | 653 | err = 0; |
655 | touch_namespace(current->namespace); | 654 | touch_namespace(current->namespace); |
656 | } | 655 | } |
@@ -702,8 +701,7 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | |||
702 | spin_lock(&vfsmount_lock); | 701 | spin_lock(&vfsmount_lock); |
703 | umount_tree(mnt); | 702 | umount_tree(mnt); |
704 | spin_unlock(&vfsmount_lock); | 703 | spin_unlock(&vfsmount_lock); |
705 | } else | 704 | } |
706 | mntput(mnt); | ||
707 | 705 | ||
708 | out: | 706 | out: |
709 | up_write(¤t->namespace->sem); | 707 | up_write(¤t->namespace->sem); |
@@ -857,15 +855,17 @@ int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, | |||
857 | goto unlock; | 855 | goto unlock; |
858 | 856 | ||
859 | newmnt->mnt_flags = mnt_flags; | 857 | newmnt->mnt_flags = mnt_flags; |
860 | newmnt->mnt_namespace = current->namespace; | 858 | if ((err = graft_tree(newmnt, nd))) |
861 | err = graft_tree(newmnt, nd); | 859 | goto unlock; |
862 | 860 | ||
863 | if (err == 0 && fslist) { | 861 | if (fslist) { |
864 | /* add to the specified expiration list */ | 862 | /* add to the specified expiration list */ |
865 | spin_lock(&vfsmount_lock); | 863 | spin_lock(&vfsmount_lock); |
866 | list_add_tail(&newmnt->mnt_expire, fslist); | 864 | list_add_tail(&newmnt->mnt_expire, fslist); |
867 | spin_unlock(&vfsmount_lock); | 865 | spin_unlock(&vfsmount_lock); |
868 | } | 866 | } |
867 | up_write(¤t->namespace->sem); | ||
868 | return 0; | ||
869 | 869 | ||
870 | unlock: | 870 | unlock: |
871 | up_write(¤t->namespace->sem); | 871 | up_write(¤t->namespace->sem); |