Re: [PATCH v3] iomap: follow the alignment requirement for iomap_dio_hole_iter()

Christoph Hellwig <[email protected]>
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.linux-btrfs,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
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(struct 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;

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.

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.