diff mbox series

[1/2] hw/block/nvme: consider metadata read aio return value in compare

Message ID 20210416072234.25732-1-anaidu.gollu@samsung.com
State New
Headers show
Series [1/2] hw/block/nvme: consider metadata read aio return value in compare | expand

Commit Message

Gollu Appalanaidu April 16, 2021, 7:22 a.m. UTC
Currently in compare command metadata aio read blk_aio_preadv return
value ignored, consider it and complete the block accounting.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
---
 hw/block/nvme.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Klaus Jensen April 16, 2021, 12:06 p.m. UTC | #1
On Apr 16 12:52, Gollu Appalanaidu wrote:
>Currently in compare command metadata aio read blk_aio_preadv return
>value ignored, consider it and complete the block accounting.
>
>Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>---
> hw/block/nvme.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
>diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>index 624a1431d0..c2727540f1 100644
>--- a/hw/block/nvme.c
>+++ b/hw/block/nvme.c
>@@ -2369,10 +2369,19 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>     uint32_t reftag = le32_to_cpu(rw->reftag);
>     struct nvme_compare_ctx *ctx = req->opaque;
>     g_autofree uint8_t *buf = NULL;
>+    BlockBackend *blk = ns->blkconf.blk;
>+    BlockAcctCookie *acct = &req->acct;
>+    BlockAcctStats *stats = blk_get_stats(blk);
>     uint16_t status = NVME_SUCCESS;
>
>     trace_pci_nvme_compare_mdata_cb(nvme_cid(req));
>
>+    if (ret) {
>+        block_acct_failed(stats, acct);
>+        nvme_aio_err(req, ret);
>+        goto out;
>+    }
>+
>     buf = g_malloc(ctx->mdata.iov.size);
>
>     status = nvme_bounce_mdata(n, buf, ctx->mdata.iov.size,
>@@ -2421,6 +2430,8 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>         goto out;
>     }
>
>+    block_acct_done(stats, acct);
>+
> out:
>     qemu_iovec_destroy(&ctx->data.iov);
>     g_free(ctx->data.bounce);
>-- 
>2.17.1
>
>

Good fix, thanks! Since there is no crash, data corruption or other 
"bad" behavior, this isn't critical for v6.0.

Might consider it for a potential stable release though, so I'll add a 
Fixes: tag and queue it up.

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Klaus Jensen April 20, 2021, 7:58 p.m. UTC | #2
On Apr 16 12:52, Gollu Appalanaidu wrote:
>Currently in compare command metadata aio read blk_aio_preadv return
>value ignored, consider it and complete the block accounting.
>
>Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>---
> hw/block/nvme.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
>diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>index 624a1431d0..c2727540f1 100644
>--- a/hw/block/nvme.c
>+++ b/hw/block/nvme.c
>@@ -2369,10 +2369,19 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>     uint32_t reftag = le32_to_cpu(rw->reftag);
>     struct nvme_compare_ctx *ctx = req->opaque;
>     g_autofree uint8_t *buf = NULL;
>+    BlockBackend *blk = ns->blkconf.blk;
>+    BlockAcctCookie *acct = &req->acct;
>+    BlockAcctStats *stats = blk_get_stats(blk);
>     uint16_t status = NVME_SUCCESS;
>
>     trace_pci_nvme_compare_mdata_cb(nvme_cid(req));
>
>+    if (ret) {
>+        block_acct_failed(stats, acct);
>+        nvme_aio_err(req, ret);
>+        goto out;
>+    }
>+
>     buf = g_malloc(ctx->mdata.iov.size);
>
>     status = nvme_bounce_mdata(n, buf, ctx->mdata.iov.size,
>@@ -2421,6 +2430,8 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>         goto out;
>     }
>
>+    block_acct_done(stats, acct);
>+
> out:
>     qemu_iovec_destroy(&ctx->data.iov);
>     g_free(ctx->data.bounce);
>-- 
>2.17.1
>

Applied to nvme-next, thanks!
diff mbox series

Patch

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 624a1431d0..c2727540f1 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -2369,10 +2369,19 @@  static void nvme_compare_mdata_cb(void *opaque, int ret)
     uint32_t reftag = le32_to_cpu(rw->reftag);
     struct nvme_compare_ctx *ctx = req->opaque;
     g_autofree uint8_t *buf = NULL;
+    BlockBackend *blk = ns->blkconf.blk;
+    BlockAcctCookie *acct = &req->acct;
+    BlockAcctStats *stats = blk_get_stats(blk);
     uint16_t status = NVME_SUCCESS;
 
     trace_pci_nvme_compare_mdata_cb(nvme_cid(req));
 
+    if (ret) {
+        block_acct_failed(stats, acct);
+        nvme_aio_err(req, ret);
+        goto out;
+    }
+
     buf = g_malloc(ctx->mdata.iov.size);
 
     status = nvme_bounce_mdata(n, buf, ctx->mdata.iov.size,
@@ -2421,6 +2430,8 @@  static void nvme_compare_mdata_cb(void *opaque, int ret)
         goto out;
     }
 
+    block_acct_done(stats, acct);
+
 out:
     qemu_iovec_destroy(&ctx->data.iov);
     g_free(ctx->data.bounce);