From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: zlang@redhat.com, fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/4] xfs/259: try to force loop device block size
Date: Wed, 28 May 2025 15:36:25 -0700 [thread overview]
Message-ID: <20250528223625.GC8303@frogsfrogsfrogs> (raw)
In-Reply-To: <aC58FjhTGEDAQiGb@dread.disaster.area>
On Thu, May 22, 2025 at 11:21:26AM +1000, Dave Chinner wrote:
> On Wed, May 21, 2025 at 03:41:36PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Starting with 6.15-rc1, loop devices created with directio mode enabled
> > will set their logical block size to whatever STATX_DIO_ALIGN on the
> > host filesystem reports. If you happen to be running a kernel that
> > always sets up loop devices in directio mode and TEST_DEV is a block
> > device with 4k sectors, this will cause conflicts with this test's usage
> > of mkfs with different block sizes. Add a helper to force the loop
> > device block size to 512 bytes, which is implied by scenarios such as
> > "device size is 4T - 2048 bytes".
> >
> > Also fix xfs/078 which simply needs the blocksize to be set.
> >
> > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > ---
> > common/rc | 22 ++++++++++++++++++++++
> > tests/generic/563 | 1 +
> > tests/xfs/078 | 2 ++
> > tests/xfs/259 | 1 +
> > tests/xfs/613 | 1 +
> > 5 files changed, 27 insertions(+)
> >
> >
> > diff --git a/common/rc b/common/rc
> > index 657772e73db86b..4e3917a298e072 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -4526,6 +4526,28 @@ _create_loop_device()
> > echo $dev
> > }
> >
> > +# Configure the loop device however needed to support the given block size.
> > +_force_loop_device_blocksize()
> > +{
> > + local loopdev="$1"
> > + local blksize="$2"
> > + local is_dio
> > + local logsec
> > +
> > + if [ ! -b "$loopdev" ] || [ -z "$blksize" ]; then
> > + echo "_force_loop_device_blocksize requires loopdev and blksize" >&2
> > + return 1
> > + fi
> > +
> > + curr_blksize="$(losetup --list --output LOG-SEC --noheadings --raw "$loopdev")"
> > + if [ "$curr_blksize" -gt "$blksize" ]; then
> > + losetup --direct-io=off "$loopdev"
> > + losetup --sector-size "$blksize" "$loopdev"
> > + fi
> > +
> > + #losetup --raw --list "$loopdev" >> $seqres.full
> > +}
>
> I think it would make more sense to use a
> _create_loop_device_blocksize() wrapper function and change the call
> sites to use it that to add this function that requires error
> checking of the parameters even though it is only called directly
> after loop device creation.
>
> _create_loop_device_blocksize()
> {
> local file=$1
> local blksize=$2
>
> dev=`losetup -f --show $file --sector-size=$blksize`
>
> # If the loop device sector size is incompatible with doing
> # direct IO on the backing file, attempting to turn on
> # direct-io will fail with an -EINVAL error. However, the
> # device will still work correctly using buffered IO, so we
> # ignore the error.
> test -b "$dev" && losetup --direct-io=on $dev 2> /dev/null
> echo $dev
Yeah, I guess that works too.
--D
> }
>
> -Dave.
> --
> Dave Chinner
> david@fromorbit.com
>
next prev parent reply other threads:[~2025-05-28 22:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 22:40 [PATCHSET 1/2] fstests: check new 6.15 behaviors Darrick J. Wong
2025-05-21 22:41 ` [PATCH 1/4] xfs/273: fix test for internal zoned filesystems Darrick J. Wong
2025-05-23 5:17 ` Christoph Hellwig
2025-05-21 22:41 ` [PATCH 2/4] xfs/259: drop the 512-byte fsblock logic from this test Darrick J. Wong
2025-05-23 5:17 ` Christoph Hellwig
2025-05-21 22:41 ` [PATCH 3/4] xfs/259: try to force loop device block size Darrick J. Wong
2025-05-22 1:21 ` Dave Chinner
2025-05-28 22:36 ` Darrick J. Wong [this message]
2025-05-23 5:19 ` Christoph Hellwig
2025-05-28 22:22 ` Darrick J. Wong
2025-06-02 5:07 ` Christoph Hellwig
2025-06-03 14:36 ` Darrick J. Wong
2025-06-03 14:37 ` Christoph Hellwig
2025-05-21 22:41 ` [PATCH 4/4] xfs/432: fix metadump loop device blocksize problems Darrick J. Wong
2025-05-22 1:08 ` Dave Chinner
2025-05-28 22:37 ` Darrick J. Wong
2025-07-10 16:16 ` [PATCHSET 1/2] fstests: check new 6.15 behaviors Darrick J. Wong
2025-07-10 18:26 ` Zorro Lang
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=20250528223625.GC8303@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=fstests@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.