mirror of https://gitee.com/openkylin/qemu.git
scsi: Introduce scsi_req_cancel_complete
Let the aio cb do the clean up and notification job after scsi_req_cancel, in preparation for asynchronous cancellation. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a83cfd12d9
commit
d5776465ee
|
@ -1718,6 +1718,16 @@ void scsi_req_complete(SCSIRequest *req, int status)
|
|||
scsi_req_unref(req);
|
||||
}
|
||||
|
||||
/* Called by the devices when the request is canceled. */
|
||||
void scsi_req_cancel_complete(SCSIRequest *req)
|
||||
{
|
||||
assert(req->io_canceled);
|
||||
if (req->bus->info->cancel) {
|
||||
req->bus->info->cancel(req);
|
||||
}
|
||||
scsi_req_unref(req);
|
||||
}
|
||||
|
||||
void scsi_req_cancel(SCSIRequest *req)
|
||||
{
|
||||
trace_scsi_req_cancel(req->dev->id, req->lun, req->tag);
|
||||
|
@ -1730,10 +1740,6 @@ void scsi_req_cancel(SCSIRequest *req)
|
|||
if (req->aiocb) {
|
||||
bdrv_aio_cancel(req->aiocb);
|
||||
}
|
||||
if (req->bus->info->cancel) {
|
||||
req->bus->info->cancel(req);
|
||||
}
|
||||
scsi_req_unref(req);
|
||||
}
|
||||
|
||||
static int scsi_ua_precedence(SCSISense sense)
|
||||
|
|
|
@ -168,6 +168,7 @@ static void scsi_aio_complete(void *opaque, int ret)
|
|||
r->req.aiocb = NULL;
|
||||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -214,6 +215,7 @@ static void scsi_write_do_fua(SCSIDiskReq *r)
|
|||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
|
||||
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -240,6 +242,7 @@ static void scsi_dma_complete_noio(void *opaque, int ret)
|
|||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
}
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -280,6 +283,7 @@ static void scsi_read_complete(void * opaque, int ret)
|
|||
r->req.aiocb = NULL;
|
||||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -312,6 +316,7 @@ static void scsi_do_read(void *opaque, int ret)
|
|||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
}
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -432,6 +437,7 @@ static void scsi_write_complete(void * opaque, int ret)
|
|||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
}
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1524,6 +1530,7 @@ static void scsi_unmap_complete(void *opaque, int ret)
|
|||
|
||||
r->req.aiocb = NULL;
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1623,6 +1630,7 @@ static void scsi_write_same_complete(void *opaque, int ret)
|
|||
r->req.aiocb = NULL;
|
||||
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ static void scsi_command_complete(void *opaque, int ret)
|
|||
|
||||
r->req.aiocb = NULL;
|
||||
if (r->req.io_canceled) {
|
||||
scsi_req_cancel_complete(&r->req);
|
||||
goto done;
|
||||
}
|
||||
if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
|
||||
|
|
|
@ -264,6 +264,7 @@ void scsi_req_data(SCSIRequest *req, int len);
|
|||
void scsi_req_complete(SCSIRequest *req, int status);
|
||||
uint8_t *scsi_req_get_buf(SCSIRequest *req);
|
||||
int scsi_req_get_sense(SCSIRequest *req, uint8_t *buf, int len);
|
||||
void scsi_req_cancel_complete(SCSIRequest *req);
|
||||
void scsi_req_cancel(SCSIRequest *req);
|
||||
void scsi_req_retry(SCSIRequest *req);
|
||||
void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense);
|
||||
|
|
Loading…
Reference in New Issue