提交 81b6b061 编写于 作者: A Al Viro

fix EBUSY on umount() from MNT_SHRINKABLE

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().

Cc: stable@vger.kernel.org # 3.12+
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 88b368f2
...@@ -1217,6 +1217,11 @@ static void namespace_unlock(void) ...@@ -1217,6 +1217,11 @@ static void namespace_unlock(void)
head.first->pprev = &head.first; head.first->pprev = &head.first;
INIT_HLIST_HEAD(&unmounted); INIT_HLIST_HEAD(&unmounted);
/* undo decrements we'd done in umount_tree() */
hlist_for_each_entry(mnt, &head, mnt_hash)
if (mnt->mnt_ex_mountpoint.mnt)
mntget(mnt->mnt_ex_mountpoint.mnt);
up_write(&namespace_sem); up_write(&namespace_sem);
synchronize_rcu(); synchronize_rcu();
...@@ -1268,6 +1273,7 @@ void umount_tree(struct mount *mnt, int how) ...@@ -1268,6 +1273,7 @@ void umount_tree(struct mount *mnt, int how)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT; p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
if (mnt_has_parent(p)) { if (mnt_has_parent(p)) {
put_mountpoint(p->mnt_mp); put_mountpoint(p->mnt_mp);
mnt_add_count(p->mnt_parent, -1);
/* move the reference to mountpoint into ->mnt_ex_mountpoint */ /* move the reference to mountpoint into ->mnt_ex_mountpoint */
p->mnt_ex_mountpoint.dentry = p->mnt_mountpoint; p->mnt_ex_mountpoint.dentry = p->mnt_mountpoint;
p->mnt_ex_mountpoint.mnt = &p->mnt_parent->mnt; p->mnt_ex_mountpoint.mnt = &p->mnt_parent->mnt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册