aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Burkov <boris@bur.io>2023-09-28 16:16:44 -0700
committerZorro Lang <zlang@kernel.org>2023-10-05 22:32:01 +0800
commit587984a47e44e0c81557b72e10eeda4bd7a6fb84 (patch)
tree0d4ea409443bb6ac8bccebb130949521716ab578
parentc0cafb48a892e0d9e414478df5d5f818d6c101dd (diff)
downloadxfstests-dev-587984a47e44e0c81557b72e10eeda4bd7a6fb84.tar.gz
btrfs: quota mode helpers
To facilitate skipping tests depending on the qgroup mode after mkfs, add support for figuring out the mode. This cannot just rely on the new sysfs file, since it might not be present on older kernels. Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rw-r--r--common/btrfs41
1 files changed, 41 insertions, 0 deletions
diff --git a/common/btrfs b/common/btrfs
index 62cee209fd..3884d9904b 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -689,3 +689,44 @@ _require_btrfs_scratch_logical_resolve_v2()
fi
_scratch_unmount
}
+
+_qgroup_mode()
+{
+ local dev=$1
+
+ if [ ! -b "$dev" ]; then
+ _fail "Usage: _qgroup_mode <mounted_device>"
+ fi
+
+ if _has_fs_sysfs_attr $dev /qgroups/mode; then
+ _get_fs_sysfs_attr $dev qgroups/mode
+ else
+ echo "disabled"
+ fi
+}
+
+_check_regular_qgroup()
+{
+ _qgroup_mode "$@" | grep -q 'qgroup'
+}
+
+_require_scratch_qgroup()
+{
+ _scratch_mkfs >>$seqres.full 2>&1
+ _scratch_mount
+ $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+ _check_regular_qgroup $SCRATCH_DEV || \
+ _notrun "not running normal qgroups"
+ _scratch_unmount
+}
+
+_require_scratch_enable_simple_quota()
+{
+ _scratch_mkfs >>$seqres.full 2>&1
+ _scratch_mount
+ _qgroup_mode $SCRATCH_DEV | grep 'squota' && \
+ _notrun "cannot enable simple quota; on by default"
+ $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT || \
+ _notrun "simple quotas not available"
+ _scratch_unmount
+}