[Devel] [PATCH RHEL7 COMMIT] revert rh mnt: Honor MNT_LOCKED when detaching mounts

Konstantin Khorenko khorenko at virtuozzo.com
Fri Sep 15 17:29:51 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.4
------>
commit 0573dc863a9ef9a7c5cba27c8a35c415c7174ae1
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Fri Sep 15 17:29:51 2017 +0300

    revert rh mnt: Honor MNT_LOCKED when detaching mounts
    
    Lazy umount after pivot_root on start of a new Container
    does not remove cloned ve0 mounts because they get MNT_LOCKED
    during clone in new user namespace.
    These mounts keep references to original super_block
    and prevent its unmount in ve0.
    
    As a work around I revert ce07d891 "mnt: Honor MNT_LOCKED when detaching mounts",
    I expect it helps to delete unused locked mounts.
    
    https://jira.sw.ru/browse/PSBM-71414
    Signed-off-by:	Vasily Averin <vvs at virtuozzo.com>
---
 fs/namespace.c | 55 +++----------------------------------------------------
 1 file changed, 3 insertions(+), 52 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 2c98249..6dbf827 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1125,13 +1125,6 @@ static void mntput_no_expire(struct mount *mnt)
 	rcu_read_unlock();
 
 	list_del(&mnt->mnt_instance);
-
-	if (unlikely(!list_empty(&mnt->mnt_mounts))) {
-		struct mount *p, *tmp;
-		list_for_each_entry_safe(p, tmp, &mnt->mnt_mounts,  mnt_child) {
-			umount_mnt(p);
-		}
-	}
 	unlock_mount_hash();
 
 	if (likely(!(mnt->mnt.mnt_flags & MNT_INTERNAL))) {
@@ -1406,35 +1399,6 @@ enum umount_tree_flags {
 	UMOUNT_CONNECTED = 4,
 };
 
-static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how)
-{
-	/* Leaving mounts connected is only valid for lazy umounts */
-	if (how & UMOUNT_SYNC)
-		return true;
-
-	/* A mount without a parent has nothing to be connected to */
-	if (!mnt_has_parent(mnt))
-		return true;
-
-	/* Because the reference counting rules change when mounts are
-	 * unmounted and connected, umounted mounts may not be
-	 * connected to mounted mounts.
-	 */
-	if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT))
-		return true;
-
-	/* Has it been requested that the mount remain connected? */
-	if (how & UMOUNT_CONNECTED)
-		return false;
-
-	/* Is the mount locked such that it needs to remain connected? */
-	if (IS_MNT_LOCKED(mnt))
-		return false;
-
-	/* By default disconnect the mount */
-	return true;
-}
-
 /*
  * mount_lock must be held
  * namespace_sem must be held for write
@@ -1463,7 +1427,6 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
 		propagate_umount(&tmp_list);
 
 	while (!list_empty(&tmp_list)) {
-		bool disconnect;
 		p = list_first_entry(&tmp_list, struct mount, mnt_list);
 		list_del_init(&p->mnt_expire);
 		list_del_init(&p->mnt_list);
@@ -1472,18 +1435,10 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
 		if (how & UMOUNT_SYNC)
 			p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
 
-		disconnect = disconnect_mount(p, how);
-
-		pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt,
-				 disconnect ? &unmounted : NULL);
+		pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt, &unmounted);
 		if (mnt_has_parent(p)) {
 			mnt_add_count(p->mnt_parent, -1);
-			if (!disconnect) {
-				/* Don't forget about p */
-				list_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts);
-			} else {
-				umount_mnt(p);
-			}
+			umount_mnt(p);
 		}
 		change_mnt_propagation(p, MS_PRIVATE);
 	}
@@ -1611,11 +1566,7 @@ void __detach_mounts(struct dentry *dentry)
 	event++;
 	while (!hlist_empty(&mp->m_list)) {
 		mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
-		if (mnt->mnt.mnt_flags & MNT_UMOUNT) {
-			hlist_add_head(&mnt->mnt_umount.s_list, &unmounted);
-			umount_mnt(mnt);
-		}
-		else umount_tree(mnt, UMOUNT_CONNECTED);
+		umount_tree(mnt, UMOUNT_CONNECTED);
 	}
 	put_mountpoint(mp);
 out_unlock:


More information about the Devel mailing list