From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Fam Zheng" <fam@euphon.net>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-block@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
pkrempa@redhat.com, "Hanna Reitz" <hreitz@redhat.com>
Subject: [PATCH 03/12] scsi: track per-SCSIRequest AioContext
Date: Thu, 13 Feb 2025 13:00:34 -0500 [thread overview]
Message-ID: <20250213180043.713434-4-stefanha@redhat.com> (raw)
In-Reply-To: <20250213180043.713434-1-stefanha@redhat.com>
Until now, a SCSIDevice's I/O requests have run in a single AioContext.
In order to support multiple IOThreads it will be necessary to move to
the concept of a per-SCSIRequest AioContext.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
include/hw/scsi/scsi.h | 1 +
hw/scsi/scsi-bus.c | 1 +
hw/scsi/scsi-disk.c | 17 ++++++-----------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index c3d5e17e38..ffc48203f9 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -24,6 +24,7 @@ struct SCSIRequest {
SCSIBus *bus;
SCSIDevice *dev;
const SCSIReqOps *ops;
+ AioContext *ctx;
uint32_t refcount;
uint32_t tag;
uint32_t lun;
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 7d4546800f..846bbbf0ec 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -868,6 +868,7 @@ invalid_opcode:
}
}
+ req->ctx = qemu_get_current_aio_context();
req->cmd = cmd;
req->residual = req->cmd.xfer;
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index f049a20275..7cf8c31b98 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -328,9 +328,8 @@ static void scsi_aio_complete(void *opaque, int ret)
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
- /* The request must only run in the BlockBackend's AioContext */
- assert(blk_get_aio_context(s->qdev.conf.blk) ==
- qemu_get_current_aio_context());
+ /* The request must run in its AioContext */
+ assert(r->req.ctx == qemu_get_current_aio_context());
assert(r->req.aiocb != NULL);
r->req.aiocb = NULL;
@@ -430,12 +429,10 @@ static void scsi_dma_complete(void *opaque, int ret)
static void scsi_read_complete_noio(SCSIDiskReq *r, int ret)
{
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
- /* The request must only run in the BlockBackend's AioContext */
- assert(blk_get_aio_context(s->qdev.conf.blk) ==
- qemu_get_current_aio_context());
+ /* The request must run in its AioContext */
+ assert(r->req.ctx == qemu_get_current_aio_context());
assert(r->req.aiocb == NULL);
if (scsi_disk_req_check_error(r, ret, ret > 0)) {
@@ -562,12 +559,10 @@ static void scsi_read_data(SCSIRequest *req)
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret)
{
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
- /* The request must only run in the BlockBackend's AioContext */
- assert(blk_get_aio_context(s->qdev.conf.blk) ==
- qemu_get_current_aio_context());
+ /* The request must run in its AioContext */
+ assert(r->req.ctx == qemu_get_current_aio_context());
assert (r->req.aiocb == NULL);
if (scsi_disk_req_check_error(r, ret, ret > 0)) {
--
2.48.1
next prev parent reply other threads:[~2025-02-13 18:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 18:00 [PATCH 00/12] virtio-scsi: add iothread-vq-mapping parameter Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 01/12] scsi-disk: drop unused SCSIDiskState->bh field Stefan Hajnoczi
2025-03-11 9:29 ` Philippe Mathieu-Daudé
2025-02-13 18:00 ` [PATCH 02/12] dma: use current AioContext for dma_blk_io() Stefan Hajnoczi
2025-02-13 18:00 ` Stefan Hajnoczi [this message]
2025-02-13 18:00 ` [PATCH 04/12] scsi: introduce requests_lock Stefan Hajnoczi
2025-03-10 13:37 ` Kevin Wolf
2025-03-11 9:11 ` Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 05/12] virtio-scsi: introduce event and ctrl virtqueue locks Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 06/12] virtio-scsi: protect events_dropped field Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 07/12] virtio-scsi: perform TMFs in appropriate AioContexts Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 08/12] virtio-blk: extract cleanup_iothread_vq_mapping() function Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 09/12] virtio-blk: tidy up iothread_vq_mapping functions Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 10/12] virtio: extract iothread-vq-mapping.h API Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 11/12] virtio-scsi: add iothread-vq-mapping parameter Stefan Hajnoczi
2025-03-10 14:33 ` Kevin Wolf
2025-03-10 14:37 ` Peter Krempa
2025-03-10 15:17 ` Kevin Wolf
2025-02-13 18:00 ` [PATCH 12/12] virtio-scsi: handle ctrl virtqueue in main loop Stefan Hajnoczi
2025-03-10 14:43 ` Kevin Wolf
2025-02-20 17:04 ` [PATCH 00/12] virtio-scsi: add iothread-vq-mapping parameter Peter Krempa
2025-03-10 14:43 ` Kevin Wolf
2025-03-11 9:22 ` 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=20250213180043.713434-4-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=david@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).