From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: misc-next and for-next: kernel BUG at fs/btrfs/extent_io.c:2350! during raid5 recovery
Date: Tue, 9 Aug 2022 15:24:08 -0400 [thread overview]
Message-ID: <YvK0WPtEVzXwv3p1@hungrycats.org> (raw)
In-Reply-To: <YvIbB5l4gtG4f/S9@infradead.org>
On Tue, Aug 09, 2022 at 01:29:59AM -0700, Christoph Hellwig wrote:
> On Mon, Aug 08, 2022 at 11:31:51PM -0400, Zygo Blaxell wrote:
> > There is now a BUG_ON arising from this test case:
> >
> > [ 241.051326][ T45] btrfs_print_data_csum_error: 156 callbacks suppressed
> > [ 241.100910][ T45] ------------[ cut here ]------------
> > [ 241.102531][ T45] kernel BUG at fs/btrfs/extent_io.c:2350!
>
> This
>
> BUG_ON(!mirror_num);
>
> so repair_io_failure gets called with a mirror_num of 0..
>
> > [ 241.128354][ T45] clean_io_failure+0x21a/0x260
>
> .. from clean_io_failure. Which starts from failrec->this_mirror and
> tries to go back to failrec->failed_mirror using the prev_mirror
> helper. prev_mirror looks like:
>
> static int prev_mirror(const struct io_failure_record *failrec, int cur_mirror)
> {
> if (cur_mirror == 1)
> return failrec->num_copies;
> return cur_mirror - 1;
> }
>
> So the only way we could end up with a mirror = 0 is if
> failrec->num_copies is 0. -failrec->num_copies is initialized
> in btrfs_get_io_failure_record by doing:
>
> failrec->num_copies = btrfs_num_copies(fs_info, failrec->logical, sectorsize);
>
> just adter allocating the failrec. I can't see any obvious way how
> btrfs_num_copies would return 0, though, as for raid5 it just copies
> from btrfs_raid_array.
Judging from prior raid5 testing behavior, it looks like there's a race
condition specific to btrfs raid5 IO. Previous kernel versions have had
assorted UAF bugs from time to time that KASAN tripped over, and btrfs
replace almost never works on the first try on a real raid5 array.
These issues were reported years ago, but nobody seems to have been
working on them until recently.
A similar test setup previously produced data corruption during raid5
recovery, even on an otherwise idle filesystem, at a low rate (~1
error per 100 GB). I expect whatever bug was leading to that hasn't
been entirely fixed yet.
> Any chance you could share a script for your reproducer?
The simplest reproducer is some variant of:
mkfs.btrfs -draid5 -mraid1 /dev/vdb /dev/vdc /dev/vdd
mount /dev/vdb /mnt -ocompress=zstd,noatime
cd /mnt
cp -a /40gb-test-data .
sync
while true; do
find -type f -exec cat {} + > /dev/null
done &
while true; do
cat /dev/zero > /dev/vdb
done &
while true; do
btrfs scrub start -Bd /mnt
done &
wait
but it can take a long time to hit a failure with something that gentle.
I throw on some extra test workload (e.g. lots of rsyncs) to keep the
page cache full and under memory pressure, which seems to speed up the
failure rate to once every few hours.
next prev parent reply other threads:[~2022-08-09 19:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 3:31 misc-next and for-next: kernel BUG at fs/btrfs/extent_io.c:2350! during raid5 recovery Zygo Blaxell
2022-08-09 4:36 ` Qu Wenruo
2022-08-09 19:46 ` Zygo Blaxell
2022-08-10 7:17 ` Qu Wenruo
2022-08-14 4:52 ` Qu Wenruo
2022-08-16 1:01 ` Zygo Blaxell
2022-08-16 1:25 ` Qu Wenruo
2022-08-09 7:35 ` Qu Wenruo
2022-08-09 19:29 ` Zygo Blaxell
2022-08-09 21:50 ` Qu Wenruo
2022-08-10 8:08 ` Goffredo Baroncelli
2022-08-10 8:24 ` Qu Wenruo
2022-08-10 8:45 ` Goffredo Baroncelli
2022-08-10 9:14 ` Qu Wenruo
2022-08-09 8:29 ` Christoph Hellwig
2022-08-09 19:24 ` Zygo Blaxell [this message]
2022-08-12 2:58 ` Wang Yugui
2022-08-12 22:47 ` Wang Yugui
2022-08-13 1:50 ` Qu Wenruo
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=YvK0WPtEVzXwv3p1@hungrycats.org \
--to=ce3g8jdj@umail.furryterror.org \
--cc=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
/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