]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs/301: enhance nested simple quotas test
authorBoris Burkov <boris@bur.io>
Wed, 30 Jul 2025 23:03:07 +0000 (16:03 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 1 Aug 2025 18:57:43 +0000 (02:57 +0800)
We had a bug with qgroup accounting with 2+ layers, which was most
easily detected with a slightly more complex nested squota hierarchy.
Make the nested squota test case a tiny bit more complex to capture this
test as well.

The kernel patch that this change exercises is:
        btrfs: fix iteration bug in __qgroup_excl_accounting()

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/301

index 6b59749d80dd14c51eef6641c158add9481eab90..7f676001ee325a455eaf9289d3f382cea8526475 100755 (executable)
@@ -19,6 +19,9 @@ _require_xfs_io_command "falloc"
 _require_scratch_enable_simple_quota
 _require_no_compress
 
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+       "btrfs: fix iteration bug in __qgroup_excl_accounting()"
+
 subv=$SCRATCH_MNT/subv
 nested=$SCRATCH_MNT/subv/nested
 snap=$SCRATCH_MNT/snap
@@ -49,7 +52,7 @@ get_qgroup_usage()
        local output
 
        output=$($BTRFS_UTIL_PROG qgroup show --sync --raw $SCRATCH_MNT | \
-                grep "$qgroupid" | $AWK_PROG '{print $3}')
+                grep -a "^$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
@@ -218,7 +221,9 @@ prepare_nested()
        prepare
        local subvid=$(get_subvid)
        $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT
+       $BTRFS_UTIL_PROG qgroup create 2/100 $SCRATCH_MNT
        $BTRFS_UTIL_PROG qgroup limit $limit 1/100 $SCRATCH_MNT
+       $BTRFS_UTIL_PROG qgroup assign 1/100 2/100 $SCRATCH_MNT >> $seqres.full
        $BTRFS_UTIL_PROG qgroup assign 0/$subvid 1/100 $SCRATCH_MNT >> $seqres.full
        $BTRFS_UTIL_PROG subvolume create $nested >> $seqres.full
        local nestedid=$(get_nestedid)
@@ -228,6 +233,7 @@ prepare_nested()
        local subv_usage=$(get_subvol_usage $subvid)
        local nested_usage=$(get_subvol_usage $nestedid)
        check_qgroup_usage 1/100 $(($subv_usage + $nested_usage))
+       check_qgroup_usage 2/100 $(($subv_usage + $nested_usage))
 }
 
 # Write in a single subvolume, including going over the limit.
@@ -377,12 +383,14 @@ nested_accounting()
        local subv_usage=$(get_subvol_usage $subvid)
        local nested_usage=$(get_subvol_usage $nestedid)
        check_qgroup_usage 1/100 $(($subv_usage + $nested_usage))
+       check_qgroup_usage 2/100 $(($subv_usage + $nested_usage))
        rm $nested/f
        check_subvol_usage $subvid $total_fill
        check_subvol_usage $nestedid 0
        subv_usage=$(get_subvol_usage $subvid)
        nested_usage=$(get_subvol_usage $nestedid)
        check_qgroup_usage 1/100 $(($subv_usage + $nested_usage))
+       check_qgroup_usage 2/100 $(($subv_usage + $nested_usage))
        do_enospc_falloc $nested/large_falloc 2G
        do_enospc_write $nested/large 2G
        _scratch_unmount