btrfs/022: Match qgroup id more correctly
authorQu Wenruo <wqu@suse.com>
Fri, 7 Feb 2020 01:59:41 +0000 (09:59 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 9 Feb 2020 15:56:09 +0000 (23:56 +0800)
[BUG]
Btrfs/022 sometimes fails with snapshot's reference mismatch with its
source.

[CAUSE]
Since commit fd0830929573 ("fsstress: add the ability to create
snapshots") adds the ability for fsstress to create/delete snapshot and
subvolumes, fsstress will create new subvolumes under test dir.

For example, we could have the following subvolumes created by fsstress:
subvol a id=256
subvol b id=306
qgroupid         rfer         excl
--------         ----         ----
0/5             16384        16384
0/256        13914112        16384
...
0/263         3080192      2306048  << 2 *306* 048
...
0/306        13914112        16384  << 0/ *306

So when we're greping for subvolid 306, it matches qgroup 0/263 first,
which has difference size, and caused false alert.

[FIX]
Instead of greping "$subvolid" blindly, now grep "0/$subvolid" to catch
qgroupid correctly, without hitting rfer/excl values.

Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/022

index 5348d3ed0da71ad97182cf5c7b989df13ca3e6d9..3e7298526c04c87900531f8ea8faa65711d19f55 100755 (executable)
@@ -49,10 +49,10 @@ _basic_test()
 
        # the shared values of both the original subvol and snapshot should
        # match
-       a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
+       a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
        a_shared=$(echo $a_shared | awk '{ print $2 }')
        subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
-       b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
+       b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
        b_shared=$(echo $b_shared | awk '{ print $2 }')
        [ $b_shared -eq $a_shared ] || _fail "shared values don't match"
 }
@@ -68,12 +68,12 @@ _rescan_test()
        run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
                $FSSTRESS_AVOID
        sync
-       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
+       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
        echo $output >> $seqres.full
        refer=$(echo $output | awk '{ print $2 }')
        excl=$(echo $output | awk '{ print $3 }')
        _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
-       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
+       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
        echo $output >> $seqres.full
        [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \
                _fail "reference values don't match after rescan"