From: Prasad Pandit <ppandit@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@redhat.com,
Prasad Pandit <pjp@fedoraproject.org>
Subject: [PATCH v2] linux-aio: add IO_CMD_FDSYNC command support
Date: Mon, 11 Mar 2024 11:13:33 +0530 [thread overview]
Message-ID: <20240311054333.1264776-1-ppandit@redhat.com> (raw)
From: Prasad Pandit <pjp@fedoraproject.org>
Libaio defines IO_CMD_FDSYNC command to sync all outstanding
asynchronous I/O operations, by flushing out file data to the
disk storage.
Enable linux-aio to submit such aio request. This helps to
reduce latency induced via pthread_create calls by
thread-pool (aio=threads).
Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
---
block/file-posix.c | 12 ++++++++++++
block/linux-aio.c | 5 ++++-
2 files changed, 16 insertions(+), 1 deletion(-)
v2: if IO_CMD_FDSYNC is not supported by the kernel,
fallback on thread-pool flush.
-> https://lists.nongnu.org/archive/html/qemu-devel/2024-03/msg01986.html
diff --git a/block/file-posix.c b/block/file-posix.c
index 35684f7e21..4f2195d01d 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2599,6 +2599,18 @@ static int coroutine_fn raw_co_flush_to_disk(BlockDriverState *bs)
if (raw_check_linux_io_uring(s)) {
return luring_co_submit(bs, s->fd, 0, NULL, QEMU_AIO_FLUSH);
}
+#endif
+#ifdef CONFIG_LINUX_AIO
+ if (raw_check_linux_aio(s)) {
+ ret = laio_co_submit(s->fd, 0, NULL, QEMU_AIO_FLUSH, 0);
+ if (ret >= 0) {
+ /*
+ * if AIO_FLUSH is supported return
+ * else fallback on thread-pool flush.
+ */
+ return ret;
+ }
+ }
#endif
return raw_thread_pool_submit(handle_aiocb_flush, &acb);
}
diff --git a/block/linux-aio.c b/block/linux-aio.c
index ec05d946f3..d940d029e3 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -384,6 +384,9 @@ static int laio_do_submit(int fd, struct qemu_laiocb *laiocb, off_t offset,
case QEMU_AIO_READ:
io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
+ case QEMU_AIO_FLUSH:
+ io_prep_fdsync(iocbs, fd);
+ break;
/* Currently Linux kernel does not support other operations */
default:
fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",
@@ -412,7 +415,7 @@ int coroutine_fn laio_co_submit(int fd, uint64_t offset, QEMUIOVector *qiov,
AioContext *ctx = qemu_get_current_aio_context();
struct qemu_laiocb laiocb = {
.co = qemu_coroutine_self(),
- .nbytes = qiov->size,
+ .nbytes = qiov ? qiov->size : 0,
.ctx = aio_get_linux_aio(ctx),
.ret = -EINPROGRESS,
.is_read = (type == QEMU_AIO_READ),
--
2.44.0
next reply other threads:[~2024-03-11 5:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 5:43 Prasad Pandit [this message]
2024-03-11 13:09 ` [PATCH v2] linux-aio: add IO_CMD_FDSYNC command support Stefan Hajnoczi
2024-03-11 15:40 ` Kevin Wolf
2024-03-11 19:36 ` Stefan Hajnoczi
2024-03-12 9:45 ` Kevin Wolf
2024-03-12 13:37 ` Prasad Pandit
2024-03-12 14:45 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240311054333.1264776-1-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=kwolf@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).