diff mbox series

[3/4] btrfs/220: nologreplay support older kernel

Message ID 1419f13a972043a6e7d2de8300adccfd29021079.1628818510.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs/220: make it compatible with older kernels | expand

Commit Message

Anand Jain Aug. 13, 2021, 1:59 a.m. UTC
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 mbox series

Patch

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