@@ -2799,6 +2799,13 @@ _btrfs_stress_replace()
done
}
+# find the right option to force output in bytes, older versions of btrfs-progs
+# print that by default, newer print human readable numbers with unit suffix
+_btrfs_qgroup_units()
+{
+ $BTRFS_UTIL_PROG qgroup show --help 2>&1 | grep -q -- --raw && echo "--raw"
+}
+
# return device size in kb
_get_device_size()
{
@@ -79,7 +79,8 @@ rm -fr $SCRATCH_MNT/snap/foo*
sync
-$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}'
+units=`_btrfs_qgroup_units`
+$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}'
# success, all done
status=0
@@ -52,7 +52,7 @@ _basic_test()
_run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
_run_btrfs_util_prog quota enable $SCRATCH_MNT/a
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
- $BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid >> \
+ $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid >> \
$seqres.full 2>&1
[ $? -eq 0 ] || _fail "couldn't find our subvols quota group"
run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
@@ -62,10 +62,10 @@ _basic_test()
# the shared values of both the original subvol and snapshot should
# match
- a_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid)
+ a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
a_shared=$(echo $a_shared | awk '{ print $2 }')
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
- b_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid)
+ b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
b_shared=$(echo $b_shared | awk '{ print $2 }')
[ $b_shared -eq $a_shared ] || _fail "shared values don't match"
}
@@ -81,12 +81,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 $SCRATCH_MNT | grep $subvolid)
+ output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $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 $SCRATCH_MNT | grep $subvolid)
+ output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
echo $output >> $seqres.full
[ $refer -eq $(echo $output | awk '{ print $2 }') ] || \
_fail "reference values don't match after rescan"
@@ -118,6 +118,8 @@ _limit_test_noexceed()
[ $? -eq 0 ] || _fail "should have been allowed to write"
}
+units=`_btrfs_qgroup_units`
+
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_basic_test
@@ -74,7 +74,8 @@ _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
rm -rf $SCRATCH_MNT/* >& /dev/null
_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
-$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \
+units=`_btrfs_qgroup_units`
+$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \
| $AWK_PROG '{print $2" "$3}'
status=0
Newer versions of btrfs-progs change the default output of 'qgroup show', we have to check what version is running and use the right option if needed. Signed-off-by: David Sterba <dsterba@suse.cz> --- common/rc | 7 +++++++ tests/btrfs/017 | 3 ++- tests/btrfs/022 | 12 +++++++----- tests/btrfs/057 | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-)