aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2014-12-18 14:10:48 -0500
committerEric W. Biederman <ebiederm@xmission.com>2015-04-02 21:34:18 -0400
commitc003b26ff98ca04a180ff34c38c007a3998d62f9 (patch)
tree0d48f9edeed164c03b02494cf129ef76a0ffb91c /fs
parent8318e667f176f7ea34451a1a530634e293f216ac (diff)
mnt: In umount_tree reuse mnt_list instead of mnt_hash
umount_tree builds a list of mounts that need to be unmounted. Utilize mnt_list for this purpose instead of mnt_hash. This begins to allow keeping a mount on the mnt_hash after it is unmounted, which is necessary for a properly functioning MNT_LOCKED implementation. The fact that mnt_list is an ordinary list makding available list_move is nice bonus. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/namespace.c20
-rw-r--r--fs/pnode.c6
-rw-r--r--fs/pnode.h2
3 files changed, 15 insertions, 13 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index c68d9fc912e7..54cbef129f4a 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1327,23 +1327,25 @@ enum umount_tree_flags {
1327 */ 1327 */
1328static void umount_tree(struct mount *mnt, enum umount_tree_flags how) 1328static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
1329{ 1329{
1330 HLIST_HEAD(tmp_list); 1330 LIST_HEAD(tmp_list);
1331 struct mount *p; 1331 struct mount *p;
1332 1332
1333 for (p = mnt; p; p = next_mnt(p, mnt)) { 1333 /* Gather the mounts to umount */
1334 hlist_del_init_rcu(&p->mnt_hash); 1334 for (p = mnt; p; p = next_mnt(p, mnt))
1335 hlist_add_head(&p->mnt_hash, &tmp_list); 1335 list_move(&p->mnt_list, &tmp_list);
1336 }
1337 1336
1338 hlist_for_each_entry(p, &tmp_list, mnt_hash) 1337 /* Hide the mounts from lookup_mnt and mnt_mounts */
1338 list_for_each_entry(p, &tmp_list, mnt_list) {
1339 hlist_del_init_rcu(&p->mnt_hash);
1339 list_del_init(&p->mnt_child); 1340 list_del_init(&p->mnt_child);
1341 }
1340 1342
1343 /* Add propogated mounts to the tmp_list */
1341 if (how & UMOUNT_PROPAGATE) 1344 if (how & UMOUNT_PROPAGATE)
1342 propagate_umount(&tmp_list); 1345 propagate_umount(&tmp_list);
1343 1346
1344 while (!hlist_empty(&tmp_list)) { 1347 while (!list_empty(&tmp_list)) {
1345 p = hlist_entry(tmp_list.first, struct mount, mnt_hash); 1348 p = list_first_entry(&tmp_list, struct mount, mnt_list);
1346 hlist_del_init_rcu(&p->mnt_hash);
1347 list_del_init(&p->mnt_expire); 1349 list_del_init(&p->mnt_expire);
1348 list_del_init(&p->mnt_list); 1350 list_del_init(&p->mnt_list);
1349 __touch_mnt_namespace(p->mnt_ns); 1351 __touch_mnt_namespace(p->mnt_ns);
diff --git a/fs/pnode.c b/fs/pnode.c
index 260ac8f898a4..bf012af709dd 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -384,7 +384,7 @@ static void __propagate_umount(struct mount *mnt)
384 if (child && list_empty(&child->mnt_mounts)) { 384 if (child && list_empty(&child->mnt_mounts)) {
385 list_del_init(&child->mnt_child); 385 list_del_init(&child->mnt_child);
386 hlist_del_init_rcu(&child->mnt_hash); 386 hlist_del_init_rcu(&child->mnt_hash);
387 hlist_add_before_rcu(&child->mnt_hash, &mnt->mnt_hash); 387 list_move_tail(&child->mnt_list, &mnt->mnt_list);
388 } 388 }
389 } 389 }
390} 390}
@@ -396,11 +396,11 @@ static void __propagate_umount(struct mount *mnt)
396 * 396 *
397 * vfsmount lock must be held for write 397 * vfsmount lock must be held for write
398 */ 398 */
399int propagate_umount(struct hlist_head *list) 399int propagate_umount(struct list_head *list)
400{ 400{
401 struct mount *mnt; 401 struct mount *mnt;
402 402
403 hlist_for_each_entry(mnt, list, mnt_hash) 403 list_for_each_entry(mnt, list, mnt_list)
404 __propagate_umount(mnt); 404 __propagate_umount(mnt);
405 return 0; 405 return 0;
406} 406}
diff --git a/fs/pnode.h b/fs/pnode.h
index 16afc3d6d2f2..aa6d65df7204 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -40,7 +40,7 @@ static inline void set_mnt_shared(struct mount *mnt)
40void change_mnt_propagation(struct mount *, int); 40void change_mnt_propagation(struct mount *, int);
41int propagate_mnt(struct mount *, struct mountpoint *, struct mount *, 41int propagate_mnt(struct mount *, struct mountpoint *, struct mount *,
42 struct hlist_head *); 42 struct hlist_head *);
43int propagate_umount(struct hlist_head *); 43int propagate_umount(struct list_head *);
44int propagate_mount_busy(struct mount *, int); 44int propagate_mount_busy(struct mount *, int);
45void mnt_release_group_id(struct mount *); 45void mnt_release_group_id(struct mount *);
46int get_dominating_id(struct mount *mnt, const struct path *root); 46int get_dominating_id(struct mount *mnt, const struct path *root);