From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Cc: Filipe Manana <fdmanana@suse.com>
Subject: [PATCH] common/btrfs: handle dmdust as mounted device in _btrfs_buffered_read_on_mirror()
Date: Mon, 26 Jun 2023 14:00:52 +0800 [thread overview]
Message-ID: <20230626060052.8913-1-wqu@suse.com> (raw)
[BUG]
After commit ab41f0bddb73 ("common/btrfs: use _scratch_cycle_mount to
ensure all page caches are dropped"), the test case btrfs/143 can fail
like below:
btrfs/143 6s ... [failed, exit status 1]- output mismatch (see ~/xfstests/results//btrfs/143.out.bad)
--- tests/btrfs/143.out 2020-06-10 19:29:03.818519162 +0100
+++ ~/xfstests/results//btrfs/143.out.bad 2023-06-19 17:04:00.575033899 +0100
@@ -1,37 +1,6 @@
QA output created by 143
wrote 131072/131072 bytes
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
................
-XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
................
-XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
................
-XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
................
[CAUSE]
Test case btrfs/143 uses dm-dust device to emulate read errors, this
means we can not use _scratch_cycle_mount to cycle mount $SCRATCH_MNT.
As it would go mount $SCRATCH_DEV, not the dm-dust device to
$SCRATCH_MNT.
This prevents us to trigger read-repair (since no error would be hit)
thus fail the test.
[FIX]
Since we can mount whatever device at $SCRATCH_MNT, we can not use
_scratch_cycle_mount in this case.
Instead implement a small helper to grab the mounted device and its
mount options, and use the same device and mount options to cycle
$SCRATCH_MNT mount.
This would fix btrfs/143 and hopefully future test cases which use dm
devices.
Reported-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
common/btrfs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/common/btrfs b/common/btrfs
index 175b33ae..4a02b2cc 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -601,8 +601,18 @@ _btrfs_buffered_read_on_mirror()
# The drop_caches doesn't seem to drop every pages on aarch64 with
# 64K page size.
# So here as another workaround, cycle mount the SCRATCH_MNT to ensure
- # the cache are dropped.
- _scratch_cycle_mount
+ # the cache are dropped, but we can not use _scratch_cycle_mount, as
+ # we may mount whatever dm device at SCRATCH_MNT.
+ # So here we grab the mounted block device and its mount options, then
+ # unmount and re-mount with the same device and options.
+ local mount_info=$(_mount | grep "$SCRATCH_MNT")
+ if [ -z "$mount_info" ]; then
+ _fail "failed to grab mount info of $SCRATCH_MNT"
+ fi
+ local dev=$(echo $mount_info | $AWK_PROG '{print $1}')
+ local opts=$(echo $mount_info | $AWK_PROG '{print $6}' | sed 's/[()]//g')
+ _scratch_unmount
+ _mount $dev -o $opts $SCRATCH_MNT
while [[ -z $( (( BASHPID % nr_mirrors == mirror )) &&
exec $XFS_IO_PROG \
-c "pread -b $size $offset $size" $file) ]]; do
--
2.39.0
next reply other threads:[~2023-06-26 6:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 6:00 Qu Wenruo [this message]
2023-06-26 16:36 ` [PATCH] common/btrfs: handle dmdust as mounted device in _btrfs_buffered_read_on_mirror() Filipe Manana
2023-06-26 17:32 ` Zorro Lang
2023-06-26 21:23 ` Qu Wenruo
2023-06-28 11:34 ` Zorro Lang
2023-06-28 11:40 ` Qu Wenruo
2023-06-28 15:16 ` Zorro Lang
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=20230626060052.8913-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=fdmanana@suse.com \
--cc=fstests@vger.kernel.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