aboutsummaryrefslogtreecommitdiff
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2015-08-14 09:31:17 -0700
committerKevin Hilman <khilman@linaro.org>2015-08-14 09:31:17 -0700
commitb7be2a1de3f5c0827a4f8ccb6a18342d9d4dc446 (patch)
tree7761d178103d5b37a2784dd13cb402474a573cfe /fs/namespace.c
parent6285098f212ef8d8f05a69f0e3a7d4f421dd0ed7 (diff)
parent352cb8677f83a6cf2139151578c8c79785d2d4bf (diff)
Merge tag 'v4.1.5' into linux-linaro-lsk-v4.1lsk-v4.1-15.08
This is the 4.1.5 stable release * tag 'v4.1.5': (124 commits) Linux 4.1.5 perf symbols: Store if there is a filter in place xfs: remote attributes need to be considered data xfs: remote attribute headers contain an invalid LSN drm/nouveau/drm/nv04-nv40/instmem: protect access to priv->heap by mutex drm/nouveau: hold mutex when calling nouveau_abi16_fini() drm/nouveau/kms/nv50-: guard against enabling cursor on disabled heads drm/nouveau/fbcon/nv11-: correctly account for ring space usage qla2xxx: kill sessions/log out initiator on RSCN and port down events qla2xxx: fix command initialization in target mode. qla2xxx: Remove msleep in qlt_send_term_exchange qla2xxx: release request queue reservation. qla2xxx: Fix hardware lock/unlock issue causing kernel panic. intel_pstate: Add get_scaling cpu_defaults param to Knights Landing iscsi-target: Fix iser explicit logout TX kthread leak iscsi-target: Fix iscsit_start_kthreads failure OOPs iscsi-target: Fix use-after-free during TPG session shutdown IB/ipoib: Fix CONFIG_INFINIBAND_IPOIB_CM NFS: Fix a memory leak in nfs_do_recoalesce NFSv4: We must set NFS_OPEN_STATE flag in nfs_resync_open_stateid_locked ...
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 02c6875dd945..fce3cc1a3fa7 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1350,6 +1350,36 @@ enum umount_tree_flags {
UMOUNT_PROPAGATE = 2,
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
@@ -1387,10 +1417,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
if (how & UMOUNT_SYNC)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
- disconnect = !(((how & UMOUNT_CONNECTED) &&
- mnt_has_parent(p) &&
- (p->mnt_parent->mnt.mnt_flags & MNT_UMOUNT)) ||
- IS_MNT_LOCKED_AND_LAZY(p));
+ disconnect = disconnect_mount(p, how);
pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt,
disconnect ? &unmounted : NULL);
@@ -1527,11 +1554,8 @@ void __detach_mounts(struct dentry *dentry)
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) {
- 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);
- }
+ hlist_add_head(&mnt->mnt_umount.s_list, &unmounted);
+ umount_mnt(mnt);
}
else umount_tree(mnt, UMOUNT_CONNECTED);
}