[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAB0TPYHjPbzMNqS6wiYmjUjrmROSVVCYsSQLjwE+PUOBsMH_mw@mail.gmail.com>
Date: Tue, 10 Sep 2019 12:12:28 +0200
From: Martijn Coenen <maco@...roid.com>
To: Jens Axboe <axboe@...nel.dk>,
Christoph Hellwig <hch@...radead.org>,
Ming Lei <ming.lei@...hat.com>
Cc: linux-block <linux-block@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Greg KH <gregkh@...uxfoundation.org>, kernel-team@...roid.com,
Narayan Kamath <narayan@...gle.com>,
Dario Freni <dariofreni@...gle.com>,
Nikita Ioffe <ioffe@...gle.com>,
Jiyong Park <jiyong@...gle.com>,
Martijn Coenen <maco@...gle.com>
Subject: Re: [PATCH v2] loop: change queue block size to match when using DIO.
Hi Jens, Ming,
Do you have any thoughts about this patch?
Thanks,
Martijn
On Wed, Sep 4, 2019 at 9:49 PM Martijn Coenen <maco@...roid.com> wrote:
>
> 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.
>
> Signed-off-by: Martijn Coenen <maco@...roid.com>
> ---
> v2 changes:
> - Fixed commit message to say the block size must match the underlying
> block device, not the underlying filesystem.
> - Also set physical blocksize and minimal io size correspondingly.
>
> drivers/block/loop.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index ab7ca5989097a..b547182037af2 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -994,6 +994,16 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
> if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
> blk_queue_write_cache(lo->lo_queue, true, false);
>
> + if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev) {
> + /* In case of direct I/O, match underlying block size */
> + unsigned short bsize = bdev_logical_block_size(
> + inode->i_sb->s_bdev);
> +
> + blk_queue_logical_block_size(lo->lo_queue, bsize);
> + blk_queue_physical_block_size(lo->lo_queue, bsize);
> + blk_queue_io_min(lo->lo_queue, bsize);
> + }
> +
> loop_update_rotational(lo);
> loop_update_dio(lo);
> set_capacity(lo->lo_disk, size);
> --
> 2.23.0.187.g17f5b7556c-goog
>
Powered by blists - more mailing lists