public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] fstests: btrfs/215: avoid false alert for subpage case
Date: Mon, 17 May 2021 17:29:22 +0800	[thread overview]
Message-ID: <20210517092922.119788-1-wqu@suse.com> (raw)

[BUG]
When running btrfs/215 with 64K page size, 4K sectorsize (subpage RW
support), it fails with the following error:
btrfs/215       [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//btrfs/215.out.bad)
    --- tests/btrfs/215.out     2021-03-19 16:34:26.069634953 +0800
    +++ ~/xfstests-dev/results//btrfs/215.out.bad      2021-05-17 16:52:34.743514224 +0800
    @@ -1,2 +1,3 @@
     QA output created by 215
    -Silence is golden
    +Errors: 8 expected: 2
    +(see ~/xfstests-dev/results//btrfs/215.full for details)
    ...
    (Run 'diff -u ~/xfstests-dev/tests/btrfs/215.out ~/xfstests-dev/results//btrfs/215.out.bad'  to see the entire diff)

[CAUSE]
For subpage case, btrfs still tries to read the full page, other than
read just one sector for PAGE_SIZE == sectorsize case.

This means for the 2 sectors corrupted case, since they are in the same
page, all the errors will be reported.

[FIX]
Change the following values:
- filesize
  Now it's 8 * pagesize.

- expected error number
  Now it's 2 * sectors_per_page or 6 * sectors_per_page.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Note: The btrfs subpage full data RW support is not yet merged into upstream,
but most of its preparation patches are already merged, and it can
already pass most fstests.

The out-of-tree branch can be fetched from my git repo:
https://github.com/adam900710/linux/tree/subpage

Some failures are just false alerts, like btrfs/215 which always
believes sectorsize == PAGE_SIZE for btrfs, thus it's worthy fixing before
bothering testers when the RW support get merged.
---
 tests/btrfs/215 | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/tests/btrfs/215 b/tests/btrfs/215
index 748287e7..c4959061 100755
--- a/tests/btrfs/215
+++ b/tests/btrfs/215
@@ -46,8 +46,21 @@ _scratch_mkfs > /dev/null
 # blobk group
 _scratch_mount -o nospace_cache
 
+pagesize=$(get_page_size)
 blocksize=$(_get_block_size $SCRATCH_MNT)
-filesize=$((8*$blocksize))
+
+# For subpage case, since we still do read in full page size, if have 8 corrupted
+# sectors in one page, then even we just try to read one sector of that page,
+# all 8 corruption will be reported.
+# So here we chose the filesize using page size.
+filesize=$((8*$pagesize))
+if [ $blocksize -le $pagesize ]; then
+	sectors_per_page=$(($pagesize / $blocksize))
+else
+	# We don't support multi-page sectorsize yet
+	_notrun "this test doesn't support sectorsize $blocksize with page size $pagesize yet"
+fi
+
 uuid=$(findmnt -n -o UUID "$SCRATCH_MNT")
 
 if [ ! -e /sys/fs/btrfs/$uuid/bdi ]; then
@@ -64,24 +77,24 @@ echo "logical = $logical_extent physical=$physical_extent" >> $seqres.full
 
 # corrupt first 4 blocks of file
 _scratch_unmount
-$XFS_IO_PROG -d -c "pwrite -S 0xaa -b $blocksize $physical_extent $((4*$blocksize))" $SCRATCH_DEV > /dev/null
+$XFS_IO_PROG -d -c "pwrite -S 0xaa -b $pagesize $physical_extent $((4 * $pagesize))" $SCRATCH_DEV > /dev/null
 _scratch_mount
 
 # disable readahead to avoid skewing the counter
 echo 0 > /sys/fs/btrfs/$uuid/bdi/read_ahead_kb
 
-# buffered reads whould result in 2 errors since readahead code always submits
-# at least 1 page worth of IO and it will be counted as an error as well
+# buffered reads whould result in 2 * sectors_per_page errors since readahead code always submits
+# at least 1 page worth of IO and it will be counted as error(s) as well
 $XFS_IO_PROG -c "pread -b $filesize 0 $filesize" "$SCRATCH_MNT/foobar" > /dev/null 2>&1
 errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | awk '/corruption_errs/ { print $2 }')
-if [ $errs -ne 2 ]; then
+if [ $errs -ne $((2 * $sectors_per_page)) ]; then
 	_fail "Errors: $errs expected: 2"
 fi
 
 # DIO does check every sector
 $XFS_IO_PROG -d -c "pread -b $filesize 0 $filesize" "$SCRATCH_MNT/foobar" > /dev/null 2>&1
 errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | awk '/corruption_errs/ { print $2 }')
-if [ $errs -ne 6 ]; then
+if [ $errs -ne $((6 * $sectors_per_page)) ]; then
 	_fail "Errors: $errs expected: 6"
 fi
 
-- 
2.31.1


                 reply	other threads:[~2021-05-17  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210517092922.119788-1-wqu@suse.com \
    --to=wqu@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