diff mbox series

[v4,4/6] btrfs: quota rescan helpers

Message ID 1f8549eb7f043ab9071faf896121896e759daab7.1695942727.git.boris@bur.io (mailing list archive)
State New, archived
Headers show
Series btrfs: simple quotas fstests | expand

Commit Message

Boris Burkov Sept. 28, 2023, 11:16 p.m. UTC
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>
---
 common/btrfs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Anand Jain Sept. 29, 2023, 9:14 a.m. UTC | #1
On 29/09/2023 07:16, Boris Burkov wrote:
> 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>

> +_require_qgroup_rescan()
> +{
> +	_scratch_mkfs >>$seqres.full 2>&1
> +	_scratch_mount
> +	_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +	$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT ||  _notrun "not able to run quota rescan"

Fixed line length to < 80 chars.

Thx, Anand
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index 8d51bd522..34fa3a157 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -710,6 +710,24 @@  _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
+	$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT ||  _notrun "not able to run quota rescan"
+	_scratch_unmount
+}
+
 _require_scratch_qgroup()
 {
 	_scratch_mkfs >>$seqres.full 2>&1