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

Configure Feed

Select the types of activity you want to include in your feed.

open_detached_copy(): separate creation of namespace into helper

... and convert the helper to use of a guard(namespace_excl)

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 57a7b5b0 71cf10ce

+15 -9
+15 -9
fs/namespace.c
··· 3047 3047 return err; 3048 3048 } 3049 3049 3050 - static struct file *open_detached_copy(struct path *path, bool recursive) 3050 + static struct mnt_namespace *get_detached_copy(const struct path *path, bool recursive) 3051 3051 { 3052 3052 struct mnt_namespace *ns, *mnt_ns = current->nsproxy->mnt_ns, *src_mnt_ns; 3053 3053 struct user_namespace *user_ns = mnt_ns->user_ns; 3054 3054 struct mount *mnt, *p; 3055 - struct file *file; 3056 3055 3057 3056 ns = alloc_mnt_ns(user_ns, true); 3058 3057 if (IS_ERR(ns)) 3059 - return ERR_CAST(ns); 3058 + return ns; 3060 3059 3061 - namespace_lock(); 3060 + guard(namespace_excl)(); 3062 3061 3063 3062 /* 3064 3063 * Record the sequence number of the source mount namespace. ··· 3074 3075 3075 3076 mnt = __do_loopback(path, recursive); 3076 3077 if (IS_ERR(mnt)) { 3077 - namespace_unlock(); 3078 - free_mnt_ns(ns); 3078 + emptied_ns = ns; 3079 3079 return ERR_CAST(mnt); 3080 3080 } 3081 3081 ··· 3083 3085 ns->nr_mounts++; 3084 3086 } 3085 3087 ns->root = mnt; 3086 - mntget(&mnt->mnt); 3087 - namespace_unlock(); 3088 + return ns; 3089 + } 3090 + 3091 + static struct file *open_detached_copy(struct path *path, bool recursive) 3092 + { 3093 + struct mnt_namespace *ns = get_detached_copy(path, recursive); 3094 + struct file *file; 3095 + 3096 + if (IS_ERR(ns)) 3097 + return ERR_CAST(ns); 3088 3098 3089 3099 mntput(path->mnt); 3090 - path->mnt = &mnt->mnt; 3100 + path->mnt = mntget(&ns->root->mnt); 3091 3101 file = dentry_open(path, O_PATH, current_cred()); 3092 3102 if (IS_ERR(file)) 3093 3103 dissolve_on_fput(path->mnt);