linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org
Subject: [PATCH v3 2/6] btrfs: quota mode helpers
Date: Wed, 27 Sep 2023 16:14:34 -0700	[thread overview]
Message-ID: <3c6f4cd053ccd2deb8ee459f5b0e5eb6fd877487.1695856385.git.boris@bur.io> (raw)
In-Reply-To: <cover.1695856385.git.boris@bur.io>

To facilitate skipping tests depending on the qgroup mode after mkfs,
add support for figuring out the mode. This cannot just rely on the new
sysfs file, since it might not be present on older kernels.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 common/btrfs | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index c9903a413..37796cc6e 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -689,3 +689,41 @@ _require_btrfs_scratch_logical_resolve_v2()
 	fi
 	_scratch_unmount
 }
+
+_qgroup_mode()
+{
+	local dev=$1
+
+	if [ ! -b "$dev" ]; then
+		_fail "Usage: _qgroup_mode <mounted_device>"
+	fi
+
+	if _has_fs_sysfs_attr $dev /qgroups/mode; then
+		_get_fs_sysfs_attr $dev qgroups/mode
+	else
+		echo "disabled"
+	fi
+}
+
+_check_regular_qgroup()
+{
+	_qgroup_mode "$@" | grep -q 'qgroup'
+}
+
+_require_scratch_qgroup()
+{
+	_scratch_mkfs >>$seqres.full 2>&1
+	_scratch_mount
+	_run_btrfs_util_prog quota enable $SCRATCH_MNT
+	_check_regular_qgroup $SCRATCH_DEV || _notrun "not running normal qgroups"
+	_scratch_unmount
+}
+
+_require_scratch_enable_simple_quota()
+{
+    _scratch_mkfs >>$seqres.full 2>&1
+    _scratch_mount
+	_qgroup_mode $SCRATCH_DEV | grep 'squota' && _notrun "cannot enable simple quota; on by default"
+    $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT || _notrun "simple quotas not available"
+	_scratch_unmount
+}
-- 
2.42.0


  parent reply	other threads:[~2023-09-27 23:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27 23:14 [PATCH v3 0/6] btrfs: simple quotas fstests Boris Burkov
2023-09-27 23:14 ` [PATCH v3 1/6] common: refactor sysfs_attr functions Boris Burkov
2023-09-27 23:14 ` Boris Burkov [this message]
2023-09-28 13:07   ` [PATCH v3 2/6] btrfs: quota mode helpers Anand Jain
2023-09-27 23:14 ` [PATCH v3 3/6] btrfs/301: new test for simple quotas Boris Burkov
2023-09-28 15:39   ` Filipe Manana
2023-09-27 23:14 ` [PATCH v3 4/6] btrfs: quota rescan helpers Boris Burkov
2023-09-28 12:58   ` Anand Jain
2023-09-27 23:14 ` [PATCH v3 5/6] btrfs: use new rescan wrapper Boris Burkov
2023-09-27 23:14 ` [PATCH v3 6/6] btrfs: skip squota incompatible tests Boris Burkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c6f4cd053ccd2deb8ee459f5b0e5eb6fd877487.1695856385.git.boris@bur.io \
    --to=boris@bur.io \
    --cc=fstests@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).