From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Tal Zussman <tz2294@columbia.edu>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Hannes Reinecke <hare@kernel.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
John Garry <john.g.garry@oracle.com>,
Christian Brauner <brauner@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
Keith Busch <kbusch@kernel.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v3 2/7] block: take i_rwsem for the direct I/O write fallback
Date: Fri, 18 Sep 2026 11:55:50 +0900 [thread overview]
Message-ID: <aqynM1cSQbjXCMjT@shinmob> (raw)
In-Reply-To: <20260909-blkdev-fixes-v3-2-1a5222c6e8ad@columbia.edu>
On Sep 09, 2026 / 17:59, Tal Zussman wrote:
> Commit c0e473a0d226 ("block: fix race between set_blocksize and read
> paths") closed a race between set_blocksize() and block device I/O: with
> large sector size support, set_blocksize() can change i_blkbits and the
> mapping's minimum folio order while a concurrent reader still holds a
> folio of the old, smaller order, leading to crashes. In particular, it
> made blkdev_write_iter() wrap buffered writes in inode_lock_shared().
>
> However, the direct I/O fallback path was missed in that conversion.
> blkdev_write_iter() passes blkdev_buffered_write() as an argument to
> direct_write_fallback() with no lock held. A direct write that completes
> only partially then finishes as a buffered write with no protection.
[...]
> Fix this by calling blkdev_buffered_write() in the fallback path under
> inode_lock_shared(), matching the plain buffered-write branch. With the
> fix the same workload runs clean.
>
> A short IOCB_NOWAIT direct write reaches the same fallback. Taking
> i_rwsem there can now block behind set_blocksize(), and the fallback
> already blocks on writeback of the data it copied in
> direct_write_fallback(). blkdev_write_iter() already rejects a purely
> buffered IOCB_NOWAIT write with -EOPNOTSUPP, so do not enter the
> fallback for IOCB_NOWAIT at all: return the bytes the direct path
> already wrote, or -EAGAIN if none, and let the caller retry.
>
> The reproducer used was written by an LLM, and is available at [1].
>
> [1] https://gist.github.com/tzussman/69d06bc57d42a42989eb038b1b5aeb74
>
> Fixes: 3c20917120ce ("block/bdev: enable large folio support for large logical block sizes")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/20260730-blk-dontcache-v7-0-3e8e6850068d%40columbia.edu?part=5
> Assisted-by: Claude:claude-fable-5
> Reviewed-by: Hannes Reinecke <hare@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
I confirmed that this patch avoids the hang triggered by the corresponding, new
blktests test case [*].
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
[*] https://lore.kernel.org/linux-block/20260909-blkdev-fixes-tests-v1-1-1f8af8665d16@columbia.edu/
next prev parent reply other threads:[~2026-09-18 2:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 21:59 [PATCH v3 0/7] block device fixes for large block sizes, IOCB_NOWAIT, and direct I/O Tal Zussman
2026-09-09 21:59 ` [PATCH v3 1/7] block: use iomap_dirty_folio for block devices Tal Zussman
2026-09-09 21:59 ` [PATCH v3 2/7] block: take i_rwsem for the direct I/O write fallback Tal Zussman
2026-09-18 2:55 ` Shin'ichiro Kawasaki [this message]
2026-09-09 21:59 ` [PATCH v3 3/7] block: take i_rwsem for the splice read path Tal Zussman
2026-09-18 2:57 ` Shin'ichiro Kawasaki
2026-09-18 7:25 ` Christoph Hellwig
2026-09-09 21:59 ` [PATCH v3 4/7] block: honor IOCB_NOWAIT in the block device buffered " Tal Zussman
2026-09-09 22:05 ` [PATCH v3 6/7] block: unpin all pages of a bvec in bio_iov_iter_align_down() Tal Zussman
2026-09-18 3:26 ` Shin'ichiro Kawasaki
2026-09-18 8:43 ` Christoph Hellwig
2026-09-09 22:05 ` [PATCH v3 5/7] block: fail atomic writes instead of falling back to buffered I/O Tal Zussman
2026-09-10 6:40 ` John Garry
2026-09-13 20:48 ` Tal Zussman
2026-09-09 22:05 ` [PATCH v3 7/7] block: remove dead metadata handling from the async direct I/O path Tal Zussman
2026-09-10 10:40 ` Hannes Reinecke
2026-09-13 20:12 ` Tal Zussman
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=aqynM1cSQbjXCMjT@shinmob \
--to=shinichiro.kawasaki@wdc.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--cc=john.g.garry@oracle.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mcgrof@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=tz2294@columbia.edu \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®