Re: [PATCH 5/5] fs: make umount(2) of the root killable on s_umount

From: Jan Kara

Date: Mon Oct 26 2026 - 08:42:27 EST


On Fri 23-10-26 20:39:34, Josef Bacik wrote:
> Unmounting the root of the caller doesn't unmount anything, it remounts
> the filesystem read-only. So it has the same problem as a remount: it
> waits for s_umount in D state, can't be killed, and keeps every later
> reader of the lock waiting behind it.
>
> Use down_write_killable() in do_umount_root().
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>

Look good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> fs/namespace.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 837f531e494b..b874accabf76 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1897,9 +1897,11 @@ static void shrink_submounts(struct mount *mnt);
>
> static int do_umount_root(struct super_block *sb)
> {
> - int ret = 0;
> + int ret;
>
> - down_write(&sb->s_umount);
> + ret = down_write_killable(&sb->s_umount);
> + if (ret)
> + return ret;
> if (!sb_rdonly(sb)) {
> struct fs_context *fc;
>
>
> --
> 2.55.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR