Skip to content

Commit 7eecba3

Browse files
stefanhaRHkevmw
authored andcommitted
scsi: track per-SCSIRequest AioContext
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 <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Message-ID: <[email protected]> Tested-by: Peter Krempa <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent a89c3c9 commit 7eecba3

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

hw/scsi/scsi-bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
868868
}
869869
}
870870

871+
req->ctx = qemu_get_current_aio_context();
871872
req->cmd = cmd;
872873
req->residual = req->cmd.xfer;
873874

hw/scsi/scsi-disk.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,8 @@ static void scsi_aio_complete(void *opaque, int ret)
328328
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
329329
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
330330

331-
/* The request must only run in the BlockBackend's AioContext */
332-
assert(blk_get_aio_context(s->qdev.conf.blk) ==
333-
qemu_get_current_aio_context());
331+
/* The request must run in its AioContext */
332+
assert(r->req.ctx == qemu_get_current_aio_context());
334333

335334
assert(r->req.aiocb != NULL);
336335
r->req.aiocb = NULL;
@@ -430,12 +429,10 @@ static void scsi_dma_complete(void *opaque, int ret)
430429

431430
static void scsi_read_complete_noio(SCSIDiskReq *r, int ret)
432431
{
433-
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
434432
uint32_t n;
435433

436-
/* The request must only run in the BlockBackend's AioContext */
437-
assert(blk_get_aio_context(s->qdev.conf.blk) ==
438-
qemu_get_current_aio_context());
434+
/* The request must run in its AioContext */
435+
assert(r->req.ctx == qemu_get_current_aio_context());
439436

440437
assert(r->req.aiocb == NULL);
441438
if (scsi_disk_req_check_error(r, ret, ret > 0)) {
@@ -562,12 +559,10 @@ static void scsi_read_data(SCSIRequest *req)
562559

563560
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret)
564561
{
565-
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
566562
uint32_t n;
567563

568-
/* The request must only run in the BlockBackend's AioContext */
569-
assert(blk_get_aio_context(s->qdev.conf.blk) ==
570-
qemu_get_current_aio_context());
564+
/* The request must run in its AioContext */
565+
assert(r->req.ctx == qemu_get_current_aio_context());
571566

572567
assert (r->req.aiocb == NULL);
573568
if (scsi_disk_req_check_error(r, ret, ret > 0)) {

include/hw/scsi/scsi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct SCSIRequest {
2424
SCSIBus *bus;
2525
SCSIDevice *dev;
2626
const SCSIReqOps *ops;
27+
AioContext *ctx;
2728
uint32_t refcount;
2829
uint32_t tag;
2930
uint32_t lun;

0 commit comments

Comments
 (0)