Skip to content

Commit f8a654b

Browse files
Christoph Hellwigjfvogel
authored andcommitted
loop: check in LO_FLAGS_DIRECT_IO in loop_default_blocksize
[ Upstream commit f6f9e32fe1e454ae8ac0190b2c2bd6074914beec ] 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 <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 20a53c3689a20a5e34b88fc7705b7f0bf883eb1c) Signed-off-by: Jack Vogel <[email protected]>
1 parent 33cb624 commit f8a654b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static unsigned int loop_default_blocksize(struct loop_device *lo,
916916
struct block_device *backing_bdev)
917917
{
918918
/* In case of direct I/O, match underlying block size */
919-
if ((lo->lo_backing_file->f_flags & O_DIRECT) && backing_bdev)
919+
if ((lo->lo_flags & LO_FLAGS_DIRECT_IO) && backing_bdev)
920920
return bdev_logical_block_size(backing_bdev);
921921
return SECTOR_SIZE;
922922
}

0 commit comments

Comments
 (0)