public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Zorro Lang <zlang@redhat.com>, Christoph Hellwig <hch@lst.de>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	linux-btrfs@vger.kernel.org,
	Hans Holmberg <hans.holmberg@wdc.com>,
	fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 2/3] common/zoned: add _create_zloop
Date: Wed, 8 Oct 2025 08:08:06 -0700	[thread overview]
Message-ID: <20251008150806.GA6188@frogsfrogsfrogs> (raw)
In-Reply-To: <hrht5llavtcgd5bb6sgsluy3vs2m6ddzzshkhwqb4fjgujgrli@6px7vpsk7ek3>

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?

--D

> > +}
> 
> Looks fine to me, but I'm not sure if some error checking would be
> worth here in case setting up the zloop dev fails?
> > --
> > 2.51.0
> > 
> 

  reply	other threads:[~2025-10-08 15:08 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 [this message]
2025-10-11  9:34       ` Johannes Thumshirn
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=20251008150806.GA6188@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=hch@lst.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --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