linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/5] btrfs-progs: fsck-tests: Check if current kernel can mount fs with specified sector size
Date: Fri,  5 Jul 2019 15:26:48 +0800	[thread overview]
Message-ID: <20190705072651.25150-3-wqu@suse.com> (raw)
In-Reply-To: <20190705072651.25150-1-wqu@suse.com>

[BUG]
When doing test on platforms with page size other than 4K (e.g aarch64
can use 64K page size, or ppc64le), certain test wills fail like:
      [TEST/fsck]   012-leaf-corruption
  mount: /home/adam/btrfs-progs/tests/mnt: wrong fs type, bad option, bad superblock on /dev/loop4, missing codepage or helper program, or other error.
  find: '/home/adam/btrfs-progs/tests//mnt/lost+found': No such file or directory
  inode 1862 not recovered correctly
  test failed for case 012-leaf-corruption

      [TEST/fsck]   028-unaligned-super-dev-sizes
  failed: mount -t btrfs -o loop ./dev_and_super_mismatch_unaligned.raw.restored /home/adam/btrfs-progs/tests//mnt
  test failed for case 028-unaligned-super-dev-sizes

      [TEST/fsck]   037-freespacetree-repair
  failed: /home/adam/btrfs-progs/mkfs.btrfs -f -n 4k /home/adam/btrfs-progs/tests//test.img
  test failed for case 037-freespacetree-repair

[CAUSE]

For fsck/012 and fsck/028, it's caused by the lack of subpage size sector
size support, thus we require kernel page size to match on-disk sector size:
  BTRFS error (device loop4): sectorsize 4096 not supported yet, only support 65536
  BTRFS error (device loop4): superblock contains fatal errors
  BTRFS error (device loop4): open_ctree failed

For fsck/037, it's mkfs causing the problem as we're using 4k nodesize,
but on 64K page sized system, we will use 64K sectorsize and cause
conflicts.

[FIX]
Considering it's easier and easier to get aarch64 boards with enough
performance (e.g rpi4, rk3399, S922) to compile kernel and run tests,
let's skip such tests before widespread complain comes.

This patch will introduce a new check, check_prereq_mount_with_sectorsize(),
which will test if kernel can mount btrfs with specified sectorsize.
So that even one day we support subpage sized sectorsize, we won't need
to update test case again.

For fsck/037, also specify sector size manually. And since in that case
we still need to mount the fs, also add
check_prereq_mount_with_sectorsize() call.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 tests/common                                  | 29 +++++++++++++++++++
 tests/fsck-tests/012-leaf-corruption/test.sh  |  1 +
 .../028-unaligned-super-dev-sizes/test.sh     |  1 +
 .../037-freespacetree-repair/test.sh          |  3 +-
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/tests/common b/tests/common
index 79a16f1e187d..5ad16b69b61d 100644
--- a/tests/common
+++ b/tests/common
@@ -306,6 +306,35 @@ check_prereq()
 	fi
 }
 
+# Require to mount images with speicified sectorsize
+# This is to make sure we can run this test on different arch
+# (e.g aarch64 with 64K pagesize)
+check_prereq_mount_with_sectorsize()
+{
+	prepare_test_dev 128M
+	check_prereq mkfs.btrfs
+	setup_root_helper
+
+	local sectorsize=$1
+	local loop_opt
+
+	if [[ -b "$TEST_DEV" ]]; then
+		loop_opt=""
+	elif [[ -f "$TEST_DEV" ]]; then
+		loop_opt="-o loop"
+	else
+		_fail "Invalid \$TEST_DEV: $TEST_DEV"
+	fi
+
+	run_check_mkfs_test_dev -f -s $sectorsize
+	$SUDO_HELPER mount -t btrfs $loop_opt "$TEST_DEV" "$TEST_MNT" \
+		&> /dev/null
+	if [ $? -ne 0 ]; then
+		_not_run "kernel doesn't support sectorsize $sectorsize"
+	fi
+	run_check_umount_test_dev
+}
+
 check_global_prereq()
 {
 	which "$1" &> /dev/null
diff --git a/tests/fsck-tests/012-leaf-corruption/test.sh b/tests/fsck-tests/012-leaf-corruption/test.sh
index 68d9f695d4de..d5da1d210f28 100755
--- a/tests/fsck-tests/012-leaf-corruption/test.sh
+++ b/tests/fsck-tests/012-leaf-corruption/test.sh
@@ -107,6 +107,7 @@ check_leaf_corrupt_no_data_ext()
 
 setup_root_helper
 
+check_prereq_mount_with_sectorsize 4096
 generate_leaf_corrupt_no_data_ext test.img
 check_image test.img
 check_leaf_corrupt_no_data_ext test.img
diff --git a/tests/fsck-tests/028-unaligned-super-dev-sizes/test.sh b/tests/fsck-tests/028-unaligned-super-dev-sizes/test.sh
index 4015df2d8570..49fa35241d04 100755
--- a/tests/fsck-tests/028-unaligned-super-dev-sizes/test.sh
+++ b/tests/fsck-tests/028-unaligned-super-dev-sizes/test.sh
@@ -6,6 +6,7 @@
 source "$TEST_TOP/common"
 
 check_prereq btrfs
+check_prereq_mount_with_sectorsize 4096
 setup_root_helper
 
 check_all_images
diff --git a/tests/fsck-tests/037-freespacetree-repair/test.sh b/tests/fsck-tests/037-freespacetree-repair/test.sh
index 7f547a33512d..32e6651ac705 100755
--- a/tests/fsck-tests/037-freespacetree-repair/test.sh
+++ b/tests/fsck-tests/037-freespacetree-repair/test.sh
@@ -10,6 +10,7 @@ prepare_test_dev 256M
 
 check_prereq btrfs
 check_prereq mkfs.btrfs
+check_prereq_mount_with_sectorsize 4096
 check_global_prereq grep
 check_global_prereq tail
 check_global_prereq head
@@ -55,7 +56,7 @@ if ! [ -f "/sys/fs/btrfs/features/free_space_tree" ]; then
 	exit
 fi
 
-run_check_mkfs_test_dev -n 4k
+run_check_mkfs_test_dev -s 4k -n 4k
 run_check_mount_test_dev -oclear_cache,space_cache=v2
 
 # create files which will populate the FST
-- 
2.22.0


  parent reply	other threads:[~2019-07-05  7:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  7:26 [PATCH 0/5] btrfs-progs: tests: Make 64K page size system happier Qu Wenruo
2019-07-05  7:26 ` [PATCH 1/5] btrfs-progs: mkfs: Apply the sectorsize user specified on 64k page size system Qu Wenruo
2019-07-05  7:45   ` Nikolay Borisov
2019-07-05  8:38     ` Qu Wenruo
2019-07-05  7:26 ` Qu Wenruo [this message]
2019-07-22 17:07   ` [PATCH 2/5] btrfs-progs: fsck-tests: Check if current kernel can mount fs with specified sector size David Sterba
2019-07-23  1:05     ` Qu Wenruo
2019-07-05  7:26 ` [PATCH 3/5] btrfs-progs: mkfs-tests: Skip 010-minimal-size if we can't mount with 4k " Qu Wenruo
2019-07-22 17:15   ` David Sterba
2019-07-23  1:08     ` Qu Wenruo
2019-07-05  7:26 ` [PATCH 4/5] btrfs-progs: misc-tests: Make test cases work or skipped on 64K page size system Qu Wenruo
2019-07-05  7:26 ` [PATCH 5/5] btrfs-progs: convert-tests: Skip tests if kernel doesn't support subpage sized sector size Qu Wenruo
2019-07-22 17:39   ` David Sterba
2019-07-22 16:49 ` [PATCH 0/5] btrfs-progs: tests: Make 64K page size system happier David Sterba

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=20190705072651.25150-3-wqu@suse.com \
    --to=wqu@suse.com \
    --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;
as well as URLs for NNTP newsgroup(s).