From: "Darrick J. Wong" <djwong@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Zorro Lang <zlang@redhat.com>, Christoph Hellwig <hch@lst.de>,
fstests@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Anand Jain <anand.jain@oracle.com>,
linux-btrfs@vger.kernel.org,
Hans Holmberg <Hans.Holmberg@wdc.com>,
linux-xfs@vger.kernel.org, Carlos Maiolino <cem@kernel.org>
Subject: Re: [PATCH v6 2/3] common/zoned: add helpers for creation and teardown of zloop devices
Date: Mon, 20 Oct 2025 08:46:04 -0700 [thread overview]
Message-ID: <20251020154604.GJ6178@frogsfrogsfrogs> (raw)
In-Reply-To: <20251017055008.672621-3-johannes.thumshirn@wdc.com>
On Fri, Oct 17, 2025 at 07:50:07AM +0200, Johannes Thumshirn wrote:
> Add _create_zloop, _destroy_zloop and _find_next_zloop helper functions
> for creating destroying and finding the next free zloop device.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> common/zoned | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/common/zoned b/common/zoned
> index 41697b08..e2f5969c 100644
> --- a/common/zoned
> +++ b/common/zoned
> @@ -45,3 +45,56 @@ _require_zloop()
> _notrun "This test requires zoned loopback device support"
> fi
> }
> +
> +_find_next_zloop()
> +{
> + id=0
local id=0
(so the helper won't reassign a variable in the caller's scope)
With that fixed,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> +
> + while true; do
> + if [[ ! -b "/dev/zloop$id" ]]; then
> + break
> + fi
> + id=$((id + 1))
> + done
> +
> + echo "$id"
> +}
> +
> +# Create a zloop device
> +# usage: _create_zloop <base_dir> <zone_size> <nr_conv_zones>
> +_create_zloop()
> +{
> + local id="$(_find_next_zloop)"
> +
> + if [ -n "$1" ]; then
> + local zloop_base="$1"
> + else
> + local zloop_base="/var/local/zloop"
> + fi
> +
> + if [ -n "$2" ]; then
> + local zone_size=",zone_size_mb=$2"
> + fi
> +
> + if [ -n "$3" ]; then
> + local conv_zones=",conv_zones=$3"
> + fi
> +
> + mkdir -p "$zloop_base/$id"
> +
> + local zloop_args="add id=$id,base_dir=$zloop_base$zone_size$conv_zones"
> +
> + echo "$zloop_args" > /dev/zloop-control || \
> + _fail "cannot create zloop device"
> +
> + echo "/dev/zloop$id"
> +}
> +
> +_destroy_zloop() {
> + local zloop="$1"
> +
> + test -b "$zloop" || return
> + local id=$(echo $zloop | grep -oE '[0-9]+$')
> +
> + echo "remove id=$id" > /dev/zloop-control
> +}
> --
> 2.51.0
>
>
next prev parent reply other threads:[~2025-10-20 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 5:50 [PATCH v6 0/3] fstests: basic smoke test on zoned loop device Johannes Thumshirn
2025-10-17 5:50 ` [PATCH v6 1/3] common/zoned: add _require_zloop Johannes Thumshirn
2025-10-17 5:50 ` [PATCH v6 2/3] common/zoned: add helpers for creation and teardown of zloop devices Johannes Thumshirn
2025-10-17 6:04 ` Christoph Hellwig
2025-10-20 5:15 ` Anand Jain
2025-10-20 15:46 ` Darrick J. Wong [this message]
2025-10-17 5:50 ` [PATCH v6 3/3] generic: basic smoke for filesystems on zoned block devices Johannes Thumshirn
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=20251020154604.GJ6178@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=Hans.Holmberg@wdc.com \
--cc=anand.jain@oracle.com \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=fstests@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).