Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tidy up around finish_automount()

do_add_mount() and mnt_clear_expiry() are not needed outside of
namespace.c anymore, now that namei has finish_automount() to
use.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro b1e75df4 15f9a3f3

+18 -30
-2
fs/internal.h
··· 71 71 extern void umount_tree(struct vfsmount *, int, struct list_head *); 72 72 extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); 73 73 extern int finish_automount(struct vfsmount *, struct path *); 74 - extern int do_add_mount(struct vfsmount *, struct path *, int); 75 - extern void mnt_clear_expiry(struct vfsmount *); 76 74 77 75 extern void mnt_make_longterm(struct vfsmount *); 78 76 extern void mnt_make_shortterm(struct vfsmount *);
+18 -28
fs/namespace.c
··· 1872 1872 return err; 1873 1873 } 1874 1874 1875 + static int do_add_mount(struct vfsmount *, struct path *, int); 1876 + 1875 1877 /* 1876 1878 * create a new mount for userspace and request it to be added into the 1877 1879 * namespace's tree ··· 1911 1909 1912 1910 if (m->mnt_sb == path->mnt->mnt_sb && 1913 1911 m->mnt_root == path->dentry) { 1914 - mnt_clear_expiry(m); 1915 - mntput(m); 1916 - mntput(m); 1917 - return -ELOOP; 1912 + err = -ELOOP; 1913 + goto fail; 1918 1914 } 1919 1915 1920 1916 err = do_add_mount(m, path, path->mnt->mnt_flags | MNT_SHRINKABLE); 1921 - if (err) { 1922 - mnt_clear_expiry(m); 1923 - mntput(m); 1924 - mntput(m); 1917 + if (!err) 1918 + return 0; 1919 + fail: 1920 + /* remove m from any expiration list it may be on */ 1921 + if (!list_empty(&m->mnt_expire)) { 1922 + down_write(&namespace_sem); 1923 + br_write_lock(vfsmount_lock); 1924 + list_del_init(&m->mnt_expire); 1925 + br_write_unlock(vfsmount_lock); 1926 + up_write(&namespace_sem); 1925 1927 } 1928 + mntput(m); 1929 + mntput(m); 1926 1930 return err; 1927 1931 } 1928 1932 1929 1933 /* 1930 1934 * add a mount into a namespace's mount tree 1931 1935 */ 1932 - int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) 1936 + static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) 1933 1937 { 1934 1938 int err; 1935 1939 ··· 1962 1954 goto unlock; 1963 1955 1964 1956 newmnt->mnt_flags = mnt_flags; 1965 - if ((err = graft_tree(newmnt, path))) 1966 - goto unlock; 1967 - 1968 - up_write(&namespace_sem); 1969 - return 0; 1957 + err = graft_tree(newmnt, path); 1970 1958 1971 1959 unlock: 1972 1960 up_write(&namespace_sem); ··· 1985 1981 up_write(&namespace_sem); 1986 1982 } 1987 1983 EXPORT_SYMBOL(mnt_set_expiry); 1988 - 1989 - /* 1990 - * Remove a vfsmount from any expiration list it may be on 1991 - */ 1992 - void mnt_clear_expiry(struct vfsmount *mnt) 1993 - { 1994 - if (!list_empty(&mnt->mnt_expire)) { 1995 - down_write(&namespace_sem); 1996 - br_write_lock(vfsmount_lock); 1997 - list_del_init(&mnt->mnt_expire); 1998 - br_write_unlock(vfsmount_lock); 1999 - up_write(&namespace_sem); 2000 - } 2001 - } 2002 1984 2003 1985 /* 2004 1986 * process a list of expirable mountpoints with the intent of discarding any