[PATCH 0/2] block device write path fixes

From: Tal Zussman

Date: Sun Aug 02 2026 - 07:15:16 EST


Two independent fixes for the block device write path. Both issues were
found by Sashiko during review of the "block: enable RWF_DONTCACHE for
block devices" series [1] and are independent of it.

Patch 1 fixes silently lost mmap writes with CONFIG_BUFFER_HEAD=n:
def_blk_aops uses filemap_dirty_folio, which does not set the
per-block dirty bits in the folio's iomap_folio_state, so writeback
finds no dirty blocks and submits no I/O.

Patch 2 makes blkdev_write_iter() take i_rwsem shared around the
buffered-write fallback for a partial direct I/O write. The fallback
currently runs with no lock held and races set_blocksize() changing
i_blkbits and the mapping's minimum folio order, which can trip
VM_BUG_ON_FOLIO in __filemap_add_folio() on kernels with block sizes
above PAGE_SIZE.

Both issues are currently unlikely to be hit in practice due to the
specific configurations required to trigger them.

[1] https://lore.kernel.org/all/20260730-blk-dontcache-v7-0-3e8e6850068d@xxxxxxxxxxxx/

Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
Tal Zussman (2):
block: use iomap_dirty_folio for block devices
block: take i_rwsem for the direct I/O write fallback

block/fops.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff
change-id: 20260801-blkdev-fixes-771b1c314ebb

Best regards,
--
Tal Zussman <tz2294@xxxxxxxxxxxx>