btrfs: Use _require_btrfs_qgroup_report to replace open code

Introduce new _require_btrfs_qgroup_report function, which will
check the accessibility to "btrfs check --qgroup-report", then set a
global flag to info _check_scratch_fs() to do extra qgroup check.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Qu Wenruo
2016-12-09 09:19:59 +08:00
committed by Eryu Guan
parent 47bb69de19
commit 180843c1f4
11 changed files with 45 additions and 32 deletions
+4
View File
@@ -43,6 +43,7 @@ _cleanup()
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
rm -f $seqres.full
@@ -125,16 +126,19 @@ _scratch_mkfs > /dev/null 2>&1
_scratch_mount
_basic_test
_scratch_unmount
_check_scratch_fs
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_rescan_test
_scratch_unmount
_check_scratch_fs
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_limit_test_exceed
_scratch_unmount
_check_scratch_fs
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
+2 -3
View File
@@ -51,6 +51,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
_scratch_mkfs
_scratch_mount
@@ -86,9 +87,7 @@ _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
_scratch_unmount
# generate a qgroup report and look for inconsistent groups
$BTRFS_UTIL_PROG check --qgroup-report $SCRATCH_DEV 2>&1 | \
grep -E "Counts for qgroup.*are different"
# qgroup will be checked at _check_scratch_fs() by fstest.
echo "Silence is golden"
status=0
+1
View File
@@ -43,6 +43,7 @@ _cleanup()
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
rm -f $seqres.full
+1
View File
@@ -46,6 +46,7 @@ _cleanup()
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
# Use big blocksize to ensure there is still enough space left for metadata
# space reserve.
+5 -15
View File
@@ -58,6 +58,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
rm -f $seqres.full
@@ -145,21 +146,10 @@ _scratch_cycle_mount
# referenced above.
_run_btrfs_util_prog subvolume delete $SCRATCH_MNT/snap1
# There is no way from userspace to force btrfs_drop_snapshot to run
# at a given time (even via mount/unmount). We must wait for it to
# start and complete. This is the shortest time on my tests systems I
# have found which always allows drop_snapshot to run to completion.
sleep 45
# "btrfs filesystem sync" will trigger subvolume deletion
_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
_scratch_unmount
# generate a qgroup report and look for inconsistent groups
# - don't use _run_btrfs_util_prog here as it captures the output and
# we need to grep it.
$BTRFS_UTIL_PROG check --qgroup-report $SCRATCH_DEV 2>&1 | \
grep -E -q "Counts for qgroup.*are different"
if [ $? -ne 0 ]; then
status=0
fi
# Qgroup will be checked by fstest at _check_scratch_fs()
status=0
exit
+3 -6
View File
@@ -49,6 +49,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
rm -f $seqres.full
@@ -78,11 +79,7 @@ _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap2"
_scratch_unmount
# generate a qgroup report and look for inconsistent groups
$BTRFS_UTIL_PROG check --qgroup-report $SCRATCH_DEV 2>&1 | \
grep -q -E "Counts for qgroup.*are different"
if [ $? -ne 0 ]; then
status=0
fi
# qgroup will be checked by fstest at _check_scratch_fs()
status=0
exit
+2 -3
View File
@@ -53,6 +53,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
_scratch_mkfs
# Need to use inline extents to fill metadata rapidly
@@ -76,9 +77,7 @@ _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
_run_btrfs_util_prog balance start -d $SCRATCH_MNT
_scratch_unmount
# generate a qgroup report and look for inconsistent groups
$BTRFS_UTIL_PROG check --qgroup-report $SCRATCH_DEV 2>&1 | \
grep -E "Counts for qgroup.*are different"
# qgroup will be check at _check_scratch_fs() by fstest
# success, all done
status=0
+1
View File
@@ -49,6 +49,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_btrfs_qgroup_report
_scratch_mkfs
# Use enospc_debug mount option to trigger restrict space info check