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: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Родитель
3631c7f4a2
Коммит
3c7b224f19
|
@ -467,7 +467,6 @@ out:
|
|||
static void nvmet_execute_identify_ns(struct nvmet_req *req)
|
||||
{
|
||||
struct nvmet_ctrl *ctrl = req->sq->ctrl;
|
||||
struct nvmet_ns *ns;
|
||||
struct nvme_id_ns *id;
|
||||
u16 status = 0;
|
||||
|
||||
|
@ -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 */
|
||||
ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid);
|
||||
if (!ns) {
|
||||
req->ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid);
|
||||
if (!req->ns) {
|
||||
status = NVME_SC_INVALID_NS;
|
||||
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
|
||||
* that out from the underlying device.
|
||||
*/
|
||||
id->ncap = id->nsze = cpu_to_le64(ns->size >> ns->blksize_shift);
|
||||
switch (req->port->ana_state[ns->anagrpid]) {
|
||||
id->ncap = id->nsze =
|
||||
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_PERSISTENT_LOSS:
|
||||
break;
|
||||
|
@ -506,8 +506,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
|
|||
break;
|
||||
}
|
||||
|
||||
if (ns->bdev)
|
||||
nvmet_bdev_set_limits(ns->bdev, id);
|
||||
if (req->ns->bdev)
|
||||
nvmet_bdev_set_limits(req->ns->bdev, id);
|
||||
|
||||
/*
|
||||
* 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)
|
|||
* controllers, but also with any other user of the block device.
|
||||
*/
|
||||
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 |
|
||||
NVME_NS_DPC_PI_TYPE1 | NVME_NS_DPC_PI_TYPE2 |
|
||||
NVME_NS_DPC_PI_TYPE3;
|
||||
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->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);
|
||||
nvmet_put_namespace(ns);
|
||||
done:
|
||||
if (!status)
|
||||
status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
|
||||
|
|
Загрузка…
Ссылка в новой задаче