]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
btrfs: quota rescan helpers
authorBoris Burkov <boris@bur.io>
Thu, 28 Sep 2023 23:16:46 +0000 (16:16 -0700)
committerZorro Lang <zlang@kernel.org>
Thu, 5 Oct 2023 14:32:01 +0000 (22:32 +0800)
Many btrfs tests explicitly trigger quota rescan. This is not a
meaningful operation for simple quotas, so we wrap it in a helper that
doesn't blow up quite so badly and lets us run those tests where the
rescan is a qgroup detail.

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/btrfs

index 3884d9904b2125a94bd19b9362c73f18588eaf98..c3bffd2ae3f738ed6f6070e170bd7464003f1d38 100644 (file)
@@ -710,6 +710,29 @@ _check_regular_qgroup()
        _qgroup_mode "$@" | grep -q 'qgroup'
 }
 
+_qgroup_rescan()
+{
+       local mnt=$1
+       local dev=$(findmnt -n -o SOURCE $mnt)
+
+       _check_regular_qgroup $dev || return 1
+       _run_btrfs_util_prog quota rescan -w $mnt
+}
+
+_require_qgroup_rescan()
+{
+       _scratch_mkfs >>$seqres.full 2>&1
+       _scratch_mount
+       _run_btrfs_util_prog quota enable $SCRATCH_MNT
+       # Wait for the first rescan.
+       $BTRFS_UTIL_PROG quota rescan -W $SCRATCH_MNT || \
+                               _notrun "not able to wait on a quota rescan"
+       # Make sure we can start a rescan.
+       $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full || \
+                                       _notrun "not able to run quota rescan"
+       _scratch_unmount
+}
+
 _require_scratch_qgroup()
 {
        _scratch_mkfs >>$seqres.full 2>&1