[PATCH] hw/nvme: set DNR on compare failure

Klaus Jensen posted 1 patch 1 year, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220825053221.130428-1-its@irrelevant.dk
Maintainers: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>
hw/nvme/ctrl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] hw/nvme: set DNR on compare failure
Posted by Klaus Jensen 1 year, 8 months ago
From: Klaus Jensen <k.jensen@samsung.com>

Even if the host is somehow using compare to do compare-and-write, the
host should be notified immediately about the compare failure and not
have to wait for the driver to potentially retry the command.

Reported-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 87aeba056499..299cbb1f2205 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -2242,7 +2242,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
 
         for (bufp = buf; mbufp < end; bufp += ns->lbaf.ms, mbufp += ns->lbaf.ms) {
             if (memcmp(bufp + pil, mbufp + pil, ns->lbaf.ms - pil)) {
-                req->status = NVME_CMP_FAILURE;
+                req->status = NVME_CMP_FAILURE | NVME_DNR;
                 goto out;
             }
         }
@@ -2251,7 +2251,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
     }
 
     if (memcmp(buf, ctx->mdata.bounce, ctx->mdata.iov.size)) {
-        req->status = NVME_CMP_FAILURE;
+        req->status = NVME_CMP_FAILURE | NVME_DNR;
         goto out;
     }
 
@@ -2300,7 +2300,7 @@ static void nvme_compare_data_cb(void *opaque, int ret)
     }
 
     if (memcmp(buf, ctx->data.bounce, ctx->data.iov.size)) {
-        req->status = NVME_CMP_FAILURE;
+        req->status = NVME_CMP_FAILURE | NVME_DNR;
         goto out;
     }
 
-- 
2.37.2
Re: [PATCH] hw/nvme: set DNR on compare failure
Posted by Klaus Jensen 1 year, 6 months ago
On Aug 25 07:32, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Even if the host is somehow using compare to do compare-and-write, the
> host should be notified immediately about the compare failure and not
> have to wait for the driver to potentially retry the command.
> 
> Reported-by: Jim Harris <james.r.harris@intel.com>
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/nvme/ctrl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 87aeba056499..299cbb1f2205 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -2242,7 +2242,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>  
>          for (bufp = buf; mbufp < end; bufp += ns->lbaf.ms, mbufp += ns->lbaf.ms) {
>              if (memcmp(bufp + pil, mbufp + pil, ns->lbaf.ms - pil)) {
> -                req->status = NVME_CMP_FAILURE;
> +                req->status = NVME_CMP_FAILURE | NVME_DNR;
>                  goto out;
>              }
>          }
> @@ -2251,7 +2251,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
>      }
>  
>      if (memcmp(buf, ctx->mdata.bounce, ctx->mdata.iov.size)) {
> -        req->status = NVME_CMP_FAILURE;
> +        req->status = NVME_CMP_FAILURE | NVME_DNR;
>          goto out;
>      }
>  
> @@ -2300,7 +2300,7 @@ static void nvme_compare_data_cb(void *opaque, int ret)
>      }
>  
>      if (memcmp(buf, ctx->data.bounce, ctx->data.iov.size)) {
> -        req->status = NVME_CMP_FAILURE;
> +        req->status = NVME_CMP_FAILURE | NVME_DNR;
>          goto out;
>      }
>  
> -- 
> 2.37.2
> 

Bump :)