This is a note to let you know that I've just added the patch titled mnt: Honor MNT_LOCKED when detaching mounts to the 4.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mnt-honor-mnt_locked-when-detaching-mounts.patch and it can be found in the queue-4.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From ce07d891a0891d3c0d0c2d73d577490486b809e1 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx> Date: Tue, 23 Dec 2014 21:37:03 -0600 Subject: mnt: Honor MNT_LOCKED when detaching mounts From: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx> commit ce07d891a0891d3c0d0c2d73d577490486b809e1 upstream. Modify umount(MNT_DETACH) to keep mounts in the hash table that are locked to their parent mounts, when the parent is lazily unmounted. In mntput_no_expire detach the children from the hash table, depending on mnt_pin_kill in cleanup_mnt to decrement the mnt_count of the children. In __detach_mounts if there are any mounts that have been unmounted but still are on the list of mounts of a mountpoint, remove their children from the mount hash table and those children to the unmounted list so they won't linger potentially indefinitely waiting for their final mntput, now that the mounts serve no purpose. Signed-off-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/namespace.c | 29 ++++++++++++++++++++++++++--- fs/pnode.h | 2 ++ 2 files changed, 28 insertions(+), 3 deletions(-) --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1099,6 +1099,13 @@ static void mntput_no_expire(struct moun 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))) { @@ -1372,6 +1379,7 @@ static void umount_tree(struct mount *mn 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); @@ -1380,10 +1388,18 @@ static void umount_tree(struct mount *mn if (how & UMOUNT_SYNC) p->mnt.mnt_flags |= MNT_SYNC_UMOUNT; - pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt, &unmounted); + disconnect = !IS_MNT_LOCKED_AND_LAZY(p); + + pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt, + disconnect ? &unmounted : NULL); if (mnt_has_parent(p)) { mnt_add_count(p->mnt_parent, -1); - umount_mnt(p); + if (!disconnect) { + /* Don't forget about p */ + list_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts); + } else { + umount_mnt(p); + } } change_mnt_propagation(p, MS_PRIVATE); } @@ -1508,7 +1524,14 @@ void __detach_mounts(struct dentry *dent lock_mount_hash(); while (!hlist_empty(&mp->m_list)) { mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list); - umount_tree(mnt, 0); + if (mnt->mnt.mnt_flags & MNT_UMOUNT) { + struct mount *p, *tmp; + list_for_each_entry_safe(p, tmp, &mnt->mnt_mounts, mnt_child) { + hlist_add_head(&p->mnt_umount.s_list, &unmounted); + umount_mnt(p); + } + } + else umount_tree(mnt, 0); } unlock_mount_hash(); put_mountpoint(mp); --- a/fs/pnode.h +++ b/fs/pnode.h @@ -20,6 +20,8 @@ #define SET_MNT_MARK(m) ((m)->mnt.mnt_flags |= MNT_MARKED) #define CLEAR_MNT_MARK(m) ((m)->mnt.mnt_flags &= ~MNT_MARKED) #define IS_MNT_LOCKED(m) ((m)->mnt.mnt_flags & MNT_LOCKED) +#define IS_MNT_LOCKED_AND_LAZY(m) \ + (((m)->mnt.mnt_flags & (MNT_LOCKED|MNT_SYNC_UMOUNT)) == MNT_LOCKED) #define CL_EXPIRE 0x01 #define CL_SLAVE 0x02 Patches currently in stable-queue which might be from ebiederm@xxxxxxxxxxxx are queue-4.0/mnt-don-t-propagate-umounts-in-__detach_mounts.patch queue-4.0/mnt-add-mnt_umount-flag.patch queue-4.0/mnt-honor-mnt_locked-when-detaching-mounts.patch queue-4.0/mnt-delay-removal-from-the-mount-hash.patch queue-4.0/mnt-on-an-unmount-propagate-clearing-of-mnt_locked.patch queue-4.0/mnt-don-t-propagate-unmounts-to-locked-mounts.patch queue-4.0/mnt-factor-out-unhash_mnt-from-detach_mnt-and-umount_tree.patch queue-4.0/mnt-factor-umount_mnt-from-umount_tree.patch queue-4.0/mnt-fix-the-error-check-in-__detach_mounts.patch queue-4.0/mnt-update-detach_mounts-to-leave-mounts-connected.patch queue-4.0/mnt-improve-the-umount_tree-flags.patch queue-4.0/mnt-in-umount_tree-reuse-mnt_list-instead-of-mnt_hash.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html