* [PATCH] xfs/841: create a block device that must exist
@ 2026-02-02 8:57 Christoph Hellwig
2026-02-02 18:54 ` Luca Di Maio
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-02-02 8:57 UTC (permalink / raw)
To: zlang; +Cc: djwong, luca.dimaio1, linux-xfs, fstests
This test currently creates a block device node for /dev/ram0,
which isn't guaranteed to exist, and can thus cause the test to
fail with:
mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or address
Instead, create a node for the backing device for $TEST_DIR, which must
exist.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
tests/xfs/841 | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/xfs/841 b/tests/xfs/841
index ee2368d4a746..ddb1b3bea104 100755
--- a/tests/xfs/841
+++ b/tests/xfs/841
@@ -85,9 +85,12 @@ _create_proto_dir()
$here/src/af_unix "$PROTO_DIR/socket" 2> /dev/null || true
# Block device (requires root)
- mknod "$PROTO_DIR/blockdev" b 1 0 2> /dev/null || true
+ # Uses the device for $TEST_DIR to ensure it always exists.
+ mknod "$PROTO_DIR/blockdev" b $(stat -c '%Hd %Ld' $TEST_DIR) \
+ 2> /dev/null || true
# Character device (requires root)
+ # Uses /dev/null, which should always exist
mknod "$PROTO_DIR/chardev" c 1 3 2> /dev/null || true
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs/841: create a block device that must exist
2026-02-02 8:57 [PATCH] xfs/841: create a block device that must exist Christoph Hellwig
@ 2026-02-02 18:54 ` Luca Di Maio
2026-02-03 8:28 ` Zorro Lang
2026-03-03 17:53 ` Darrick J. Wong
2 siblings, 0 replies; 6+ messages in thread
From: Luca Di Maio @ 2026-02-02 18:54 UTC (permalink / raw)
To: Christoph Hellwig, zlang; +Cc: djwong, linux-xfs, fstests
Thanks Christoph
Reviewed-by: Luca Di Maio <luca.dimaio1@gmail.com>
On Mon, 2026-02-02 at 09:57 +0100, Christoph Hellwig wrote:
> This test currently creates a block device node for /dev/ram0,
> which isn't guaranteed to exist, and can thus cause the test to
> fail with:
>
> mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or
> address
>
> Instead, create a node for the backing device for $TEST_DIR, which
> must
> exist.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> tests/xfs/841 | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/xfs/841 b/tests/xfs/841
> index ee2368d4a746..ddb1b3bea104 100755
> --- a/tests/xfs/841
> +++ b/tests/xfs/841
> @@ -85,9 +85,12 @@ _create_proto_dir()
> $here/src/af_unix "$PROTO_DIR/socket" 2> /dev/null || true
>
> # Block device (requires root)
> - mknod "$PROTO_DIR/blockdev" b 1 0 2> /dev/null || true
> + # Uses the device for $TEST_DIR to ensure it always exists.
> + mknod "$PROTO_DIR/blockdev" b $(stat -c '%Hd %Ld' $TEST_DIR)
> \
> + 2> /dev/null || true
>
> # Character device (requires root)
> + # Uses /dev/null, which should always exist
> mknod "$PROTO_DIR/chardev" c 1 3 2> /dev/null || true
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs/841: create a block device that must exist
2026-02-02 8:57 [PATCH] xfs/841: create a block device that must exist Christoph Hellwig
2026-02-02 18:54 ` Luca Di Maio
@ 2026-02-03 8:28 ` Zorro Lang
2026-03-03 17:53 ` Darrick J. Wong
2 siblings, 0 replies; 6+ messages in thread
From: Zorro Lang @ 2026-02-03 8:28 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: zlang, djwong, luca.dimaio1, linux-xfs, fstests
On Mon, Feb 02, 2026 at 09:57:01AM +0100, Christoph Hellwig wrote:
> This test currently creates a block device node for /dev/ram0,
> which isn't guaranteed to exist, and can thus cause the test to
> fail with:
>
> mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or address
>
> Instead, create a node for the backing device for $TEST_DIR, which must
> exist.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
This patch makes sense to me, thanks.
Reviewed-by: Zorro Lang <zlang@redhat.com>
> tests/xfs/841 | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/xfs/841 b/tests/xfs/841
> index ee2368d4a746..ddb1b3bea104 100755
> --- a/tests/xfs/841
> +++ b/tests/xfs/841
> @@ -85,9 +85,12 @@ _create_proto_dir()
> $here/src/af_unix "$PROTO_DIR/socket" 2> /dev/null || true
>
> # Block device (requires root)
> - mknod "$PROTO_DIR/blockdev" b 1 0 2> /dev/null || true
> + # Uses the device for $TEST_DIR to ensure it always exists.
> + mknod "$PROTO_DIR/blockdev" b $(stat -c '%Hd %Ld' $TEST_DIR) \
> + 2> /dev/null || true
>
> # Character device (requires root)
> + # Uses /dev/null, which should always exist
> mknod "$PROTO_DIR/chardev" c 1 3 2> /dev/null || true
> }
>
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs/841: create a block device that must exist
2026-02-02 8:57 [PATCH] xfs/841: create a block device that must exist Christoph Hellwig
2026-02-02 18:54 ` Luca Di Maio
2026-02-03 8:28 ` Zorro Lang
@ 2026-03-03 17:53 ` Darrick J. Wong
2026-03-04 12:55 ` Christoph Hellwig
2 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2026-03-03 17:53 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: zlang, luca.dimaio1, linux-xfs, fstests
On Mon, Feb 02, 2026 at 09:57:01AM +0100, Christoph Hellwig wrote:
> This test currently creates a block device node for /dev/ram0,
> which isn't guaranteed to exist, and can thus cause the test to
> fail with:
>
> mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or address
>
> Instead, create a node for the backing device for $TEST_DIR, which must
> exist.
Hrm. I'm still noticing regressions with this test, particularly when
the blocksize of the test filesystem is different from the block size
of the $IMG_FILE filesystem.
So I started looking for fsblock discrepancies between
xfs_reproducible_test.img.[1-3] and noticed that EOF block contents are
different if the file being copied in has sparse holes in it that are
not aligned to the fsblock size of the new filesystem.
IOWs, if $TEST_DIR is a 1k fsblock filesystem and the $IMG_FILE
filesystems have 4k fsblocks, you can write 1k at odd offsets (e.g. 1k,
3k, 5k, 7k, etc) and the created file does not match the file in the
proto dir.
I traced this to design thinko in libxfs_file_write -- it assumes that
the caller always wants to write the full block, even if the buffer
passed in does not cover the entire range of the block. Therefore it'll
zero the head and the tail of the xfs_buf before writing it out.
Thus, the region at 1k causes mkfs to allocate fileoff 0 (which is a 4k
block). Then libxfs_file_write writes 1024 bytes of zeroes, 1024 bytes
of copied-in data, and 2048 bytes of more zeroes.
Next, the region at 3k causes mkfs to re-call libxfs_file_write, but
this time it writes 3072 bytes of zeroes and 1024 bytes of copied-in
data, thus obliterating the first write.
That bug's on me, and I'll fix it in writefile by rounding data_pos and
hole_pos outward as needed to be aligned to the block size of the copied
in filesystem. And I'll update xfs/841 to compare $PROTO_DIR against
what's in the new filesystem.
That fixes the data corruption problem, but then the test still fails
because now the space map isn't the same between mkfs invocations.
--D
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> tests/xfs/841 | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/xfs/841 b/tests/xfs/841
> index ee2368d4a746..ddb1b3bea104 100755
> --- a/tests/xfs/841
> +++ b/tests/xfs/841
> @@ -85,9 +85,12 @@ _create_proto_dir()
> $here/src/af_unix "$PROTO_DIR/socket" 2> /dev/null || true
>
> # Block device (requires root)
> - mknod "$PROTO_DIR/blockdev" b 1 0 2> /dev/null || true
> + # Uses the device for $TEST_DIR to ensure it always exists.
> + mknod "$PROTO_DIR/blockdev" b $(stat -c '%Hd %Ld' $TEST_DIR) \
> + 2> /dev/null || true
>
> # Character device (requires root)
> + # Uses /dev/null, which should always exist
> mknod "$PROTO_DIR/chardev" c 1 3 2> /dev/null || true
> }
>
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs/841: create a block device that must exist
2026-03-03 17:53 ` Darrick J. Wong
@ 2026-03-04 12:55 ` Christoph Hellwig
2026-03-04 16:49 ` Darrick J. Wong
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-03-04 12:55 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Christoph Hellwig, zlang, luca.dimaio1, linux-xfs, fstests
On Tue, Mar 03, 2026 at 09:53:00AM -0800, Darrick J. Wong wrote:
> On Mon, Feb 02, 2026 at 09:57:01AM +0100, Christoph Hellwig wrote:
> > This test currently creates a block device node for /dev/ram0,
> > which isn't guaranteed to exist, and can thus cause the test to
> > fail with:
> >
> > mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or address
> >
> > Instead, create a node for the backing device for $TEST_DIR, which must
> > exist.
>
> Hrm. I'm still noticing regressions with this test, particularly when
> the blocksize of the test filesystem is different from the block size
> of the $IMG_FILE filesystem.
That is with the test in general, and not because of the block device
fix, right? Your description seems to indicate that, I'm just a bit
confused as it is replying to my incremental patch.
> So I started looking for fsblock discrepancies between
> xfs_reproducible_test.img.[1-3] and noticed that EOF block contents are
> different if the file being copied in has sparse holes in it that are
> not aligned to the fsblock size of the new filesystem.
Oooh.
> Next, the region at 3k causes mkfs to re-call libxfs_file_write, but
> this time it writes 3072 bytes of zeroes and 1024 bytes of copied-in
> data, thus obliterating the first write.
>
> That bug's on me,
Yeah.
> and I'll fix it in writefile by rounding data_pos and
> hole_pos outward as needed to be aligned to the block size of the copied
> in filesystem. And I'll update xfs/841 to compare $PROTO_DIR against
> what's in the new filesystem.
>
> That fixes the data corruption problem, but then the test still fails
> because now the space map isn't the same between mkfs invocations.
Aarg. But I'm glad we got a test for this feature that's uncovering
old buggy/sloppy libxfs code..
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs/841: create a block device that must exist
2026-03-04 12:55 ` Christoph Hellwig
@ 2026-03-04 16:49 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2026-03-04 16:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: zlang, luca.dimaio1, linux-xfs, fstests
On Wed, Mar 04, 2026 at 01:55:02PM +0100, Christoph Hellwig wrote:
> On Tue, Mar 03, 2026 at 09:53:00AM -0800, Darrick J. Wong wrote:
> > On Mon, Feb 02, 2026 at 09:57:01AM +0100, Christoph Hellwig wrote:
> > > This test currently creates a block device node for /dev/ram0,
> > > which isn't guaranteed to exist, and can thus cause the test to
> > > fail with:
> > >
> > > mkfs.xfs: cannot open $TEST_DIR/proto/blockdev: No such device or address
> > >
> > > Instead, create a node for the backing device for $TEST_DIR, which must
> > > exist.
> >
> > Hrm. I'm still noticing regressions with this test, particularly when
> > the blocksize of the test filesystem is different from the block size
> > of the $IMG_FILE filesystem.
>
> That is with the test in general, and not because of the block device
> fix, right? Your description seems to indicate that, I'm just a bit
> confused as it is replying to my incremental patch.
Correct, I'm just complaining about x841 in general. Your bdev fix
eliminated one of the sources of test failures.
> > So I started looking for fsblock discrepancies between
> > xfs_reproducible_test.img.[1-3] and noticed that EOF block contents are
> > different if the file being copied in has sparse holes in it that are
> > not aligned to the fsblock size of the new filesystem.
>
> Oooh.
>
> > Next, the region at 3k causes mkfs to re-call libxfs_file_write, but
> > this time it writes 3072 bytes of zeroes and 1024 bytes of copied-in
> > data, thus obliterating the first write.
> >
> > That bug's on me,
>
> Yeah.
>
>
> > and I'll fix it in writefile by rounding data_pos and
> > hole_pos outward as needed to be aligned to the block size of the copied
> > in filesystem. And I'll update xfs/841 to compare $PROTO_DIR against
> > what's in the new filesystem.
> >
> > That fixes the data corruption problem, but then the test still fails
> > because now the space map isn't the same between mkfs invocations.
>
> Aarg. But I'm glad we got a test for this feature that's uncovering
> old buggy/sloppy libxfs code..
Yeah. I missed the detail that none of the existing protofile tests
actually tried to import sparse files, let alone checked the results.
I'll try to send the fix patches in a bit but QA blew up last night so I
should probably go figure out why there's suddenly log corruption, or if
some cloud thing got really FUBARd at 17:08 last night.
--D
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-04 16:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 8:57 [PATCH] xfs/841: create a block device that must exist Christoph Hellwig
2026-02-02 18:54 ` Luca Di Maio
2026-02-03 8:28 ` Zorro Lang
2026-03-03 17:53 ` Darrick J. Wong
2026-03-04 12:55 ` Christoph Hellwig
2026-03-04 16:49 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox