summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2024-05-07 16:36:06 +0930
committerAnand Jain <anand.jain@oracle.com>2024-05-24 12:06:43 +0800
commitfa81eef946b9fd5ebacf877f9cab2790a11a30c8 (patch)
tree8049c37f80320f6ee12e9d12bb20b03c0a2a55ae
parent73f45a1ff44e1f33b27db7bf2de4d3c7e8fbeab6 (diff)
fstests: btrfs/301: handle auto-removed qgroups
There are always attempts to auto-remove empty qgroups after dropping a subvolume. For squota mode, not all qgroups can or should be dropped, as there are common cases where the dropped subvolume are still referred by other snapshots. In that case, the numbers can only be freed when the last referencer got dropped. The latest kernel attempt would only try to drop empty qgroups for squota mode. But even with such safe change, the test case still needs to handle auto-removed qgroups, by explicitly echoing "0", or later calculation would break bash grammar. This patch would add extra handling for such removed qgroups, to be future proof for qgroup auto-removal behavior change. Reviewed-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rwxr-xr-xtests/btrfs/30114
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/btrfs/301 b/tests/btrfs/301
index 05e0f4c8..62854a50 100755
--- a/tests/btrfs/301
+++ b/tests/btrfs/301
@@ -47,9 +47,17 @@ _require_fio $fio_config
get_qgroup_usage()
{
local qgroupid=$1
-
- $BTRFS_UTIL_PROG qgroup show --sync --raw $SCRATCH_MNT | \
- grep "$qgroupid" | $AWK_PROG '{print $3}'
+ local output
+
+ output=$($BTRFS_UTIL_PROG qgroup show --sync --raw $SCRATCH_MNT | \
+ grep "$qgroupid" | $AWK_PROG '{print $3}')
+ # The qgroup is auto-removed, this can only happen if its numbers are
+ # already all zeros, so here we only need to explicitly echo "0".
+ if [ -z "$output" ]; then
+ echo "0"
+ else
+ echo "$output"
+ fi
}
get_subvol_usage()