From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org, HAN Yuwei <hrx@bupt.moe>,
stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: reject zoned RW mount if sectorsize is smaller than page size
Date: Wed, 14 Feb 2024 08:28:46 +0100 [thread overview]
Message-ID: <20240214072846.GM355@twin.jikos.cz> (raw)
In-Reply-To: <2a19a500ccb297397018dac23d30106977153d62.1707714970.git.wqu@suse.com>
On Mon, Feb 12, 2024 at 03:46:15PM +1030, Qu Wenruo wrote:
> [BUG]
> There is a bug report that with zoned device and sectorsize is smaller
> than page size (aka, subpage), btrfs would crash with a very basic
> workload:
>
> # getconfig PAGESIZE
> 16384
> # mkfs.btrfs -f $dev -s 4k
> # mount $dev $mnt
> # $fsstress -w -n 8 -s 1707820327 -v -d $mnt
> # umount $mnt
>
> The crash would look like this (with CONFIG_BTRFS_ASSERT enabled):
>
> assertion failed: block_start != EXTENT_MAP_HOLE, in fs/btrfs/extent_io.c:1384
> ------------[ cut here ]------------
> kernel BUG at fs/btrfs/extent_io.c:1384!
> CPU: 0 PID: 872 Comm: kworker/u9:2 Tainted: G OE 6.8.0-rc3-custom+ #7
> Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20231122-12.fc39 11/22/2023
> Workqueue: writeback wb_workfn (flush-btrfs-8)
> pc : __extent_writepage_io+0x404/0x460 [btrfs]
> lr : __extent_writepage_io+0x404/0x460 [btrfs]
> Call trace:
> __extent_writepage_io+0x404/0x460 [btrfs]
> extent_write_locked_range+0x16c/0x460 [btrfs]
> run_delalloc_cow+0x88/0x118 [btrfs]
> btrfs_run_delalloc_range+0x128/0x228 [btrfs]
> writepage_delalloc+0xb8/0x178 [btrfs]
> __extent_writepage+0xc8/0x3a0 [btrfs]
> extent_write_cache_pages+0x1cc/0x460 [btrfs]
> extent_writepages+0x8c/0x120 [btrfs]
> btrfs_writepages+0x18/0x30 [btrfs]
> do_writepages+0x94/0x1f8
> __writeback_single_inode+0x4c/0x388
> writeback_sb_inodes+0x208/0x4b0
> wb_writeback+0x118/0x3c0
> wb_do_writeback+0xbc/0x388
> wb_workfn+0x80/0x240
> process_one_work+0x154/0x3c8
> worker_thread+0x2bc/0x3e0
> kthread+0xf4/0x108
> ret_from_fork+0x10/0x20
> Code: 9102c021 90000be0 91378000 9402bf53 (d4210000)
> ---[ end trace 0000000000000000 ]---
>
> [CAUSE]
> There are several factors causing the problem:
>
> 1. __extent_writepage_io() requires all dirty ranges to have delalloc
> executed
> This can be solved by adding @start and @len parameter to only submit
> IO for a subset of the page, and update several involved helpers to
> do subpage checks.
>
> So this is not a big deal.
>
> 2. Subpage only accepts for full page aligned ranges for
> extent_write_locked_range()
> For zoned device, regular COW is switched to utilize
> extent_write_locked_range() to submit the IO.
>
> But the caller, run_delalloc_cow() can be called to run on a subpage
> range, e.g.
>
> 0 4K 8K 12K 16K
> |/////| |/////|
>
> Where |///| is the dirtied range.
>
> In that case, btrfs_run_delalloc_range() would call run_delalloc_cow(),
> which would call extent_write_locked_range() for [0, 4K), and unlock
> the whole [0, 16K) page.
>
> But btrfs_run_delalloc_range() would again be called for range [8K,
> 12K), as there are still dirty range left.
> In that case, since the whole page is already unlocked by previous
> iteration, and would cause different ASSERT()s inside
> extent_write_locked_range().
>
> That's also why compression for subpage cases require fully page
> aligned range.
>
> [WORKAROUND]
> A proper fix requires some big changes to delalloc workload, to allow
> extent_write_locked_range() to handle multiple different entries with
> the same @locked_page.
>
> So for now, disable read-write support for subpage zoned btrfs.
>
> The problem can only be solved if subpage btrfs can handle subpage
> compression, which need quite some work on the delalloc procedure for
> the @locked_page handling.
>
> Reported-by: HAN Yuwei <hrx@bupt.moe>
> Link: https://lore.kernel.org/all/1ACD2E3643008A17+da260584-2c7f-432a-9e22-9d390aae84cc@bupt.moe/
> CC: stable@vger.kernel.org # 5.10+
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/disk-io.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index c3ab268533ca..85cd23aebdd6 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3193,7 +3193,8 @@ int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount)
> * part of @locked_page.
> * That's also why compression for subpage only work for page aligned ranges.
> */
> - if (fs_info->sectorsize < PAGE_SIZE && btrfs_is_zoned(fs_info) && is_rw_mount) {
> + if (fs_info->sectorsize < PAGE_SIZE &&
> + btrfs_fs_incompat(fs_info, ZONED) && is_rw_mount) {
> btrfs_warn(fs_info,
> "no zoned read-write support for page size %lu with sectorsize %u",
> PAGE_SIZE, fs_info->sectorsize);
This does not match any code I see in usual branches and it also does
not apply so it can't be picked as a fix.
prev parent reply other threads:[~2024-02-14 7:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 5:16 [PATCH] btrfs: reject zoned RW mount if sectorsize is smaller than page size Qu Wenruo
2024-02-12 9:45 ` Johannes Thumshirn
2024-02-12 9:50 ` Qu Wenruo
2024-02-12 10:25 ` Johannes Thumshirn
2024-02-14 7:29 ` David Sterba
2024-02-17 0:07 ` Qu Wenruo
2024-02-12 11:14 ` David Sterba
2024-02-12 22:54 ` Qu Wenruo
2024-02-14 7:28 ` David Sterba [this message]
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=20240214072846.GM355@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=hrx@bupt.moe \
--cc=linux-btrfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wqu@suse.com \
/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