From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>,
axboe@kernel.dk, linux-block@vger.kernel.org
Subject: Re: [PATCH] loop: stop using vfs_iter_{read,write} for buffered I/O
Date: Thu, 10 Apr 2025 15:07:11 -0700 [thread overview]
Message-ID: <20250410220711.GU6307@frogsfrogsfrogs> (raw)
In-Reply-To: <20250410073439.GA461@lst.de>
On Thu, Apr 10, 2025 at 09:34:39AM +0200, Christoph Hellwig wrote:
> On Wed, Apr 09, 2025 at 09:44:41PM +0800, Ming Lei wrote:
> > On Wed, Apr 09, 2025 at 03:09:40PM +0200, Christoph Hellwig wrote:
> > > vfs_iter_{read,write} always perform direct I/O when the file has the
> > > O_DIRECT flag set, which breaks disabling direct I/O using the
> > > LOOP_SET_STATUS / LOOP_SET_STATUS64 ioctls.
> >
> > So dio is disabled automatically because lo_offset is changed in
> > LOOP_SET_STATUS, but backing file is still opened with O_DIRECT,
> > then dio fails?
> >
> > But Darrick reports it is caused by changing sector size, instead of
> > LOOP_SET_STATUS.
>
> LOOP_SET_STATUS changes the direct I/O flag.
>
> This is the minimal reproducer, dev needs to be a 4k lba size device:
>
> dev=/dev/nvme0n1
>
> mkfs.xfs -f $dev
> mount $dev /mnt
>
> truncate -s 30g /mnt/a
> losetup --direct-io=on -f --show /mnt/a
> losetup --direct-io=off /dev/loop0
> losetup --sector-size 2048 /dev/loop0
> mkfs.xfs /dev/loop0
>
> mkfs then fails with an I/O error.
>
> (I plan to wire up something like this for blktests)
Please cc me so I can pick through the test. :)
> > > This was recenly reported as a regression, but as far as I can tell
> > > was only uncovered by better checking for block sizes and has been
> > > around since the direct I/O support was added.
> >
> > What is the 1st real bad commit for this regression? I think it is useful
> > for backporting. Or it is new test case?
>
> Not entirely sure, maybe Darrick can fill in.
It was a surprisingly hard struggle to get losetup on RHEL8 and 9 to
cooperate. It doesn't look like 5.4 or 5.15 are affected. Regrettably
it's going to be harder to test 6.1 and 6.6 because I don't have kernels
at the ready, and grubby is a PITA to deal with.
--D
> >
> > >
> > > Fix this by using the existing aio code that calls the raw read/write
> > > iter methods instead. Note that despite the comments there is no need
> > > for block drivers to ever call flush_dcache_page themselves, and the
> > > call is a left-over from prehistoric times.
> > >
> > > Fixes: ab1cb278bc70 ("block: loop: introduce ioctl command of LOOP_SET_DIRECT_IO")
> >
> > Why is the issue related with ioctl(LOOP_SET_DIRECT_IO)?
> >
> >
> > Thanks,
> > Ming
> ---end quoted text---
next prev parent reply other threads:[~2025-04-10 22:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 13:09 [PATCH] loop: stop using vfs_iter_{read,write} for buffered I/O Christoph Hellwig
2025-04-09 13:44 ` Ming Lei
2025-04-10 7:34 ` Christoph Hellwig
2025-04-10 22:07 ` Darrick J. Wong [this message]
2025-04-15 3:33 ` Ming Lei
2025-04-15 3:41 ` Ming Lei
2025-04-16 0:47 ` Darrick J. Wong
2025-04-16 0:59 ` Jens Axboe
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=20250410220711.GU6307@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@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).