Re: [PATCH v3] iomap: follow the alignment requirement for iomap_dio_hole_iter()
Qu Wenruo <[email protected]> Wed, 5 Aug 2026 07:01:20 +0930
| Newsgroups | gmane.comp.file-systems.btrfs,gmane.linux.file-systems |
|---|---|
| Message-ID | <[email protected]> |
=E5=9C=A8 2026/8/4 22:31, Christoph Hellwig =E5=86=99=E9=81=93:
> On Sat, Aug 01, 2026 at 07:17:26AM +0930, Qu Wenruo wrote:
>> +++ b/fs/iomap/direct-io.c
>> @@ -409,7 +409,10 @@ static inline unsigned int iomap_dio_alignment(str=
uct inode *inode,
>> {
>> if (dio_flags & IOMAP_DIO_FSBLOCK_ALIGNED)
>> return i_blocksize(inode);
>> - return bdev_logical_block_size(bdev);
>> + /* @bdev can be NULL for hole cases. */
>> + if (bdev)
>> + return bdev_logical_block_size(bdev);
>> + return SECTOR_SIZE;
>=20
> No. As said for previous versions you should not use
> iomap_dio_alignment. There is no such things as sub-fsblock alignment
> for holes. All mappings need to be aligned on fs blocks, you can do
> sub-mapping granularity I/O in it, but not align on it. So don't
> call iomap_dio_alignment, but instead align down the shortened range
> from the fault to a fs block boundary.
OK, got it now.
>=20
> And really sort out the btrfs locking that we can't get rid of this
> premature faulting as it keeps messing up core code way too much.
That will be a long term work, meanwhile I'm only fixing a short-term=20
bug, already affecting existing bs > ps support.
I hate the btrfs internal locking mechanism just as you, but it won't be=
=20
an easy thing to do in the short term.
Thanks,
Qu