scsi-generic: Handle canceled request in scsi_command_complete
Now that we always called the cb in bdrv_aio_cancel, let's make scsi-generic callbacks check io_canceled flag similarly to scsi-disk. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
eda470e41a
commit
6c25fa6cf8
@ -93,6 +93,9 @@ static void scsi_command_complete(void *opaque, int ret)
|
||||
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
|
||||
|
||||
r->req.aiocb = NULL;
|
||||
if (r->req.io_canceled) {
|
||||
goto done;
|
||||
}
|
||||
if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
|
||||
r->req.sense_len = r->io_header.sb_len_wr;
|
||||
}
|
||||
@ -133,6 +136,7 @@ static void scsi_command_complete(void *opaque, int ret)
|
||||
r, r->req.tag, status);
|
||||
|
||||
scsi_req_complete(&r->req, status);
|
||||
done:
|
||||
if (!r->req.io_canceled) {
|
||||
scsi_req_unref(&r->req);
|
||||
}
|
||||
@ -186,8 +190,7 @@ static void scsi_read_complete(void * opaque, int ret)
|
||||
int len;
|
||||
|
||||
r->req.aiocb = NULL;
|
||||
if (ret) {
|
||||
DPRINTF("IO error ret %d\n", ret);
|
||||
if (ret || r->req.io_canceled) {
|
||||
scsi_command_complete(r, ret);
|
||||
return;
|
||||
}
|
||||
@ -246,8 +249,7 @@ static void scsi_write_complete(void * opaque, int ret)
|
||||
|
||||
DPRINTF("scsi_write_complete() ret = %d\n", ret);
|
||||
r->req.aiocb = NULL;
|
||||
if (ret) {
|
||||
DPRINTF("IO error\n");
|
||||
if (ret || r->req.io_canceled) {
|
||||
scsi_command_complete(r, ret);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user