* [PATCH] nvmet: return all zeroed buffer when we can't find an active namespace
@ 2018-05-30 16:45 Christoph Hellwig
2018-05-31 16:23 ` [PATCH v2] " Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-05-30 16:45 UTC (permalink / raw)
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>
---
drivers/nvme/target/admin-cmd.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index b2ba95b2eef7..7f906e4ccc96 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -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);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2] nvmet: return all zeroed buffer when we can't find an active namespace
2018-05-30 16:45 [PATCH] nvmet: return all zeroed buffer when we can't find an active namespace Christoph Hellwig
@ 2018-05-31 16:23 ` Christoph Hellwig
2018-06-03 12:13 ` Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-05-31 16:23 UTC (permalink / raw)
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>
---
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(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index b2ba95b2eef7..64a12d4d7607 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -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);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2] nvmet: return all zeroed buffer when we can't find an active namespace
2018-05-31 16:23 ` [PATCH v2] " Christoph Hellwig
@ 2018-06-03 12:13 ` Sagi Grimberg
2018-06-03 13:17 ` Max Gurtovoy
2018-06-04 11:35 ` Johannes Thumshirn
2 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-06-03 12:13 UTC (permalink / raw)
Reviewed-by: Sagi Grimberg <sagi at rimberg.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] nvmet: return all zeroed buffer when we can't find an active namespace
2018-05-31 16:23 ` [PATCH v2] " Christoph Hellwig
2018-06-03 12:13 ` Sagi Grimberg
@ 2018-06-03 13:17 ` Max Gurtovoy
2018-06-04 11:35 ` Johannes Thumshirn
2 siblings, 0 replies; 5+ messages in thread
From: Max Gurtovoy @ 2018-06-03 13:17 UTC (permalink / raw)
On 5/31/2018 7:23 PM, Christoph Hellwig wrote:
> 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>
> ---
>
> 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(-)
>
Looks good,
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] nvmet: return all zeroed buffer when we can't find an active namespace
2018-05-31 16:23 ` [PATCH v2] " Christoph Hellwig
2018-06-03 12:13 ` Sagi Grimberg
2018-06-03 13:17 ` Max Gurtovoy
@ 2018-06-04 11:35 ` Johannes Thumshirn
2 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2018-06-04 11:35 UTC (permalink / raw)
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-04 11:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30 16:45 [PATCH] nvmet: return all zeroed buffer when we can't find an active namespace Christoph Hellwig
2018-05-31 16:23 ` [PATCH v2] " Christoph Hellwig
2018-06-03 12:13 ` Sagi Grimberg
2018-06-03 13:17 ` Max Gurtovoy
2018-06-04 11:35 ` Johannes Thumshirn
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.