Skip to content

Commit 725ab43

Browse files
author
Al Viro
committed
get rid of CL_SHARE_TO_SLAVE
the only difference between it and CL_SLAVE is in this predicate in clone_mnt(): if ((flag & CL_SLAVE) || ((flag & CL_SHARED_TO_SLAVE) && IS_MNT_SHARED(old))) { However, in case of CL_SHARED_TO_SLAVE we have not allocated any mount group ids since the time we'd grabbed namespace_sem, so IS_MNT_SHARED() is equivalent to non-zero ->mnt_group_id. And in case of CL_SLAVE old has come either from the original tree, which had ->mnt_group_id allocated for all nodes or from result of sequence of CL_MAKE_SHARED or CL_MAKE_SHARED|CL_SLAVE copies, ultimately going back to the original tree. In both cases we are guaranteed that old->mnt_group_id will be non-zero. In other words, the predicate is always equal to (flags & (CL_SLAVE | CL_SHARED_TO_SLAVE)) && old->mnt_group_id and with that replacement CL_SLAVE and CL_SHARED_TO_SLAVE have exact same behaviour. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent aab771f commit 725ab43

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

fs/namespace.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
13091309
mnt->mnt.mnt_flags = READ_ONCE(old->mnt.mnt_flags) &
13101310
~MNT_INTERNAL_FLAGS;
13111311

1312-
if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE))
1312+
if (flag & (CL_SLAVE | CL_PRIVATE))
13131313
mnt->mnt_group_id = 0; /* not a peer of original */
13141314
else
13151315
mnt->mnt_group_id = old->mnt_group_id;
@@ -1340,8 +1340,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
13401340
if (peers(mnt, old))
13411341
list_add(&mnt->mnt_share, &old->mnt_share);
13421342

1343-
if ((flag & CL_SLAVE) ||
1344-
((flag & CL_SHARED_TO_SLAVE) && IS_MNT_SHARED(old))) {
1343+
if ((flag & CL_SLAVE) && old->mnt_group_id) {
13451344
hlist_add_head(&mnt->mnt_slave, &old->mnt_slave_list);
13461345
mnt->mnt_master = old;
13471346
} else if (IS_MNT_SLAVE(old)) {
@@ -4228,7 +4227,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
42284227
/* First pass: copy the tree topology */
42294228
copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;
42304229
if (user_ns != ns->user_ns)
4231-
copy_flags |= CL_SHARED_TO_SLAVE;
4230+
copy_flags |= CL_SLAVE;
42324231
new = copy_tree(old, old->mnt.mnt_root, copy_flags);
42334232
if (IS_ERR(new)) {
42344233
namespace_unlock();

fs/pnode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define CL_COPY_UNBINDABLE 0x04
2626
#define CL_MAKE_SHARED 0x08
2727
#define CL_PRIVATE 0x10
28-
#define CL_SHARED_TO_SLAVE 0x20
2928
#define CL_COPY_MNT_NS_FILE 0x40
3029

3130
/*

0 commit comments

Comments
 (0)