Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

loop: change queue block size to match when using DIO

The loop driver assumes that if the passed in fd is opened with
O_DIRECT, the caller wants to use direct I/O on the loop device.
However, if the underlying block device has a different block size than
the loop block queue, direct I/O can't be enabled. Instead of requiring
userspace to manually change the blocksize and re-enable direct I/O,
just change the queue block sizes to match, as well as the io_min size.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martijn Coenen <maco@android.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Martijn Coenen and committed by
Jens Axboe
85560117 2d5ba0c7

+10
+10
drivers/block/loop.c
··· 994 994 if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync) 995 995 blk_queue_write_cache(lo->lo_queue, true, false); 996 996 997 + if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev) { 998 + /* In case of direct I/O, match underlying block size */ 999 + unsigned short bsize = bdev_logical_block_size( 1000 + inode->i_sb->s_bdev); 1001 + 1002 + blk_queue_logical_block_size(lo->lo_queue, bsize); 1003 + blk_queue_physical_block_size(lo->lo_queue, bsize); 1004 + blk_queue_io_min(lo->lo_queue, bsize); 1005 + } 1006 + 997 1007 loop_update_rotational(lo); 998 1008 loop_update_dio(lo); 999 1009 set_capacity(lo->lo_disk, size);