[PATCH] hw/block/nvme: remove redundant invalid_lba_range trace

Gollu Appalanaidu posted 1 patch 3 years ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210414070435.3702-1-anaidu.gollu@samsung.com
Maintainers: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
hw/block/nvme.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
[PATCH] hw/block/nvme: remove redundant invalid_lba_range trace
Posted by Gollu Appalanaidu 3 years ago
Currently pci_nvme_err_invalid_lba_range tace being called indvidually
at each function, add this in nvme_check_bounds and remove redundant
usage of it.

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

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 6842b01ab5..c67d3315a1 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1424,6 +1424,7 @@ static inline uint16_t nvme_check_bounds(NvmeNamespace *ns, uint64_t slba,
     uint64_t nsze = le64_to_cpu(ns->id_ns.nsze);
 
     if (unlikely(UINT64_MAX - slba < nlb || slba + nlb > nsze)) {
+        trace_pci_nvme_err_invalid_lba_range(slba, nlb, nsze);
         return NVME_LBA_RANGE | NVME_DNR;
     }
 
@@ -2266,7 +2267,6 @@ static void nvme_copy_in_complete(NvmeRequest *req)
 
     status = nvme_check_bounds(ns, sdlba, ctx->nlb);
     if (status) {
-        trace_pci_nvme_err_invalid_lba_range(sdlba, ctx->nlb, ns->id_ns.nsze);
         goto invalid;
     }
 
@@ -2528,8 +2528,6 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
             uint32_t nlb = le32_to_cpu(range[i].nlb);
 
             if (nvme_check_bounds(ns, slba, nlb)) {
-                trace_pci_nvme_err_invalid_lba_range(slba, nlb,
-                                                     ns->id_ns.nsze);
                 continue;
             }
 
@@ -2602,7 +2600,6 @@ static uint16_t nvme_verify(NvmeCtrl *n, NvmeRequest *req)
 
     status = nvme_check_bounds(ns, slba, nlb);
     if (status) {
-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
         return status;
     }
 
@@ -2687,7 +2684,6 @@ static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req)
 
         status = nvme_check_bounds(ns, slba, _nlb);
         if (status) {
-            trace_pci_nvme_err_invalid_lba_range(slba, _nlb, ns->id_ns.nsze);
             goto out;
         }
 
@@ -2816,7 +2812,6 @@ static uint16_t nvme_compare(NvmeCtrl *n, NvmeRequest *req)
 
     status = nvme_check_bounds(ns, slba, nlb);
     if (status) {
-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
         return status;
     }
 
@@ -2935,7 +2930,6 @@ static uint16_t nvme_read(NvmeCtrl *n, NvmeRequest *req)
 
     status = nvme_check_bounds(ns, slba, nlb);
     if (status) {
-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
         goto invalid;
     }
 
@@ -3015,7 +3009,6 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
 
     status = nvme_check_bounds(ns, slba, nlb);
     if (status) {
-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
         goto invalid;
     }
 
-- 
2.17.1


Re: [PATCH] hw/block/nvme: remove redundant invalid_lba_range trace
Posted by Klaus Jensen 3 years ago
On Apr 14 12:34, Gollu Appalanaidu wrote:
>Currently pci_nvme_err_invalid_lba_range tace being called indvidually
>at each function, add this in nvme_check_bounds and remove redundant
>usage of it.
>
>Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>---
> hw/block/nvme.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
>diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>index 6842b01ab5..c67d3315a1 100644
>--- a/hw/block/nvme.c
>+++ b/hw/block/nvme.c
>@@ -1424,6 +1424,7 @@ static inline uint16_t nvme_check_bounds(NvmeNamespace *ns, uint64_t slba,
>     uint64_t nsze = le64_to_cpu(ns->id_ns.nsze);
>
>     if (unlikely(UINT64_MAX - slba < nlb || slba + nlb > nsze)) {
>+        trace_pci_nvme_err_invalid_lba_range(slba, nlb, nsze);
>         return NVME_LBA_RANGE | NVME_DNR;
>     }
>
>@@ -2266,7 +2267,6 @@ static void nvme_copy_in_complete(NvmeRequest *req)
>
>     status = nvme_check_bounds(ns, sdlba, ctx->nlb);
>     if (status) {
>-        trace_pci_nvme_err_invalid_lba_range(sdlba, ctx->nlb, ns->id_ns.nsze);
>         goto invalid;
>     }
>
>@@ -2528,8 +2528,6 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
>             uint32_t nlb = le32_to_cpu(range[i].nlb);
>
>             if (nvme_check_bounds(ns, slba, nlb)) {
>-                trace_pci_nvme_err_invalid_lba_range(slba, nlb,
>-                                                     ns->id_ns.nsze);
>                 continue;
>             }
>
>@@ -2602,7 +2600,6 @@ static uint16_t nvme_verify(NvmeCtrl *n, NvmeRequest *req)
>
>     status = nvme_check_bounds(ns, slba, nlb);
>     if (status) {
>-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
>         return status;
>     }
>
>@@ -2687,7 +2684,6 @@ static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req)
>
>         status = nvme_check_bounds(ns, slba, _nlb);
>         if (status) {
>-            trace_pci_nvme_err_invalid_lba_range(slba, _nlb, ns->id_ns.nsze);
>             goto out;
>         }
>
>@@ -2816,7 +2812,6 @@ static uint16_t nvme_compare(NvmeCtrl *n, NvmeRequest *req)
>
>     status = nvme_check_bounds(ns, slba, nlb);
>     if (status) {
>-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
>         return status;
>     }
>
>@@ -2935,7 +2930,6 @@ static uint16_t nvme_read(NvmeCtrl *n, NvmeRequest *req)
>
>     status = nvme_check_bounds(ns, slba, nlb);
>     if (status) {
>-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
>         goto invalid;
>     }
>
>@@ -3015,7 +3009,6 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
>
>     status = nvme_check_bounds(ns, slba, nlb);
>     if (status) {
>-        trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
>         goto invalid;
>     }
>

Thanks. Applied to nvme-next!
Re: [PATCH] hw/block/nvme: remove redundant invalid_lba_range trace
Posted by Philippe Mathieu-Daudé 3 years ago
On 4/14/21 9:04 AM, Gollu Appalanaidu wrote:
> Currently pci_nvme_err_invalid_lba_range tace being called indvidually

Typos "trace", "individually".

> at each function, add this in nvme_check_bounds and remove redundant
> usage of it.
> 
> Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
> ---
>  hw/block/nvme.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>