Skip to content

Commit faf0dce

Browse files
author
Al Viro
committed
Merge branch 'work.namespace' into for-linus
2 parents 128394e + 5235d44 commit faf0dce

File tree

2 files changed

+38
-44
lines changed

2 files changed

+38
-44
lines changed

fs/namespace.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ static inline struct hlist_head *mp_hash(struct dentry *dentry)
9696
return &mountpoint_hashtable[tmp & mp_hash_mask];
9797
}
9898

99-
/*
100-
* allocation is serialized by namespace_sem, but we need the spinlock to
101-
* serialize with freeing.
102-
*/
10399
static int mnt_alloc_id(struct mount *mnt)
104100
{
105101
int res;
@@ -1034,6 +1030,8 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
10341030
if (IS_MNT_SLAVE(old))
10351031
list_add(&mnt->mnt_slave, &old->mnt_slave);
10361032
mnt->mnt_master = old->mnt_master;
1033+
} else {
1034+
CLEAR_MNT_SHARED(mnt);
10371035
}
10381036
if (flag & CL_MAKE_SHARED)
10391037
set_mnt_shared(mnt);
@@ -1828,9 +1826,7 @@ struct vfsmount *clone_private_mount(const struct path *path)
18281826
if (IS_MNT_UNBINDABLE(old_mnt))
18291827
return ERR_PTR(-EINVAL);
18301828

1831-
down_read(&namespace_sem);
18321829
new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
1833-
up_read(&namespace_sem);
18341830
if (IS_ERR(new_mnt))
18351831
return ERR_CAST(new_mnt);
18361832

fs/pnode.c

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -67,49 +67,47 @@ int get_dominating_id(struct mount *mnt, const struct path *root)
6767

6868
static int do_make_slave(struct mount *mnt)
6969
{
70-
struct mount *peer_mnt = mnt, *master = mnt->mnt_master;
71-
struct mount *slave_mnt;
70+
struct mount *master, *slave_mnt;
7271

73-
/*
74-
* slave 'mnt' to a peer mount that has the
75-
* same root dentry. If none is available then
76-
* slave it to anything that is available.
77-
*/
78-
while ((peer_mnt = next_peer(peer_mnt)) != mnt &&
79-
peer_mnt->mnt.mnt_root != mnt->mnt.mnt_root) ;
80-
81-
if (peer_mnt == mnt) {
82-
peer_mnt = next_peer(mnt);
83-
if (peer_mnt == mnt)
84-
peer_mnt = NULL;
85-
}
86-
if (mnt->mnt_group_id && IS_MNT_SHARED(mnt) &&
87-
list_empty(&mnt->mnt_share))
88-
mnt_release_group_id(mnt);
89-
90-
list_del_init(&mnt->mnt_share);
91-
mnt->mnt_group_id = 0;
92-
93-
if (peer_mnt)
94-
master = peer_mnt;
95-
96-
if (master) {
97-
list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
98-
slave_mnt->mnt_master = master;
99-
list_move(&mnt->mnt_slave, &master->mnt_slave_list);
100-
list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
101-
INIT_LIST_HEAD(&mnt->mnt_slave_list);
72+
if (list_empty(&mnt->mnt_share)) {
73+
if (IS_MNT_SHARED(mnt)) {
74+
mnt_release_group_id(mnt);
75+
CLEAR_MNT_SHARED(mnt);
76+
}
77+
master = mnt->mnt_master;
78+
if (!master) {
79+
struct list_head *p = &mnt->mnt_slave_list;
80+
while (!list_empty(p)) {
81+
slave_mnt = list_first_entry(p,
82+
struct mount, mnt_slave);
83+
list_del_init(&slave_mnt->mnt_slave);
84+
slave_mnt->mnt_master = NULL;
85+
}
86+
return 0;
87+
}
10288
} else {
103-
struct list_head *p = &mnt->mnt_slave_list;
104-
while (!list_empty(p)) {
105-
slave_mnt = list_first_entry(p,
106-
struct mount, mnt_slave);
107-
list_del_init(&slave_mnt->mnt_slave);
108-
slave_mnt->mnt_master = NULL;
89+
struct mount *m;
90+
/*
91+
* slave 'mnt' to a peer mount that has the
92+
* same root dentry. If none is available then
93+
* slave it to anything that is available.
94+
*/
95+
for (m = master = next_peer(mnt); m != mnt; m = next_peer(m)) {
96+
if (m->mnt.mnt_root == mnt->mnt.mnt_root) {
97+
master = m;
98+
break;
99+
}
109100
}
101+
list_del_init(&mnt->mnt_share);
102+
mnt->mnt_group_id = 0;
103+
CLEAR_MNT_SHARED(mnt);
110104
}
105+
list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
106+
slave_mnt->mnt_master = master;
107+
list_move(&mnt->mnt_slave, &master->mnt_slave_list);
108+
list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
109+
INIT_LIST_HEAD(&mnt->mnt_slave_list);
111110
mnt->mnt_master = master;
112-
CLEAR_MNT_SHARED(mnt);
113111
return 0;
114112
}
115113

0 commit comments

Comments
 (0)