linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Boris Burkov <boris@bur.io>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com,
	fstests@vger.kernel.org
Subject: Re: [PATCH 2/5] common/btrfs: quota mode helpers
Date: Sat, 23 Sep 2023 00:34:20 +0800	[thread overview]
Message-ID: <eb234015-a589-9b1c-b310-7cc64e9f7631@oracle.com> (raw)
In-Reply-To: <e4ea95fc4d1eaef56aabe417c33fa3af350c860f.1688600422.git.boris@bur.io>

On 06/07/2023 07:42, Boris Burkov wrote:
> 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 | 43 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 43 insertions(+)
> 
> diff --git a/common/btrfs b/common/btrfs
> index 175b33aee..66c065a10 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -680,3 +680,46 @@ _require_btrfs_scratch_logical_resolve_v2()
>   	fi
>   	_scratch_unmount
>   }
> +
> +_qgroup_mode_file()
> +{
> +	local mnt=$1
> +
> +	uuid=$(findmnt -n -o UUID $mnt)
> +	echo /sys/fs/btrfs/${uuid}/qgroups/mode
> +}


> +
> +_qgroup_enabled_file()
> +{
> +	local mnt=$1
> +
> +	uuid=$(findmnt -n -o UUID $mnt)


> +	echo /sys/fs/btrfs/${uuid}/qgroups/enabled
> +}
> +


> +_qgroup_mode()
> +{
> +	local mnt=$1
> +
> +	if [ ! -f "$(_qgroup_enabled_file $mnt)" ]; then
> +		echo "disabled"
> +		return
> +	fi
> +
> +	if [ -f "$(_qgroup_mode_file $mnt)" ]; then
> +		cat $(_qgroup_mode_file $mnt)
> +	elif [ $(cat $(_qgroup_enabled_file $mnt)) -eq "1" ]; then
/> +		echo "qgroup"
> +	else
> +		echo "disabled" # should not be reachable, the enabled file won't exist.
> +	fi
> +}
> +
> +_require_scratch_qgroup()
> +{
> +	_scratch_mkfs >>$seqres.full 2>&1
> +	_scratch_mount
> +	_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +	_check_regular_qgroup $SCRATCH_MNT || _notrun "not running normal qgroups"
> +	_scratch_unmount
> +}


Can you add _has_scratch_fs_sysfs() helper for scratch?  See for example 
_has_fs_sysfs().

So that you can do something like..

if [ _has_scratch_fs_sysfs qgroups/mode ]; then
	if [ $(_get_fs_sysfs_attr $mnt qgroups/mode) == 1 ]; then
		echo qgroup
	else
		echo something
else
	_notrun "qgroup unsupported"
fi


Thanks, Anand

  reply	other threads:[~2023-09-22 16:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 23:42 [PATCH 0/5] btrfs: simple quotas fstests Boris Burkov
2023-07-05 23:42 ` [PATCH 1/5] btrfs/400: new test for simple quotas Boris Burkov
2023-09-22 15:40   ` Anand Jain
2023-09-22 15:50     ` Anand Jain
2023-09-27 17:57     ` Boris Burkov
2023-07-05 23:42 ` [PATCH 2/5] common/btrfs: quota mode helpers Boris Burkov
2023-09-22 16:34   ` Anand Jain [this message]
2023-07-05 23:42 ` [PATCH 3/5] common/btrfs: quota rescan helpers Boris Burkov
2023-07-13 20:30   ` Josef Bacik
2023-07-05 23:42 ` [PATCH 4/5] btrfs: use new rescan wrapper Boris Burkov
2023-07-05 23:42 ` [PATCH 5/5] 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=eb234015-a589-9b1c-b310-7cc64e9f7631@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=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).