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@xxxxxx> --- common/btrfs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/common/btrfs b/common/btrfs index 175b33aee..66c065a10 100644 --- a/common/btrfs +++ b/common/btrfs @@ -680,3 +680,46 @@ _require_btrfs_scratch_logical_resolve_v2() fi _scratch_unmount } + +_qgroup_mode_file() +{ + local mnt=$1 + + uuid=$(findmnt -n -o UUID $mnt) + echo /sys/fs/btrfs/${uuid}/qgroups/mode +} + +_qgroup_enabled_file() +{ + local mnt=$1 + + uuid=$(findmnt -n -o UUID $mnt) + echo /sys/fs/btrfs/${uuid}/qgroups/enabled +} + +_qgroup_mode() +{ + local mnt=$1 + + if [ ! -f "$(_qgroup_enabled_file $mnt)" ]; then + echo "disabled" + return + fi + + if [ -f "$(_qgroup_mode_file $mnt)" ]; then + cat $(_qgroup_mode_file $mnt) + elif [ $(cat $(_qgroup_enabled_file $mnt)) -eq "1" ]; then + echo "qgroup" + else + echo "disabled" # should not be reachable, the enabled file won't exist. + fi +} + +_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + _check_regular_qgroup $SCRATCH_MNT || _notrun "not running normal qgroups" + _scratch_unmount +} -- 2.41.0