Re: [PATCH 4/6] hw/nvme: Fix block accounting for compare

Klaus Jensen <[email protected]>
Newsgroups gmane.comp.emulators.qemu.block,gmane.comp.emulators.qemu
Message-ID <[email protected]>
On Jul 24 17:23, Hanna Czenczek wrote:
> nvme_compare() starts block accounting for the operation, but
> nvme_compare_data_cb() (and nvme_compare_mdata_cb()) do not always
> finalize the cookie.  Specifically, there are a lot of error paths that
> do not call block_acct_failed().
> 
> Fix this by putting block_acct_done()/block_acct_failed() under the
> `out` labels of nvme_compare_data_cb() and nvme_compare_mdata_cb().
> 
> Signed-off-by: Hanna Czenczek <[email protected]>

Reviewed-by: Klaus Jensen <[email protected]>

> ---
>  hw/nvme/ctrl.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 32e78881234..335498a2d73 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -2388,7 +2388,6 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>      trace_pci_nvme_compare_mdata_cb(nvme_cid(req));
>  
>      if (ret) {
> -        block_acct_failed(stats, acct);
>          req->status = NVME_UNRECOVERED_READ;
>  
>          trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status);
> @@ -2443,9 +2442,14 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>          goto out;
>      }
>  
> -    block_acct_done(stats, acct);
>  
>  out:
> +    if (req->status == NVME_SUCCESS) {
> +        block_acct_done(stats, acct);
> +    } else {
> +        block_acct_failed(stats, acct);
> +    }
> +
>      qemu_iovec_destroy(&ctx->data.iov);
>      g_free(ctx->data.bounce);
>  
> @@ -2473,7 +2477,6 @@ static void nvme_compare_data_cb(void *opaque, int ret)
>      trace_pci_nvme_compare_data_cb(nvme_cid(req));
>  
>      if (ret) {
> -        block_acct_failed(stats, acct);
>          req->status = NVME_UNRECOVERED_READ;
>  
>          trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status);
> @@ -2512,9 +2515,13 @@ static void nvme_compare_data_cb(void *opaque, int ret)
>          return;
>      }
>  
> -    block_acct_done(stats, acct);
> -
>  out:
> +    if (req->status == NVME_SUCCESS) {
> +        block_acct_done(stats, acct);
> +    } else {
> +        block_acct_failed(stats, acct);
> +    }
> +
>      qemu_iovec_destroy(&ctx->data.iov);
>      g_free(ctx->data.bounce);
>      g_free(ctx);
> -- 
> 2.55.0
> 
>
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmpp9Z0ACgkQTeGvMW1P
Denp9gf/TjLwbOeg5hxrGk+Vip8Anqf+D5DlN6YyepLV647mLGhasjQrbLe9/EwJ
2QKz2flyne05IrX0V1FE5GNiePvQkmx6edvczbbJbv8C6zrw6dGH693BwRP5UUeR
WSL7gNGXr79DCnZHTJXymBZonuhXmNdXvQj4yWVgCFR1qM/SirB6/uMF6xYHqk+c
GTpiBXeuburrGMD6+7Lzql/ohmoNYNCaj/yomSN5qPrl0yr4K13AJbqsCn8eYjR+
k/+9i9jF63wm8i+IKCu92//QeVjY/3gJFevGBZ4EiqnEbeDr8jR7OZf+KhAJuWpZ
V7nEk2m09j+nPoNOZjU4Z4cIrCoeBQ==
=CkzU
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.