common/btrfs: add _require_btrfs_sysfs_fsid helper
authorAnand Jain <anand.jain@oracle.com>
Thu, 21 Oct 2021 09:17:04 +0000 (17:17 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 24 Oct 2021 16:08:22 +0000 (00:08 +0800)
It checks if the kernel has the following patch
 btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
that added sysfs interface to get fsid.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/btrfs

index ac880bddf524e040b5b042be93c769cdfc943d1c..5d938c19b56ad9dfd35c90ad2fc144e4ce429b7a 100644 (file)
@@ -445,3 +445,17 @@ _scratch_btrfs_is_zoned()
        [ `_zone_type ${SCRATCH_DEV}` != "none" ] && return 0
        return 1
 }
+
+_require_btrfs_sysfs_fsid()
+{
+       local fsid
+
+       fsid=$($BTRFS_UTIL_PROG filesystem show $TEST_DIR |grep uuid: |\
+              awk '{print $NF}')
+
+       # Check if the kernel has sysfs fsid support.
+       # Following kernel patch adds it:
+       #   btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
+       test -f /sys/fs/btrfs/$fsid/devinfo/1/fsid ||\
+               _notrun "Need btrfs sysfs fsid support"
+}