Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: "Darrick J. Wong" <djwong@kernel.org>, Carlos Maiolino <cem@kernel.org>
Cc: Zorro Lang <zlang@redhat.com>, hch <hch@lst.de>,
	Naohiro Aota <Naohiro.Aota@wdc.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	Hans Holmberg <Hans.Holmberg@wdc.com>,
	"fstests@vger.kernel.org" <fstests@vger.kernel.org>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] common/zoned: add _create_zloop
Date: Sat, 11 Oct 2025 09:34:30 +0000	[thread overview]
Message-ID: <f0713993-cebf-4e42-9c1a-26706a52be4d@wdc.com> (raw)
In-Reply-To: <20251008150806.GA6188@frogsfrogsfrogs>

On 10/8/25 5:08 PM, Darrick J. Wong wrote:
> On Wed, Oct 08, 2025 at 04:38:16PM +0200, Carlos Maiolino wrote:
>> On Tue, Oct 07, 2025 at 02:58:02PM +0200, Johannes Thumshirn wrote:
>>> Add _create_zloop a helper function for creating a zloop device.
>>>
>>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>> ---
>>>   common/zoned | 23 +++++++++++++++++++++++
>>>   1 file changed, 23 insertions(+)
>>>
>>> diff --git a/common/zoned b/common/zoned
>>> index 41697b08..33d3543b 100644
>>> --- a/common/zoned
>>> +++ b/common/zoned
>>> @@ -45,3 +45,26 @@ _require_zloop()
>>>   	    _notrun "This test requires zoned loopback device support"
>>>       fi
>>>   }
>>> +
>>> +# Create a zloop device
>>> +# useage: _create_zloop [id] <base_dir> <zone_size> <nr_conv_zones>
>>> +_create_zloop()
>>> +{
>>> +    local id=$1
>>> +
>>> +    if [ -n "$2" ]; then
>>> +        local base_dir=",base_dir=$2"
>>> +    fi
>>> +
>>> +    if [ -n "$3" ]; then
>>> +        local zone_size=",zone_size_mb=$3"
>>> +    fi
>>> +
>>> +    if [ -n "$4" ]; then
>>> +        local conv_zones=",conv_zones=$4"
>>> +    fi
>>> +
>>> +    local zloop_args="add id=$id$base_dir$zone_size$conv_zones"
>>> +
>>> +    echo "$zloop_args" > /dev/zloop-control
> Hmm, so the caller figures out its own /dev/zloopNNN number, passes NNN
> into the zloop-control devices, and then maybe a new bdev is created?
> Does NNN have to be one more than the current highest zloop device, or
> can it be any number?
>
> Source code says that if NNN >= 0 then it tries to create a new
> zloopNNN or fails with EEXIST; otherwise it gives you the lowest unused
> id.  It'd be nice in the second case if there were a way for the driver
> to tell you what the NNN is.
>
> The _create_zloop users seem to do an ls to select an NNN.  At a minimum
> that code probably ought to get hoisted to here as a common function (or
> maybe just put in _create_zloop itself).
>
> Or maybe turned into a loop like:
>
> 	while true; do
> 		local id=$(_next_zloop_id)
> 		err="$(echo "add id=$id$base_dir..." 2>&1 > /dev/zloop-control)"
> 		if [ -z "$err" ]; then
> 			echo "/dev/zloop$id"
> 			return 0
> 		fi
> 		if echo "$err" | ! grep -q "File exists"; then
> 			echo "$err" 1>&2
> 			return 1;
> 		fi
> 	done
>
> That way test cases don't have to do all that setup themselves?
>
Unfortunately the user has to create the zloop directory (e.g. 
BASE_DIR/0 for zloop0) beforehand (might be a bug though).

What I could do is  encapsulate the find the next zloop and mkdir -p for 
the user (and call in _create_zloop if no id is supplied?)


Thoughts?


  reply	other threads:[~2025-10-11  9:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 12:58 [PATCH v2 0/3] fstests: basic smoke test on zoned loop device Johannes Thumshirn
2025-10-07 12:58 ` [PATCH v2 1/3] common/zoned: add _require_zloop Johannes Thumshirn
2025-10-08 14:32   ` Carlos Maiolino
2025-10-07 12:58 ` [PATCH v2 2/3] common/zoned: add _create_zloop Johannes Thumshirn
2025-10-08 14:38   ` Carlos Maiolino
2025-10-08 15:08     ` Darrick J. Wong
2025-10-11  9:34       ` Johannes Thumshirn [this message]
2025-10-12  0:36         ` Damien Le Moal
2025-10-13 15:08           ` Darrick J. Wong
2025-10-13 15:41             ` Johannes Thumshirn
2025-10-07 12:58 ` [PATCH v2 3/3] generic: basic smoke for filesystems on zoned block devices Johannes Thumshirn
2025-10-08 14:39   ` Carlos Maiolino

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=f0713993-cebf-4e42-9c1a-26706a52be4d@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=Hans.Holmberg@wdc.com \
    --cc=Naohiro.Aota@wdc.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /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