nvmet: return all zeroed buffer when we can't find an active namespace
Subsystems (2)
Christoph Hellwig
maintainerPATCH 1/1 nvmet: return all zeroed buffer when we can't find an active namespace
Quote from Figure 106 in NVMe 1.3a:
The Identify Namespace data structure is returned to the host for the namespace specified in the Namespace Identifier (CDW1.NSID) field if it is an active NSID. If the specified namespace is not an active NSID, then the controller returns a zero filled data structure.
--- drivers/nvme/target/admin-cmd.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/nvme/target/admin-cmd.c +13 -7
@@ -288,9 +288,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)struct nvmet_ns *ns;struct nvme_id_ns *id;u16 status =0 ; - - ns =nvmet_find_namespace (req->sq->ctrl, req->cmd->identify.nsid); -if (!ns) { + +if (le32_to_cpu (req->cmd->identify.nsid) ==NVME_NSID_ALL ) { status =NVME_SC_INVALID_NS |NVME_SC_DNR ; goto out; }
@@ -298,7 +297,15 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) id =kzalloc (sizeof (*id),GFP_KERNEL );if (!id) { status =NVME_SC_INTERNAL ; - goto out_put_ns; + goto out; + } + +/* return an all zeroed buffer if we can't find an active namespace */ + ns =nvmet_find_namespace (req->sq->ctrl, req->cmd->identify.nsid); +if (!ns) { +printk ("nsid %d not found\n" , +le32_to_cpu (req->cmd->identify.nsid)); + goto done; }/*
@@ -325,11 +332,10 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) id->lbaf[0 ].ds = ns->blksize_shift; +nvmet_put_namespace (ns); +done: status =nvmet_copy_to_sgl (req,0 , id,sizeof (*id)); -kfree (id); -out_put_ns: -nvmet_put_namespace (ns); out:nvmet_req_complete (req, status); }
Signature · 1 line
2.17.0
Christoph Hellwig
maintainerPATCH v2 1/1 nvmet: return all zeroed buffer when we can't find an active namespace
Quote from Figure 106 in NVMe 1.3a:
The Identify Namespace data structure is returned to the host for the namespace specified in the Namespace Identifier (CDW1.NSID) field if it is an active NSID. If the specified namespace is not an active NSID, then the controller returns a zero filled data structure.
---
Changes since v1:
- remove a leftover debug printk
- fix whitespace damage
drivers/nvme/target/admin-cmd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/nvme/target/admin-cmd.c +9 -6
@@ -289,8 +289,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)struct nvme_id_ns *id;u16 status =0 ; - ns =nvmet_find_namespace (req->sq->ctrl, req->cmd->identify.nsid); -if (!ns) { +if (le32_to_cpu (req->cmd->identify.nsid) ==NVME_NSID_ALL ) { status =NVME_SC_INVALID_NS |NVME_SC_DNR ; goto out; }
@@ -298,9 +297,14 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) id =kzalloc (sizeof (*id),GFP_KERNEL );if (!id) { status =NVME_SC_INTERNAL ; - goto out_put_ns; + goto out; } +/* return an all zeroed buffer if we can't find an active namespace */ + ns =nvmet_find_namespace (req->sq->ctrl, req->cmd->identify.nsid); +if (!ns) + goto done; +/* * nuse = ncap = nsze isn't always true, but we have no way to find * that out from the underlying device.
@@ -325,11 +329,10 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) id->lbaf[0 ].ds = ns->blksize_shift; +nvmet_put_namespace (ns); +done: status =nvmet_copy_to_sgl (req,0 , id,sizeof (*id)); -kfree (id); -out_put_ns: -nvmet_put_namespace (ns); out:nvmet_req_complete (req, status); }
Signature · 1 line
2.17.0
Sagi Grimberg
maintainerPATCH v2 1/1 nvmet: return all zeroed buffer when we can't find an active namespace
PATCH v2 1/1 nvmet: return all zeroed buffer when we can't find an active namespace
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
Quote from Figure 106 in NVMe 1.3a:
The Identify Namespace data structure is returned to the host for the namespace specified in the Namespace Identifier (CDW1.NSID) field if it is an active NSID. If the specified namespace is not an active NSID, then the controller returns a zero filled data structure.
Signed-off-by Christoph Hellwig <hch at lst.de>
Quoted 9 lines
---
Changes since v1:
- remove a leftover debug printk
- fix whitespace damagedrivers/nvme/target/admin-cmd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Looks good,
PATCH v2 1/1 nvmet: return all zeroed buffer when we can't find an active namespace
In reply to Christoph HellwigLooks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850