]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs/220: clear_cache fix for older kernel
authorAnand Jain <anand.jain@oracle.com>
Fri, 13 Aug 2021 01:59:35 +0000 (09:59 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 15 Aug 2021 15:51:28 +0000 (23:51 +0800)
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>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/220

index 9f2f07d723c4eb998b71c94e5e998196c3291984..fa91a38493af7c50a6397de57b06c6eff9b64368 100755 (executable)
@@ -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