diff mbox series

[3/5] common/btrfs: quota rescan helpers

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

Commit Message

Boris Burkov July 5, 2023, 11:42 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 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Josef Bacik July 13, 2023, 8:30 p.m. UTC | #1
On Wed, Jul 05, 2023 at 04:42:25PM -0700, 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>
> ---
>  common/btrfs | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/common/btrfs b/common/btrfs
> index 66c065a10..d88feaded 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -715,6 +715,31 @@ _qgroup_mode()
>  	fi
>  }
>  
> +_check_regular_qgroup()
> +{
> +	local mnt=$1
> +
> +	_qgroup_mode $mnt | grep -q 'qgroup'
> +}
> +
> +_qgroup_rescan()
> +{
> +	local mnt=$1
> +
> +	_check_regular_qgroup $mnt || 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
> +}

Looks like whitespace errors here.  Thanks,

Josef
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index 66c065a10..d88feaded 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -715,6 +715,31 @@  _qgroup_mode()
 	fi
 }
 
+_check_regular_qgroup()
+{
+	local mnt=$1
+
+	_qgroup_mode $mnt | grep -q 'qgroup'
+}
+
+_qgroup_rescan()
+{
+	local mnt=$1
+
+	_check_regular_qgroup $mnt || 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