diff options
author | Christoph Hellwig <hch@lst.de> | 2018-05-31 18:23:48 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-06-08 20:51:09 +0200 |
commit | f39ae4719b1c33d048aa4d3c284d82ecf252742b (patch) | |
tree | 43973b2767d46325876629ab6f2cd7fcabaf8b7a /drivers/nvme | |
parent | md: Unify mddev destruction paths (diff) | |
download | linux-f39ae4719b1c33d048aa4d3c284d82ecf252742b.tar.xz linux-f39ae4719b1c33d048aa4d3c284d82ecf252742b.zip |
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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@rimberg.me>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/target/admin-cmd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index ead8fbe6922e..962532842769 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -270,8 +270,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; } @@ -279,9 +278,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. @@ -306,11 +310,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); } |