summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-10-04 13:02:20 +0200
committerChristian Brauner <brauner@kernel.org>2026-10-07 00:45:50 +0200
commit3d399224425573875b6f6f1181bd8cf9a28cc7d1 (patch)
treec6802876ce08bbd1eb18f53a2e13f479c4312294 /fs
parent9e320581ee632f0b141e52419065de53e7a033b0 (diff)
namespace: simplify disconnect_mount()
Rename disconnect_mount() and simplify it. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/namespace.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 9ebcb8b35c48..3ed3766f3a18 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1815,30 +1815,14 @@ enum umount_tree_flags {
UMOUNT_COVER = 4,
};
-static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how)
+/* Do we need to leave the mountpoint on the parent covered? */
+static bool needs_cover(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;
-
- /* Only an unmounted parent has a mountpoint to keep covered */
- if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT))
- return true;
-
- /* Has it been requested that the mountpoint stays covered? */
- if (how & UMOUNT_COVER)
return false;
-
- /* Is the mount locked such that its mountpoint must stay covered? */
- if (IS_MNT_LOCKED(mnt))
+ if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT))
return false;
-
- /* By default disconnect the mount */
- return true;
+ return (how & UMOUNT_COVER) || IS_MNT_LOCKED(mnt);
}
/*
@@ -1889,7 +1873,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
if (mnt_has_parent(p)) {
- if (!disconnect_mount(p, how))
+ if (needs_cover(p, how))
leave_cover(p);
umount_mnt(p);
}