* [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 4:13 ` Wu Bo
0 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 4:13 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel; +Cc: linfeilong, wubo40
Hi,
Combine grpid and ANA state checks in nvme_parse_ana_log() to
reduce repetitive code and more intuitive meaning.
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/nvme/host/multipath.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f81871c..19fe16d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -522,13 +522,11 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
nr_nsids = le32_to_cpu(desc->nnsids);
nsid_buf_size = nr_nsids * sizeof(__le32);
- if (WARN_ON_ONCE(desc->grpid == 0))
+ if (WARN_ON_ONCE(desc->grpid == 0 ||
+ le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
return -EINVAL;
- if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state == 0))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
+ if (WARN_ON_ONCE(desc->state == 0 ||
+ desc->state > NVME_ANA_CHANGE))
return -EINVAL;
offset += sizeof(*desc);
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 4:13 ` Wu Bo
0 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 4:13 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel; +Cc: linfeilong, wubo40
Hi,
Combine grpid and ANA state checks in nvme_parse_ana_log() to
reduce repetitive code and more intuitive meaning.
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/nvme/host/multipath.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f81871c..19fe16d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -522,13 +522,11 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
nr_nsids = le32_to_cpu(desc->nnsids);
nsid_buf_size = nr_nsids * sizeof(__le32);
- if (WARN_ON_ONCE(desc->grpid == 0))
+ if (WARN_ON_ONCE(desc->grpid == 0 ||
+ le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
return -EINVAL;
- if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state == 0))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
+ if (WARN_ON_ONCE(desc->state == 0 ||
+ desc->state > NVME_ANA_CHANGE))
return -EINVAL;
offset += sizeof(*desc);
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
2021-06-08 4:13 ` Wu Bo
@ 2021-06-08 4:55 ` Chaitanya Kulkarni
-1 siblings, 0 replies; 10+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-08 4:55 UTC (permalink / raw)
To: Wu Bo, kbusch, axboe, hch, sagi, linux-nvme, linux-kernel; +Cc: linfeilong
On 6/7/21 20:59, Wu Bo wrote:
> Hi,
>
> Combine grpid and ANA state checks in nvme_parse_ana_log() to
> reduce repetitive code and more intuitive meaning.
>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
Existing code just looks fine...
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 4:55 ` Chaitanya Kulkarni
0 siblings, 0 replies; 10+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-08 4:55 UTC (permalink / raw)
To: Wu Bo, kbusch, axboe, hch, sagi, linux-nvme, linux-kernel; +Cc: linfeilong
On 6/7/21 20:59, Wu Bo wrote:
> Hi,
>
> Combine grpid and ANA state checks in nvme_parse_ana_log() to
> reduce repetitive code and more intuitive meaning.
>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
Existing code just looks fine...
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
2021-06-08 4:13 ` Wu Bo
@ 2021-06-08 5:23 ` Christoph Hellwig
-1 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-08 5:23 UTC (permalink / raw)
To: Wu Bo; +Cc: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel, linfeilong
On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
> - if (WARN_ON_ONCE(desc->grpid == 0))
> + if (WARN_ON_ONCE(desc->grpid == 0 ||
> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
> return -EINVAL;
> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
> - return -EINVAL;
> - if (WARN_ON_ONCE(desc->state == 0))
> - return -EINVAL;
> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
> + if (WARN_ON_ONCE(desc->state == 0 ||
> + desc->state > NVME_ANA_CHANGE))
So besides making the code impossibl to read due to the incorrect
indentation this also makes each WARN_ON_ONCE cover multiple conditions.
Not very useful for debugging.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 5:23 ` Christoph Hellwig
0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-08 5:23 UTC (permalink / raw)
To: Wu Bo; +Cc: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel, linfeilong
On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
> - if (WARN_ON_ONCE(desc->grpid == 0))
> + if (WARN_ON_ONCE(desc->grpid == 0 ||
> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
> return -EINVAL;
> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
> - return -EINVAL;
> - if (WARN_ON_ONCE(desc->state == 0))
> - return -EINVAL;
> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
> + if (WARN_ON_ONCE(desc->state == 0 ||
> + desc->state > NVME_ANA_CHANGE))
So besides making the code impossibl to read due to the incorrect
indentation this also makes each WARN_ON_ONCE cover multiple conditions.
Not very useful for debugging.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
2021-06-08 5:23 ` Christoph Hellwig
@ 2021-06-08 12:30 ` Wu Bo
-1 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 12:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, linux-nvme, linux-kernel, linfeilong
On 2021/6/8 13:23, Christoph Hellwig wrote:
> On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
>> - if (WARN_ON_ONCE(desc->grpid == 0))
>> + if (WARN_ON_ONCE(desc->grpid == 0 ||
>> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> return -EINVAL;
>> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state == 0))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
>> + if (WARN_ON_ONCE(desc->state == 0 ||
>> + desc->state > NVME_ANA_CHANGE))
>
> So besides making the code impossibl to read due to the incorrect
> indentation this also makes each WARN_ON_ONCE cover multiple conditions.
> Not very useful for debugging.
> Indeed, not very useful for debugging, please ignore this patch.
Thanks,
Wu Bo
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 12:30 ` Wu Bo
0 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 12:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, linux-nvme, linux-kernel, linfeilong
On 2021/6/8 13:23, Christoph Hellwig wrote:
> On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
>> - if (WARN_ON_ONCE(desc->grpid == 0))
>> + if (WARN_ON_ONCE(desc->grpid == 0 ||
>> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> return -EINVAL;
>> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state == 0))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
>> + if (WARN_ON_ONCE(desc->state == 0 ||
>> + desc->state > NVME_ANA_CHANGE))
>
> So besides making the code impossibl to read due to the incorrect
> indentation this also makes each WARN_ON_ONCE cover multiple conditions.
> Not very useful for debugging.
> Indeed, not very useful for debugging, please ignore this patch.
Thanks,
Wu Bo
>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
2021-06-08 5:23 ` Christoph Hellwig
@ 2021-06-08 12:32 ` Wu Bo
-1 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 12:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, linux-nvme, linux-kernel, linfeilong
On 2021/6/8 13:23, Christoph Hellwig wrote:
> On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
>> - if (WARN_ON_ONCE(desc->grpid == 0))
>> + if (WARN_ON_ONCE(desc->grpid == 0 ||
>> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> return -EINVAL;
>> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state == 0))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
>> + if (WARN_ON_ONCE(desc->state == 0 ||
>> + desc->state > NVME_ANA_CHANGE))
>
> So besides making the code impossibl to read due to the incorrect
> indentation this also makes each WARN_ON_ONCE cover multiple conditions.
> Not very useful for debugging.
> .
>
Indeed, not very useful for debugging, please ignore this patch.
Thanks,
Wu Bo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
@ 2021-06-08 12:32 ` Wu Bo
0 siblings, 0 replies; 10+ messages in thread
From: Wu Bo @ 2021-06-08 12:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, linux-nvme, linux-kernel, linfeilong
On 2021/6/8 13:23, Christoph Hellwig wrote:
> On Tue, Jun 08, 2021 at 12:13:36PM +0800, Wu Bo wrote:
>> - if (WARN_ON_ONCE(desc->grpid == 0))
>> + if (WARN_ON_ONCE(desc->grpid == 0 ||
>> + le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> return -EINVAL;
>> - if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state == 0))
>> - return -EINVAL;
>> - if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
>> + if (WARN_ON_ONCE(desc->state == 0 ||
>> + desc->state > NVME_ANA_CHANGE))
>
> So besides making the code impossibl to read due to the incorrect
> indentation this also makes each WARN_ON_ONCE cover multiple conditions.
> Not very useful for debugging.
> .
>
Indeed, not very useful for debugging, please ignore this patch.
Thanks,
Wu Bo
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-06-08 12:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 4:13 [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log() Wu Bo
2021-06-08 4:13 ` Wu Bo
2021-06-08 4:55 ` Chaitanya Kulkarni
2021-06-08 4:55 ` Chaitanya Kulkarni
2021-06-08 5:23 ` Christoph Hellwig
2021-06-08 5:23 ` Christoph Hellwig
2021-06-08 12:30 ` Wu Bo
2021-06-08 12:30 ` Wu Bo
2021-06-08 12:32 ` Wu Bo
2021-06-08 12:32 ` Wu Bo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.