Commit 3c7b224f authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Christoph Hellwig

nvmet: remove extra variable in identify ns

We remove the extra local variable struct nvmet_ns in
nvmet_execute_identify_ns() since req already has ns member that can be
reused, this also eliminates the explicit call to nvmet_put_namespace()
which is already present in the request completion path.
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 3631c7f4
...@@ -467,7 +467,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) ...@@ -467,7 +467,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
static void nvmet_execute_identify_ns(struct nvmet_req *req) static void nvmet_execute_identify_ns(struct nvmet_req *req)
{ {
struct nvmet_ctrl *ctrl = req->sq->ctrl; struct nvmet_ctrl *ctrl = req->sq->ctrl;
struct nvmet_ns *ns;
struct nvme_id_ns *id; struct nvme_id_ns *id;
u16 status = 0; u16 status = 0;
...@@ -484,20 +483,21 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) ...@@ -484,20 +483,21 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
} }
/* return an all zeroed buffer if we can't find an active namespace */ /* return an all zeroed buffer if we can't find an active namespace */
ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid); req->ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid);
if (!ns) { if (!req->ns) {
status = NVME_SC_INVALID_NS; status = NVME_SC_INVALID_NS;
goto done; goto done;
} }
nvmet_ns_revalidate(ns); nvmet_ns_revalidate(req->ns);
/* /*
* nuse = ncap = nsze isn't always true, but we have no way to find * nuse = ncap = nsze isn't always true, but we have no way to find
* that out from the underlying device. * that out from the underlying device.
*/ */
id->ncap = id->nsze = cpu_to_le64(ns->size >> ns->blksize_shift); id->ncap = id->nsze =
switch (req->port->ana_state[ns->anagrpid]) { cpu_to_le64(req->ns->size >> req->ns->blksize_shift);
switch (req->port->ana_state[req->ns->anagrpid]) {
case NVME_ANA_INACCESSIBLE: case NVME_ANA_INACCESSIBLE:
case NVME_ANA_PERSISTENT_LOSS: case NVME_ANA_PERSISTENT_LOSS:
break; break;
...@@ -506,8 +506,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) ...@@ -506,8 +506,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
break; break;
} }
if (ns->bdev) if (req->ns->bdev)
nvmet_bdev_set_limits(ns->bdev, id); nvmet_bdev_set_limits(req->ns->bdev, id);
/* /*
* We just provide a single LBA format that matches what the * We just provide a single LBA format that matches what the
...@@ -521,25 +521,24 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) ...@@ -521,25 +521,24 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
* controllers, but also with any other user of the block device. * controllers, but also with any other user of the block device.
*/ */
id->nmic = (1 << 0); id->nmic = (1 << 0);
id->anagrpid = cpu_to_le32(ns->anagrpid); id->anagrpid = cpu_to_le32(req->ns->anagrpid);
memcpy(&id->nguid, &ns->nguid, sizeof(id->nguid)); memcpy(&id->nguid, &req->ns->nguid, sizeof(id->nguid));
id->lbaf[0].ds = ns->blksize_shift; id->lbaf[0].ds = req->ns->blksize_shift;
if (ctrl->pi_support && nvmet_ns_has_pi(ns)) { if (ctrl->pi_support && nvmet_ns_has_pi(req->ns)) {
id->dpc = NVME_NS_DPC_PI_FIRST | NVME_NS_DPC_PI_LAST | id->dpc = NVME_NS_DPC_PI_FIRST | NVME_NS_DPC_PI_LAST |
NVME_NS_DPC_PI_TYPE1 | NVME_NS_DPC_PI_TYPE2 | NVME_NS_DPC_PI_TYPE1 | NVME_NS_DPC_PI_TYPE2 |
NVME_NS_DPC_PI_TYPE3; NVME_NS_DPC_PI_TYPE3;
id->mc = NVME_MC_EXTENDED_LBA; id->mc = NVME_MC_EXTENDED_LBA;
id->dps = ns->pi_type; id->dps = req->ns->pi_type;
id->flbas = NVME_NS_FLBAS_META_EXT; id->flbas = NVME_NS_FLBAS_META_EXT;
id->lbaf[0].ms = cpu_to_le16(ns->metadata_size); id->lbaf[0].ms = cpu_to_le16(req->ns->metadata_size);
} }
if (ns->readonly) if (req->ns->readonly)
id->nsattr |= (1 << 0); id->nsattr |= (1 << 0);
nvmet_put_namespace(ns);
done: done:
if (!status) if (!status)
status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment