@@ -2614,7 +2614,7 @@ static void nvme_copy_bh(void *opaque)
qemu_aio_unref(iocb);
}
-static void nvme_copy_cb(void *opaque, int ret);
+static void nvme_do_copy(NvmeCopyAIOCB *iocb);
static void nvme_copy_source_range_parse_format0(void *ranges, int idx,
uint64_t *slba, uint32_t *nlb,
@@ -2726,7 +2726,7 @@ static void nvme_copy_out_completed_cb(void *opaque, int ret)
iocb->idx++;
iocb->slba += nlb;
out:
- nvme_copy_cb(iocb, iocb->ret);
+ nvme_do_copy(iocb);
}
static void nvme_copy_out_cb(void *opaque, int ret)
@@ -2738,16 +2738,8 @@ static void nvme_copy_out_cb(void *opaque, int ret)
size_t mlen;
uint8_t *mbounce;
- if (ret < 0) {
- iocb->ret = ret;
+ if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) {
goto out;
- } else if (iocb->ret < 0) {
- goto out;
- }
-
- if (!ns->lbaf.ms) {
- nvme_copy_out_completed_cb(iocb, 0);
- return;
}
nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, NULL,
@@ -2766,7 +2758,7 @@ static void nvme_copy_out_cb(void *opaque, int ret)
return;
out:
- nvme_copy_cb(iocb, ret);
+ nvme_copy_out_completed_cb(iocb, ret);
}
static void nvme_copy_in_completed_cb(void *opaque, int ret)
@@ -2860,15 +2852,9 @@ static void nvme_copy_in_completed_cb(void *opaque, int ret)
invalid:
req->status = status;
- iocb->aiocb = NULL;
- if (iocb->bh) {
- qemu_bh_schedule(iocb->bh);
- }
-
- return;
-
+ iocb->ret = -1;
out:
- nvme_copy_cb(iocb, ret);
+ nvme_do_copy(iocb);
}
static void nvme_copy_in_cb(void *opaque, int ret)
@@ -2879,16 +2865,8 @@ static void nvme_copy_in_cb(void *opaque, int ret)
uint64_t slba;
uint32_t nlb;
- if (ret < 0) {
- iocb->ret = ret;
+ if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) {
goto out;
- } else if (iocb->ret < 0) {
- goto out;
- }
-
- if (!ns->lbaf.ms) {
- nvme_copy_in_completed_cb(iocb, 0);
- return;
}
nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &slba,
@@ -2904,12 +2882,11 @@ static void nvme_copy_in_cb(void *opaque, int ret)
return;
out:
- nvme_copy_cb(iocb, iocb->ret);
+ nvme_copy_in_completed_cb(iocb, ret);
}
-static void nvme_copy_cb(void *opaque, int ret)
+static void nvme_do_copy(NvmeCopyAIOCB *iocb)
{
- NvmeCopyAIOCB *iocb = opaque;
NvmeRequest *req = iocb->req;
NvmeNamespace *ns = req->ns;
uint64_t slba;
@@ -2917,10 +2894,7 @@ static void nvme_copy_cb(void *opaque, int ret)
size_t len;
uint16_t status;
- if (ret < 0) {
- iocb->ret = ret;
- goto done;
- } else if (iocb->ret < 0) {
+ if (iocb->ret < 0) {
goto done;
}
@@ -2967,6 +2941,7 @@ static void nvme_copy_cb(void *opaque, int ret)
invalid:
req->status = status;
+ iocb->ret = -1;
done:
iocb->aiocb = NULL;
if (iocb->bh) {
@@ -2974,7 +2949,6 @@ done:
}
}
-
static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req)
{
NvmeNamespace *ns = req->ns;
@@ -3060,7 +3034,7 @@ static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req)
BLOCK_ACCT_WRITE);
req->aiocb = &iocb->common;
- nvme_copy_cb(iocb, 0);
+ nvme_do_copy(iocb);
return NVME_NO_COMPLETE;