diff mbox series

[4/4] btrfs/220: clear_cache fix for older kernel

Message ID 6b714b7e0fcff9d89098b15246e58fcdf8e2b681.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 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 mbox series

Patch

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