[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/12] linux-aio: add `dev_max_batch` parameter to laio_io_unplug(
From: |
Kevin Wolf |
Subject: |
[PULL 08/12] linux-aio: add `dev_max_batch` parameter to laio_io_unplug() |
Date: |
Tue, 2 Nov 2021 17:05:24 +0100 |
From: Stefano Garzarella <sgarzare@redhat.com>
Between the submission of a request and the unplug, other devices
with larger limits may have been queued new requests without flushing
the batch.
Using the new `dev_max_batch` parameter, laio_io_unplug() can check
if the batch exceeds the device limit to flush the current batch.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20211026162346.253081-4-sgarzare@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/raw-aio.h | 3 ++-
block/file-posix.c | 2 +-
block/linux-aio.c | 8 +++++---
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h
index ebd042fa27..21fc10c4c9 100644
--- a/include/block/raw-aio.h
+++ b/include/block/raw-aio.h
@@ -56,7 +56,8 @@ int coroutine_fn laio_co_submit(BlockDriverState *bs,
LinuxAioState *s, int fd,
void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context);
void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context);
void laio_io_plug(BlockDriverState *bs, LinuxAioState *s);
-void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s);
+void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
+ uint64_t dev_max_batch);
#endif
/* io_uring.c - Linux io_uring implementation */
#ifdef CONFIG_LINUX_IO_URING
diff --git a/block/file-posix.c b/block/file-posix.c
index c2c94fca66..7a27c83060 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2125,7 +2125,7 @@ static void raw_aio_unplug(BlockDriverState *bs)
#ifdef CONFIG_LINUX_AIO
if (s->use_linux_aio) {
LinuxAioState *aio = aio_get_linux_aio(bdrv_get_aio_context(bs));
- laio_io_unplug(bs, aio);
+ laio_io_unplug(bs, aio, s->aio_max_batch);
}
#endif
#ifdef CONFIG_LINUX_IO_URING
diff --git a/block/linux-aio.c b/block/linux-aio.c
index 88b44fee72..f53ae72e21 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -356,11 +356,13 @@ void laio_io_plug(BlockDriverState *bs, LinuxAioState *s)
s->io_q.plugged++;
}
-void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s)
+void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
+ uint64_t dev_max_batch)
{
assert(s->io_q.plugged);
- if (--s->io_q.plugged == 0 &&
- !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
+ if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
+ (--s->io_q.plugged == 0 &&
+ !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
ioq_submit(s);
}
}
--
2.31.1
- [PULL 00/12] Block layer patches, Kevin Wolf, 2021/11/02
- [PULL 02/12] block: Fail gracefully when blockdev-snapshot creates loops, Kevin Wolf, 2021/11/02
- [PULL 01/12] block/file-posix: Fix return value translation for AIO discards, Kevin Wolf, 2021/11/02
- [PULL 03/12] block/rbd: implement bdrv_co_block_status, Kevin Wolf, 2021/11/02
- [PULL 04/12] ide: Cap LBA28 capacity announcement to 2^28-1, Kevin Wolf, 2021/11/02
- [PULL 05/12] block/export/fuse.c: fix musl build, Kevin Wolf, 2021/11/02
- [PULL 09/12] block-backend: Silence clang -m32 compiler warning, Kevin Wolf, 2021/11/02
- [PULL 11/12] block/nvme: Display CQ/SQ pointer in nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 08/12] linux-aio: add `dev_max_batch` parameter to laio_io_unplug(),
Kevin Wolf <=
- [PULL 12/12] block/nvme: Extract nvme_free_queue() from nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 10/12] block/nvme: Automatically free qemu_memalign() with QEMU_AUTO_VFREE, Kevin Wolf, 2021/11/02
- [PULL 06/12] file-posix: add `aio-max-batch` option, Kevin Wolf, 2021/11/02
- [PULL 07/12] linux-aio: add `dev_max_batch` parameter to laio_co_submit(), Kevin Wolf, 2021/11/02
- Re: [PULL 00/12] Block layer patches, Richard Henderson, 2021/11/03