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.

mount: simplify __do_loopback()

Remove the OPEN_TREE_NAMESPACE flag checking from __do_loopback() and
instead have callers pass CL_COPY_MNT_NS_FILE directly in copy_flags.

Link: https://patch.msgid.link/20260122-work-fsmount-namespace-v1-2-5ef0a886e646@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+9 -22
+9 -22
fs/namespace.c
··· 2958 2958 } 2959 2959 2960 2960 static struct mount *__do_loopback(const struct path *old_path, 2961 - unsigned int flags, unsigned int copy_flags) 2961 + bool recurse, unsigned int copy_flags) 2962 2962 { 2963 2963 struct mount *old = real_mount(old_path->mnt); 2964 - bool recurse = flags & AT_RECURSIVE; 2965 2964 2966 2965 if (IS_MNT_UNBINDABLE(old)) 2967 2966 return ERR_PTR(-EINVAL); ··· 2970 2971 2971 2972 if (!recurse && __has_locked_children(old, old_path->dentry)) 2972 2973 return ERR_PTR(-EINVAL); 2973 - 2974 - /* 2975 - * When creating a new mount namespace we don't want to copy over 2976 - * mounts of mount namespaces to avoid the risk of cycles and also to 2977 - * minimize the default complex interdependencies between mount 2978 - * namespaces. 2979 - * 2980 - * We could ofc just check whether all mount namespace files aren't 2981 - * creating cycles but really let's keep this simple. 2982 - */ 2983 - if (!(flags & OPEN_TREE_NAMESPACE)) 2984 - copy_flags |= CL_COPY_MNT_NS_FILE; 2985 2974 2986 2975 if (recurse) 2987 2976 return copy_tree(old, old_path->dentry, copy_flags); ··· 2985 2998 { 2986 2999 struct path old_path __free(path_put) = {}; 2987 3000 struct mount *mnt = NULL; 2988 - unsigned int flags = recurse ? AT_RECURSIVE : 0; 2989 3001 int err; 2990 3002 2991 3003 if (!old_name || !*old_name) ··· 3003 3017 if (!check_mnt(mp.parent)) 3004 3018 return -EINVAL; 3005 3019 3006 - mnt = __do_loopback(&old_path, flags, 0); 3020 + mnt = __do_loopback(&old_path, recurse, CL_COPY_MNT_NS_FILE); 3007 3021 if (IS_ERR(mnt)) 3008 3022 return PTR_ERR(mnt); 3009 3023 ··· 3041 3055 ns->seq_origin = src_mnt_ns->ns.ns_id; 3042 3056 } 3043 3057 3044 - mnt = __do_loopback(path, flags, 0); 3058 + mnt = __do_loopback(path, (flags & AT_RECURSIVE), CL_COPY_MNT_NS_FILE); 3045 3059 if (IS_ERR(mnt)) { 3046 3060 emptied_ns = ns; 3047 3061 return ERR_CAST(mnt); ··· 3073 3087 return file; 3074 3088 } 3075 3089 3076 - static struct mnt_namespace *create_new_namespace(struct path *path, unsigned int flags) 3090 + static struct mnt_namespace *create_new_namespace(struct path *path, 3091 + bool recurse) 3077 3092 { 3078 3093 struct mnt_namespace *ns = current->nsproxy->mnt_ns; 3079 3094 struct user_namespace *user_ns = current_user_ns(); ··· 3122 3135 * to the restrictions of creating detached bind-mounts. It 3123 3136 * has a lot saner and simpler semantics. 3124 3137 */ 3125 - mnt = __do_loopback(path, flags, copy_flags); 3138 + mnt = __do_loopback(path, recurse, copy_flags); 3126 3139 scoped_guard(mount_writer) { 3127 3140 if (IS_ERR(mnt)) { 3128 3141 emptied_ns = new_ns; ··· 3151 3164 return new_ns; 3152 3165 } 3153 3166 3154 - static struct file *open_new_namespace(struct path *path, unsigned int flags) 3167 + static struct file *open_new_namespace(struct path *path, bool recurse) 3155 3168 { 3156 3169 struct mnt_namespace *new_ns; 3157 3170 3158 - new_ns = create_new_namespace(path, flags); 3171 + new_ns = create_new_namespace(path, recurse); 3159 3172 if (IS_ERR(new_ns)) 3160 3173 return ERR_CAST(new_ns); 3161 3174 return open_namespace_file(to_ns_common(new_ns)); ··· 3204 3217 return ERR_PTR(ret); 3205 3218 3206 3219 if (flags & OPEN_TREE_NAMESPACE) 3207 - return open_new_namespace(&path, flags); 3220 + return open_new_namespace(&path, (flags & AT_RECURSIVE)); 3208 3221 3209 3222 if (flags & OPEN_TREE_CLONE) 3210 3223 return open_detached_copy(&path, flags);