fix EBUSY on umount() from MNT_SHRINKABLE
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 30 Aug 2014 22:32:05 +0000 (18:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Sep 2014 16:19:22 +0000 (09:19 -0700)
commit30f6a1fb4287de9dce822012bd4da1fbdf00cd73
treef568b901b5c6d50f90af762a5ca2802463051e16
parentc532b9ce36b10a5b34def0870f5bd7dafc4b1384
fix EBUSY on umount() from MNT_SHRINKABLE

commit 81b6b06197606b4bef4e427a197aeb808e8d89e1 upstream.

We need the parents of victims alive until namespace_unlock() gets to
dput() of the (ex-)mountpoints.  However, that screws up the "is it
busy" checks in case when we have shrinkable mounts that need to be
killed.  Solution: go ahead and decrement refcounts of parents right
in umount_tree(), increment them again just before dropping rwsem in
namespace_unlock() (and let the loop in the end of namespace_unlock()
finally drop those references for good, as we do now).  Parents can't
get freed until we drop rwsem - at least one reference is kept until
then, both in case when parent is among the victims and when it is
not.  So they'll still be around when we get to namespace_unlock().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namespace.c