From 389302e73e11186750fb627d4639302222b5c7aa Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Fri, 13 Aug 2021 09:59:35 +0800 Subject: [PATCH] btrfs/220: clear_cache fix for older kernel 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- tests/btrfs/220 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/btrfs/220 b/tests/btrfs/220 index 9f2f07d7..fa91a384 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.39.5