fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] btrfs/220: make it compatible with older kernels
@ 2021-08-13  1:59 Anand Jain
  2021-08-13  1:59 ` [PATCH 1/4] rc: debug add _scratch_mount_options to the _scratch_mount Anand Jain
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Anand Jain @ 2021-08-13  1:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

I found this test case fails on older kernels such as 5.4.17 as the
patches that brought the mount options changes aren't the candidate
for the backport because of ABI compliance.

So make this test case to check if the newer options such as [1]
are supported and tests the mount options along with the expected
output in /proc/self/mounts accordingly.

[1]
 mount options changes:
  new                   old
  discard=sync          discard
  rescue=nologreplay    nologreplay

 /proc/self/mounts output changes:
  new  old
  ""   clear_cache

Patch 1 improves the debug log provided by the _fail() for the
scratch_mount.

Patch 2,3,4 fixes discard, nologreplay and clear_cache, respectively
and,  they are separated into the individual patch to show the diff.
These may merge at the time of integration. I am ok.

This patchset is on top of Boris's patch [2]
[2]
 [PATCH] btrfs/220: fix clear_cache and inode_cache option tests
 https://patchwork.kernel.org/project/fstests/patch/409e4c73fefce666d151b043d6b2a0d821f8ef85.1610485406.git.boris@bur.io/

Anand Jain (4):
  rc: debug add _scratch_mount_options to the _scratch_mount
  btrfs/220: discard=sync support older kernel
  btrfs/220: nologreplay support older kernel
  btrfs/220: clear_cache fix for older kernel

 common/rc       |  2 +-
 tests/btrfs/220 | 59 +++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 48 insertions(+), 13 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] rc: debug add _scratch_mount_options to the _scratch_mount
  2021-08-13  1:59 [PATCH 0/4] btrfs/220: make it compatible with older kernels Anand Jain
@ 2021-08-13  1:59 ` Anand Jain
  2021-08-13  1:59 ` [PATCH 2/4] btrfs/220: discard=sync support older kernel Anand Jain
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2021-08-13  1:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

When the _scratch_mount fails, there isn't any clue on why it failed as
of now, change this and add the $(_scratch_mount_options $*) to the
_fail.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index e04d9365d902..4e939da37010 100644
--- a/common/rc
+++ b/common/rc
@@ -339,7 +339,7 @@ _try_scratch_mount()
 # mount scratch device with given options and _fail if mount fails
 _scratch_mount()
 {
-	_try_scratch_mount $* || _fail "mount failed"
+	_try_scratch_mount $* || _fail "mount $(_scratch_mount_options $*) failed"
 }
 
 _scratch_mount_idmapped()
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] btrfs/220: discard=sync support older kernel
  2021-08-13  1:59 [PATCH 0/4] btrfs/220: make it compatible with older kernels Anand Jain
  2021-08-13  1:59 ` [PATCH 1/4] rc: debug add _scratch_mount_options to the _scratch_mount Anand Jain
@ 2021-08-13  1:59 ` Anand Jain
  2021-08-13  1:59 ` [PATCH 3/4] btrfs/220: nologreplay " Anand Jain
  2021-08-13  1:59 ` [PATCH 4/4] btrfs/220: clear_cache fix for " Anand Jain
  3 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2021-08-13  1:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

mount option -o discard=sync isn't supported on the older kernel, make
this test case older kernel compatible by checking if the mount option
is supported.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/220 | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/btrfs/220 b/tests/btrfs/220
index 7207c6967793..a01b28a6e42f 100755
--- a/tests/btrfs/220
+++ b/tests/btrfs/220
@@ -263,9 +263,14 @@ test_revertible_options()
 	test_roundtrip_mount "nodatasum" "nodatasum" "datasum" "$DEFAULT_OPTS"
 
 	test_should_fail "discard=invalid"
-	test_roundtrip_mount "discard" "discard" "discard=sync" "discard"
-	test_roundtrip_mount "discard=async" "discard=async" "discard=sync" "discard"
-	test_roundtrip_mount "discard=sync" "discard" "nodiscard" "$DEFAULT_OPTS"
+	if [ "$enable_discard_sync" = true ]; then
+		test_roundtrip_mount "discard" "discard" "discard=sync" "discard"
+		test_roundtrip_mount "discard=async" "discard=async" "discard=sync" "discard"
+		test_roundtrip_mount "discard=sync" "discard" "nodiscard" "$DEFAULT_OPTS"
+	else
+		test_roundtrip_mount "discard" "discard" "discard" "discard"
+		test_roundtrip_mount "discard" "discard" "nodiscard" "$DEFAULT_OPTS"
+	fi
 
 	test_roundtrip_mount "enospc_debug" "enospc_debug" "noenospc_debug" "$DEFAULT_OPTS"
 
@@ -292,6 +297,13 @@ test_revertible_options()
 	test_roundtrip_mount "notreelog" "notreelog" "treelog" "$DEFAULT_OPTS"
 }
 
+# Find out if the running kernel supports the -o discard=sync option.
+_scratch_mkfs >/dev/null
+MOUNT_OPTIONS=
+enable_discard_sync=false
+_try_scratch_mount "-o discard=sync" > /dev/null 2>&1 && \
+	{ enable_discard_sync=true; _scratch_unmount; }
+
 # real QA test starts here
 _scratch_mkfs >/dev/null
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] btrfs/220: nologreplay support older kernel
  2021-08-13  1:59 [PATCH 0/4] btrfs/220: make it compatible with older kernels Anand Jain
  2021-08-13  1:59 ` [PATCH 1/4] rc: debug add _scratch_mount_options to the _scratch_mount Anand Jain
  2021-08-13  1:59 ` [PATCH 2/4] btrfs/220: discard=sync support older kernel Anand Jain
@ 2021-08-13  1:59 ` Anand Jain
  2021-08-13  1:59 ` [PATCH 4/4] btrfs/220: clear_cache fix for " Anand Jain
  3 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2021-08-13  1:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

mount option -o rescue=nologreplay isn't supported on the older kernel, make
this test case older kernel compatible by checking if the mount option
is supported.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/220 | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/tests/btrfs/220 b/tests/btrfs/220
index a01b28a6e42f..9f2f07d723c4 100755
--- a/tests/btrfs/220
+++ b/tests/btrfs/220
@@ -209,22 +209,30 @@ test_non_revertible_options()
 {
 	test_mount_opt "degraded" "degraded"
 
-	# nologreplay should be used only with
+	# nologreplay should be used only with readonly
 	test_should_fail "nologreplay"
-	test_mount_opt "nologreplay,ro" "ro,rescue=nologreplay"
 
-	# norecovery should be used only with. This options is an alias to nologreplay
+	# norecovery should be used only with readonly.
+	# This options is an alias to nologreplay
 	test_should_fail "norecovery"
-	test_mount_opt "norecovery,ro" "ro,rescue=nologreplay"
+
+	if [ "$enable_rescue_nologreplay" = true ]; then
+		#rescue=nologreplay should be used only with readonly
+		test_should_fail "rescue=nologreplay"
+
+		test_mount_opt "nologreplay,ro" "ro,rescue=nologreplay"
+		test_mount_opt "norecovery,ro" "ro,rescue=nologreplay"
+		test_mount_opt "rescue=nologreplay,ro" "ro,rescue=nologreplay"
+	else
+		test_mount_opt "nologreplay,ro" "ro,nologreplay"
+		test_mount_opt "norecovery,ro" "ro,nologreplay"
+	fi
+
 	test_mount_opt "rescan_uuid_tree" "rescan_uuid_tree"
 	test_mount_opt "skip_balance" "skip_balance"
 	test_mount_opt "user_subvol_rm_allowed" "user_subvol_rm_allowed"
 
 	test_should_fail "rescue=invalid"
-
-	# nologreplay requires readonly
-	test_should_fail "rescue=nologreplay"
-	test_mount_opt "rescue=nologreplay,ro" "ro,rescue=nologreplay"
 }
 
 test_one_shot_options()
@@ -304,6 +312,10 @@ enable_discard_sync=false
 _try_scratch_mount "-o discard=sync" > /dev/null 2>&1 && \
 	{ enable_discard_sync=true; _scratch_unmount; }
 
+enable_rescue_nologreplay=false
+_try_scratch_mount "-o ro,rescue=nologreplay" > /dev/null 2>&1 && \
+	{ enable_rescue_nologreplay=true; _scratch_unmount; }
+
 # real QA test starts here
 _scratch_mkfs >/dev/null
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] btrfs/220: clear_cache fix for older kernel
  2021-08-13  1:59 [PATCH 0/4] btrfs/220: make it compatible with older kernels Anand Jain
                   ` (2 preceding siblings ...)
  2021-08-13  1:59 ` [PATCH 3/4] btrfs/220: nologreplay " Anand Jain
@ 2021-08-13  1:59 ` Anand Jain
  3 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2021-08-13  1:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

mount option -o clear_cache shown in /proc/self/mounts isn't supported
in the newer kernel, make this test case older kernel compatible by
checking if clear_cache is shown in the /proc/self/mounts.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/220 | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/btrfs/220 b/tests/btrfs/220
index 9f2f07d723c4..fa91a38493af 100755
--- a/tests/btrfs/220
+++ b/tests/btrfs/220
@@ -237,7 +237,11 @@ test_non_revertible_options()
 
 test_one_shot_options()
 {
-	test_mount_opt "clear_cache" ""
+	if [ "$enable_clear_cache_shown" = true ]; then
+		test_mount_opt "clear_cache" "clear_cache"
+	else
+		test_mount_opt "clear_cache" ""
+	fi
 }
 
 # All these options can be reverted (with their "no" counterpart), or can have
@@ -316,6 +320,13 @@ enable_rescue_nologreplay=false
 _try_scratch_mount "-o ro,rescue=nologreplay" > /dev/null 2>&1 && \
 	{ enable_rescue_nologreplay=true; _scratch_unmount; }
 
+enable_clear_cache_shown=false
+_try_scratch_mount "-o clear_cache" > /dev/null 2>&1 && \
+	{ shown_opts=$(cat /proc/self/mounts | grep $SCRATCH_MNT | \
+		       $AWK_PROG '{ print $4 }')
+	  echo $shown_opts | grep -q clear_cache && enable_clear_cache_shown=true
+	  _scratch_unmount; }
+
 # real QA test starts here
 _scratch_mkfs >/dev/null
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-13  2:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13  1:59 [PATCH 0/4] btrfs/220: make it compatible with older kernels Anand Jain
2021-08-13  1:59 ` [PATCH 1/4] rc: debug add _scratch_mount_options to the _scratch_mount Anand Jain
2021-08-13  1:59 ` [PATCH 2/4] btrfs/220: discard=sync support older kernel Anand Jain
2021-08-13  1:59 ` [PATCH 3/4] btrfs/220: nologreplay " Anand Jain
2021-08-13  1:59 ` [PATCH 4/4] btrfs/220: clear_cache fix for " Anand Jain

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).