* [PATCH v2 0/3] fstests: basic smoke test on zoned loop device
@ 2025-10-07 12:58 Johannes Thumshirn
2025-10-07 12:58 ` [PATCH v2 1/3] common/zoned: add _require_zloop Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-07 12:58 UTC (permalink / raw)
To: Zorro Lang
Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, Hans Holmberg,
fstests, linux-xfs, Carlos Maiolino, Johannes Thumshirn
Add a very basic smoke test on a zoned loopback device to check that noone is
accidentially breaking support for zoned block devices in filesystems that
support these.
Currently this includes btrfs, f2fs and xfs.
Changes to v1:
- Add patch 2/3 factoring out creation of a zloop device
- Fix commit description for patch 3/3
Johannes Thumshirn (3):
common/zoned: add _require_zloop
common/zoned: add _create_zloop
generic: basic smoke for filesystems on zoned block devices
common/zoned | 31 +++++++++++++++++++++++++++
tests/generic/772 | 50 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/772.out | 2 ++
3 files changed, 83 insertions(+)
create mode 100755 tests/generic/772
create mode 100644 tests/generic/772.out
--
2.51.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/3] common/zoned: add _require_zloop
2025-10-07 12:58 [PATCH v2 0/3] fstests: basic smoke test on zoned loop device Johannes Thumshirn
@ 2025-10-07 12:58 ` 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-07 12:58 ` [PATCH v2 3/3] generic: basic smoke for filesystems on zoned block devices Johannes Thumshirn
2 siblings, 1 reply; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-07 12:58 UTC (permalink / raw)
To: Zorro Lang
Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, Hans Holmberg,
fstests, linux-xfs, Carlos Maiolino, Johannes Thumshirn
Add _require_zloop() function used by tests that require support for the
zoned loopback block device.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
common/zoned | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/common/zoned b/common/zoned
index eed0082a..41697b08 100644
--- a/common/zoned
+++ b/common/zoned
@@ -37,3 +37,11 @@ _zone_capacity() {
grep -Po "cap 0x[[:xdigit:]]+" | cut -d ' ' -f 2)
echo $((size << 9))
}
+
+_require_zloop()
+{
+ modprobe zloop >/dev/null 2>&1
+ if [ ! -c "/dev/zloop-control" ]; then
+ _notrun "This test requires zoned loopback device support"
+ fi
+}
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/3] common/zoned: add _create_zloop
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-07 12:58 ` Johannes Thumshirn
2025-10-08 14:38 ` Carlos Maiolino
2025-10-07 12:58 ` [PATCH v2 3/3] generic: basic smoke for filesystems on zoned block devices Johannes Thumshirn
2 siblings, 1 reply; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-07 12:58 UTC (permalink / raw)
To: Zorro Lang
Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, Hans Holmberg,
fstests, linux-xfs, Carlos Maiolino, Johannes Thumshirn
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
+}
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/3] generic: basic smoke for filesystems on zoned block devices
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-07 12:58 ` [PATCH v2 2/3] common/zoned: add _create_zloop Johannes Thumshirn
@ 2025-10-07 12:58 ` Johannes Thumshirn
2025-10-08 14:39 ` Carlos Maiolino
2 siblings, 1 reply; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-07 12:58 UTC (permalink / raw)
To: Zorro Lang
Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, Hans Holmberg,
fstests, linux-xfs, Carlos Maiolino, Johannes Thumshirn
Add a basic smoke test for filesystems that support running on zoned
block devices.
It creates a zloop device with 2 conventional and 62 sequential zones,
mounts it and then runs fsx on it.
Currently this tests supports BTRFS, F2FS and XFS.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
tests/generic/772 | 50 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/772.out | 2 ++
2 files changed, 52 insertions(+)
create mode 100755 tests/generic/772
create mode 100644 tests/generic/772.out
diff --git a/tests/generic/772 b/tests/generic/772
new file mode 100755
index 00000000..403798ff
--- /dev/null
+++ b/tests/generic/772
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Wesgtern Digital Corporation. All Rights Reserved.
+#
+# FS QA Test 772
+#
+# Smoke test for FSes with ZBD support on zloop
+#
+. ./common/preamble
+_begin_fstest auto zone quick
+
+_cleanup()
+{
+ if test -b /dev/zloop$ID; then
+ echo "remove id=$ID" > /dev/zloop-control
+ fi
+}
+
+. ./common/zoned
+
+# Modify as appropriate.
+_require_scratch
+_require_scratch_size $((16 * 1024 * 1024)) #kB
+_require_zloop
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+last_id=$(ls /dev/zloop* 2> /dev/null | grep -E "zloop[0-9]+" | wc -l)
+ID=$((last_id + 1))
+
+mnt="$SCRATCH_MNT/mnt"
+zloopdir="$SCRATCH_MNT/zloop"
+
+mkdir -p "$zloopdir/$ID"
+mkdir -p $mnt
+_create_zloop $ID $zloopdir 256 2
+zloop="/dev/zloop$ID"
+
+_try_mkfs_dev $zloop 2>&1 >> $seqres.full ||\
+ _notrun "cannot mkfs zoned filesystem"
+_mount $zloop $mnt
+
+$FSX_PROG -q -N 20000 $FSX_AVOID "$mnt/fsx" >> $seqres.full
+
+umount $mnt
+
+echo Silence is golden
+# success, all done
+_exit 0
diff --git a/tests/generic/772.out b/tests/generic/772.out
new file mode 100644
index 00000000..98c13968
--- /dev/null
+++ b/tests/generic/772.out
@@ -0,0 +1,2 @@
+QA output created by 772
+Silence is golden
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/3] common/zoned: add _require_zloop
2025-10-07 12:58 ` [PATCH v2 1/3] common/zoned: add _require_zloop Johannes Thumshirn
@ 2025-10-08 14:32 ` Carlos Maiolino
0 siblings, 0 replies; 12+ messages in thread
From: Carlos Maiolino @ 2025-10-08 14:32 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Zorro Lang, Christoph Hellwig, Naohiro Aota, linux-btrfs,
Hans Holmberg, fstests, linux-xfs
On Tue, Oct 07, 2025 at 02:58:01PM +0200, Johannes Thumshirn wrote:
> Add _require_zloop() function used by tests that require support for the
> zoned loopback block device.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> common/zoned | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
>
> diff --git a/common/zoned b/common/zoned
> index eed0082a..41697b08 100644
> --- a/common/zoned
> +++ b/common/zoned
> @@ -37,3 +37,11 @@ _zone_capacity() {
> grep -Po "cap 0x[[:xdigit:]]+" | cut -d ' ' -f 2)
> echo $((size << 9))
> }
> +
> +_require_zloop()
> +{
> + modprobe zloop >/dev/null 2>&1
> + if [ ! -c "/dev/zloop-control" ]; then
> + _notrun "This test requires zoned loopback device support"
> + fi
> +}
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
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
0 siblings, 1 reply; 12+ messages in thread
From: Carlos Maiolino @ 2025-10-08 14:38 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Zorro Lang, Christoph Hellwig, Naohiro Aota, linux-btrfs,
Hans Holmberg, fstests, linux-xfs
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
> +}
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
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 3/3] generic: basic smoke for filesystems on zoned block devices
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
0 siblings, 0 replies; 12+ messages in thread
From: Carlos Maiolino @ 2025-10-08 14:39 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Zorro Lang, Christoph Hellwig, Naohiro Aota, linux-btrfs,
Hans Holmberg, fstests, linux-xfs
On Tue, Oct 07, 2025 at 02:58:03PM +0200, Johannes Thumshirn wrote:
> Add a basic smoke test for filesystems that support running on zoned
> block devices.
>
> It creates a zloop device with 2 conventional and 62 sequential zones,
> mounts it and then runs fsx on it.
>
> Currently this tests supports BTRFS, F2FS and XFS.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Looks fine:
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> tests/generic/772 | 50 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/772.out | 2 ++
> 2 files changed, 52 insertions(+)
> create mode 100755 tests/generic/772
> create mode 100644 tests/generic/772.out
>
> diff --git a/tests/generic/772 b/tests/generic/772
> new file mode 100755
> index 00000000..403798ff
> --- /dev/null
> +++ b/tests/generic/772
> @@ -0,0 +1,50 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Wesgtern Digital Corporation. All Rights Reserved.
> +#
> +# FS QA Test 772
> +#
> +# Smoke test for FSes with ZBD support on zloop
> +#
> +. ./common/preamble
> +_begin_fstest auto zone quick
> +
> +_cleanup()
> +{
> + if test -b /dev/zloop$ID; then
> + echo "remove id=$ID" > /dev/zloop-control
> + fi
> +}
> +
> +. ./common/zoned
> +
> +# Modify as appropriate.
> +_require_scratch
> +_require_scratch_size $((16 * 1024 * 1024)) #kB
> +_require_zloop
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +
> +last_id=$(ls /dev/zloop* 2> /dev/null | grep -E "zloop[0-9]+" | wc -l)
> +ID=$((last_id + 1))
> +
> +mnt="$SCRATCH_MNT/mnt"
> +zloopdir="$SCRATCH_MNT/zloop"
> +
> +mkdir -p "$zloopdir/$ID"
> +mkdir -p $mnt
> +_create_zloop $ID $zloopdir 256 2
> +zloop="/dev/zloop$ID"
> +
> +_try_mkfs_dev $zloop 2>&1 >> $seqres.full ||\
> + _notrun "cannot mkfs zoned filesystem"
> +_mount $zloop $mnt
> +
> +$FSX_PROG -q -N 20000 $FSX_AVOID "$mnt/fsx" >> $seqres.full
> +
> +umount $mnt
> +
> +echo Silence is golden
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/772.out b/tests/generic/772.out
> new file mode 100644
> index 00000000..98c13968
> --- /dev/null
> +++ b/tests/generic/772.out
> @@ -0,0 +1,2 @@
> +QA output created by 772
> +Silence is golden
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
2025-10-08 14:38 ` Carlos Maiolino
@ 2025-10-08 15:08 ` Darrick J. Wong
2025-10-11 9:34 ` Johannes Thumshirn
0 siblings, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2025-10-08 15:08 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Johannes Thumshirn, Zorro Lang, Christoph Hellwig, Naohiro Aota,
linux-btrfs, Hans Holmberg, fstests, linux-xfs
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
> >
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
2025-10-08 15:08 ` Darrick J. Wong
@ 2025-10-11 9:34 ` Johannes Thumshirn
2025-10-12 0:36 ` Damien Le Moal
0 siblings, 1 reply; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-11 9:34 UTC (permalink / raw)
To: Darrick J. Wong, Carlos Maiolino
Cc: Zorro Lang, hch, Naohiro Aota, linux-btrfs@vger.kernel.org,
Hans Holmberg, fstests@vger.kernel.org, linux-xfs@vger.kernel.org
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?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
2025-10-11 9:34 ` Johannes Thumshirn
@ 2025-10-12 0:36 ` Damien Le Moal
2025-10-13 15:08 ` Darrick J. Wong
0 siblings, 1 reply; 12+ messages in thread
From: Damien Le Moal @ 2025-10-12 0:36 UTC (permalink / raw)
To: Johannes Thumshirn, Darrick J. Wong, Carlos Maiolino
Cc: Zorro Lang, hch, Naohiro Aota, linux-btrfs@vger.kernel.org,
Hans Holmberg, fstests@vger.kernel.org, linux-xfs@vger.kernel.org
On 2025/10/11 18:34, Johannes Thumshirn wrote:
> 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).
Not a bug. It is by design since the user can specify the ID of the zloop drive
to create. And there is no fixed association between device ID and directory
path to keep things flexible for the user/distro.
> 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?)
Yes. Do that. The zloop directory si not something that the tests should touch
anyway, so you should just define your own id <-> dir path mapping in the helpers.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
2025-10-12 0:36 ` Damien Le Moal
@ 2025-10-13 15:08 ` Darrick J. Wong
2025-10-13 15:41 ` Johannes Thumshirn
0 siblings, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2025-10-13 15:08 UTC (permalink / raw)
To: Damien Le Moal
Cc: Johannes Thumshirn, Carlos Maiolino, Zorro Lang, hch,
Naohiro Aota, linux-btrfs@vger.kernel.org, Hans Holmberg,
fstests@vger.kernel.org, linux-xfs@vger.kernel.org
On Sun, Oct 12, 2025 at 09:36:18AM +0900, Damien Le Moal wrote:
> On 2025/10/11 18:34, Johannes Thumshirn wrote:
> > 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).
>
> Not a bug. It is by design since the user can specify the ID of the zloop drive
> to create. And there is no fixed association between device ID and directory
> path to keep things flexible for the user/distro.
Hrmmm, each zloop device gets its own notion of the base dir, right?
> > 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?)
>
> Yes. Do that. The zloop directory si not something that the tests should touch
> anyway, so you should just define your own id <-> dir path mapping in the helpers.
That sounds fine to me...
--D
>
>
> --
> Damien Le Moal
> Western Digital Research
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] common/zoned: add _create_zloop
2025-10-13 15:08 ` Darrick J. Wong
@ 2025-10-13 15:41 ` Johannes Thumshirn
0 siblings, 0 replies; 12+ messages in thread
From: Johannes Thumshirn @ 2025-10-13 15:41 UTC (permalink / raw)
To: Darrick J. Wong, Damien Le Moal
Cc: Carlos Maiolino, Zorro Lang, hch, Naohiro Aota,
linux-btrfs@vger.kernel.org, Hans Holmberg,
fstests@vger.kernel.org, linux-xfs@vger.kernel.org
On 10/13/25 5:08 PM, Darrick J. Wong wrote:
> On Sun, Oct 12, 2025 at 09:36:18AM +0900, Damien Le Moal wrote:
>> On 2025/10/11 18:34, Johannes Thumshirn wrote:
>>> 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).
>> Not a bug. It is by design since the user can specify the ID of the zloop drive
>> to create. And there is no fixed association between device ID and directory
>> path to keep things flexible for the user/distro.
> Hrmmm, each zloop device gets its own notion of the base dir, right?
There is the base dir and underneath there is $BASE_DIR/$ID and this
directory has to exist at the time of adding the device.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-10-13 15:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox