[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 1/8] blkio: add io_uring block driver using libblkio
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC v2 1/8] blkio: add io_uring block driver using libblkio |
Date: |
Thu, 7 Apr 2022 08:22:15 +0100 |
On Wed, Apr 06, 2022 at 07:32:04PM +0200, Kevin Wolf wrote:
> Am 05.04.2022 um 17:33 hat Stefan Hajnoczi geschrieben:
> > libblkio (https://gitlab.com/libblkio/libblkio/) is a library for
> > high-performance disk I/O. It currently supports io_uring with
> > additional drivers planned.
> >
> > One of the reasons for developing libblkio is that other applications
> > besides QEMU can use it. This will be particularly useful for
> > vhost-user-blk which applications may wish to use for connecting to
> > qemu-storage-daemon.
> >
> > libblkio also gives us an opportunity to develop in Rust behind a C API
> > that is easy to consume from QEMU.
> >
> > This commit adds an io_uring BlockDriver to QEMU using libblkio. For now
> > I/O buffers are copied through bounce buffers if the libblkio driver
> > requires it. Later commits add an optimization for pre-registering guest
> > RAM to avoid bounce buffers. It will be easy to add other libblkio
> > drivers since they will share the majority of code.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> > +static BlockDriver bdrv_io_uring = {
> > + .format_name = "io_uring",
> > + .protocol_name = "io_uring",
> > + .instance_size = sizeof(BDRVBlkioState),
> > + .bdrv_needs_filename = true,
> > + .bdrv_parse_filename = blkio_parse_filename_io_uring,
> > + .bdrv_file_open = blkio_file_open,
> > + .bdrv_close = blkio_close,
> > + .bdrv_getlength = blkio_getlength,
> > + .has_variable_length = true,
>
> This one is a bad idea. It means that every request will call
> blkio_getlength() first, which looks up the "capacity" property in
> libblkio and then calls lseek() for the io_uring backend.
Thanks for pointing this out. I didn't think this through. More below on
what I was trying to do.
> For other backends like the vhost_user one (where I just copied your
> definition and then noticed this behaviour), it involve a message over
> the vhost socket, which is even worse.
(A vhost-user-blk driver could cache the capacity field and update it
when a Configuration Change Notification is received. There is no need
to send a vhost-user protocol message every time.)
> .has_variable_length was only meant for the host_floppy/cdrom drivers
> that have to deal with media change. Everything else just requires an
> explicit block_resize monitor command to be resized.
I was trying to support devices that can be resized below QEMU (e.g.
vhost-user-blk, vhost-vdpa-blk, and virtio-blk-pci). That was
unnecessary since QEMU doesn't support that model. If an LVM volume is
resized, for example, you still need to execute a monitor command to let
QEMU know.
I'll drop .has_variable_length.
Stefan
signature.asc
Description: PGP signature
[RFC v2 3/8] block: pass size to bdrv_unregister_buf(), Stefan Hajnoczi, 2022/04/05
[RFC v2 4/8] block: add BDRV_REQ_REGISTERED_BUF request flag, Stefan Hajnoczi, 2022/04/05
[RFC v2 5/8] block: add BlockRAMRegistrar, Stefan Hajnoczi, 2022/04/05
[RFC v2 6/8] stubs: add memory_region_from_host() and memory_region_get_fd(), Stefan Hajnoczi, 2022/04/05
[RFC v2 7/8] blkio: implement BDRV_REQ_REGISTERED_BUF optimization, Stefan Hajnoczi, 2022/04/05
[RFC v2 8/8] virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint, Stefan Hajnoczi, 2022/04/05
[RFC v2 2/8] numa: call ->ram_block_removed() in ram_block_notifer_remove(), Stefan Hajnoczi, 2022/04/05