2019-01-08 03:10:22

by Andrey Smirnov

[permalink] [raw]
Subject: [PATCH] nvme-core: don't initlialize ctrl->cntlid twice

ctrl->cntlid will already be initialized from id->cntlid for
non-NVME_F_FABRICS controllers few lines below. For NVME_F_FABRICS
controllers this field should already be initialized, otherwise the
check

if (ctrl->cntlid != le16_to_cpu(id->cntlid))

below will always be a no-op.

Cc: Keith Busch <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Andrey Smirnov <[email protected]>
---

I created this patch just from readying NVMe code. Appologies for the
noise if I misread/misinterpreted things and this assignment is
actually necessary.

Thanks,
Andrey Smirnov

drivers/nvme/host/core.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 2e65be8b1387..1ec87b30fad1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2397,7 +2397,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
ctrl->oaes = le32_to_cpu(id->oaes);
atomic_set(&ctrl->abort_limit, id->acl + 1);
ctrl->vwc = id->vwc;
- ctrl->cntlid = le16_to_cpup(&id->cntlid);
if (id->mdts)
max_hw_sectors = 1 << (id->mdts + page_shift - 9);
else
--
2.20.1



2019-01-08 17:15:25

by Keith Busch

[permalink] [raw]
Subject: Re: [PATCH] nvme-core: don't initlialize ctrl->cntlid twice

On Mon, Jan 07, 2019 at 07:08:49PM -0800, Andrey Smirnov wrote:
> ctrl->cntlid will already be initialized from id->cntlid for
> non-NVME_F_FABRICS controllers few lines below. For NVME_F_FABRICS
> controllers this field should already be initialized, otherwise the
> check
>
> if (ctrl->cntlid != le16_to_cpu(id->cntlid))
>
> below will always be a no-op.

Yeah, this bug defeats the fabrics sanity check. Good catch.

Reviewed-by: Keith Busch <[email protected]>

> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 2e65be8b1387..1ec87b30fad1 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2397,7 +2397,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
> ctrl->oaes = le32_to_cpu(id->oaes);
> atomic_set(&ctrl->abort_limit, id->acl + 1);
> ctrl->vwc = id->vwc;
> - ctrl->cntlid = le16_to_cpup(&id->cntlid);
> if (id->mdts)
> max_hw_sectors = 1 << (id->mdts + page_shift - 9);
> else
> --

2019-01-09 20:50:33

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] nvme-core: don't initlialize ctrl->cntlid twice

Thanks,

applied to nvme-4.21.