From: Filipe Manana <fdmanana@kernel.org>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org, johannes.thumshirn@wdc.com,
linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
david@fromorbit.com
Subject: Re: [PATCH 2/4] btrfs: mark device addition as sb_writing
Date: Fri, 11 Mar 2022 14:21:14 +0000 [thread overview]
Message-ID: <Yita2kwuHzjCkH+z@debian9.Home> (raw)
In-Reply-To: <09e63a62afe0c03bac24cfbfe37316f97e13e113.1646983176.git.naohiro.aota@wdc.com>
On Fri, Mar 11, 2022 at 04:38:03PM +0900, Naohiro Aota wrote:
> btrfs_init_new_device() calls btrfs_relocate_sys_chunk() which incurs
> file-system internal writing. That writing can cause a deadlock with
> FS freezing like as described in like as described in commit
> 26559780b953 ("btrfs: zoned: mark relocation as writing").
>
> Mark the device addition as sb_writing. This is also consistent with
> the removing device ioctl counterpart.
>
> Fixes: 5accdf82ba25 ("fs: Improve filesystem freezing handling")
Same comment as the previous patch about this.
> Cc: stable@vger.kernel.org
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
> fs/btrfs/ioctl.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 238cee5b5254..ffa30fd3eed2 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3484,6 +3484,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
> return -EINVAL;
> }
>
> + sb_start_write(fs_info->sb);
Why not use mnt_want_write_file(), just like all the other ioctls that need
to do some change to the fs?
We don't have the struct file * here at btrfs_ioctl_add_dev(), but we have
it in its caller, btrfs_ioctl().
Thanks.
> if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_DEV_ADD)) {
> if (!btrfs_exclop_start_try_lock(fs_info, BTRFS_EXCLOP_DEV_ADD))
> return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
> @@ -3516,6 +3517,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
> btrfs_exclop_balance(fs_info, BTRFS_EXCLOP_BALANCE_PAUSED);
> else
> btrfs_exclop_finish(fs_info);
> + sb_end_write(fs_info->sb);
> return ret;
> }
>
> --
> 2.35.1
>
next prev parent reply other threads:[~2022-03-11 14:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 7:38 [PATCH 0/4] protect relocation with sb_start_write Naohiro Aota
2022-03-11 7:38 ` [PATCH 1/4] btrfs: mark resumed async balance as writing Naohiro Aota
2022-03-11 14:08 ` Filipe Manana
2022-03-14 2:29 ` Naohiro Aota
2022-03-14 11:25 ` Filipe Manana
2022-03-11 7:38 ` [PATCH 2/4] btrfs: mark device addition as sb_writing Naohiro Aota
2022-03-11 14:21 ` Filipe Manana [this message]
2022-03-14 2:31 ` Naohiro Aota
2022-03-11 7:38 ` [PATCH 3/4] fs: add check functions for sb_start_{write,pagefault,intwrite} Naohiro Aota
2022-03-11 14:28 ` Filipe Manana
2022-03-11 7:38 ` [PATCH 4/4] btrfs: assert that relocation is protected with sb_start_write() Naohiro Aota
2022-03-11 14:33 ` Filipe Manana
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yita2kwuHzjCkH+z@debian9.Home \
--to=fdmanana@kernel.org \
--cc=david@fromorbit.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).