diff mbox series

[3/4] loop: check in LO_FLAGS_DIRECT_IO in loop_default_blocksize

Message ID 20250131120120.1315125-4-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/4] loop: factor out a loop_assign_backing_file helper | expand

Commit Message

Christoph Hellwig Jan. 31, 2025, noon UTC
We can't go below the minimum direct I/O size no matter if direct I/O is
enabled by passing in an O_DIRECT file descriptor or due to the explicit
flag.  Now that LO_FLAGS_DIRECT_IO is set earlier after assigning a
backing file, loop_default_blocksize can check it instead of the
O_DIRECT flag to handle both conditions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Damien Le Moal Feb. 4, 2025, 12:56 a.m. UTC | #1
On 1/31/25 21:00, Christoph Hellwig wrote:
> We can't go below the minimum direct I/O size no matter if direct I/O is
> enabled by passing in an O_DIRECT file descriptor or due to the explicit
> flag.  Now that LO_FLAGS_DIRECT_IO is set earlier after assigning a
> backing file, loop_default_blocksize can check it instead of the
> O_DIRECT flag to handle both conditions.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 11f483d43bf4..36b01c36e06b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -979,7 +979,7 @@  static unsigned int loop_default_blocksize(struct loop_device *lo,
 		struct block_device *backing_bdev)
 {
 	/* In case of direct I/O, match underlying block size */
-	if ((lo->lo_backing_file->f_flags & O_DIRECT) && backing_bdev)
+	if ((lo->lo_flags & LO_FLAGS_DIRECT_IO) && backing_bdev)
 		return bdev_logical_block_size(backing_bdev);
 	return SECTOR_SIZE;
 }