Skip to content

Commit e2758c7

Browse files
committed
nvmet: support for csi identify ns
Implements reporting the I/O Command Set Independent Identify Namespace command. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 5fd075c commit e2758c7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,35 @@ static void nvme_execute_identify_ns_nvm(struct nvmet_req *req)
912912
nvmet_req_complete(req, status);
913913
}
914914

915+
static void nvmet_execute_id_cs_indep(struct nvmet_req *req)
916+
{
917+
struct nvme_id_ns_cs_indep *id;
918+
u16 status;
919+
920+
status = nvmet_req_find_ns(req);
921+
if (status)
922+
goto out;
923+
924+
id = kzalloc(sizeof(*id), GFP_KERNEL);
925+
if (!id) {
926+
status = NVME_SC_INTERNAL;
927+
goto out;
928+
}
929+
930+
id->nstat = NVME_NSTAT_NRDY;
931+
id->anagrpid = cpu_to_le32(req->ns->anagrpid);
932+
id->nmic = NVME_NS_NMIC_SHARED;
933+
if (req->ns->readonly)
934+
id->nsattr |= NVME_NS_ATTR_RO;
935+
if (req->ns->bdev && !bdev_nonrot(req->ns->bdev))
936+
id->nsfeat |= NVME_NS_ROTATIONAL;
937+
938+
status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
939+
kfree(id);
940+
out:
941+
nvmet_req_complete(req, status);
942+
}
943+
915944
static void nvmet_execute_identify(struct nvmet_req *req)
916945
{
917946
if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
@@ -959,6 +988,9 @@ static void nvmet_execute_identify(struct nvmet_req *req)
959988
case NVME_ID_CNS_NS_ACTIVE_LIST_CS:
960989
nvmet_execute_identify_nslist(req, true);
961990
return;
991+
case NVME_ID_CNS_NS_CS_INDEP:
992+
nvmet_execute_id_cs_indep(req);
993+
return;
962994
case NVME_ID_CNS_ENDGRP_LIST:
963995
nvmet_execute_identify_endgrp_list(req);
964996
return;

include/linux/nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ enum {
563563
NVME_NS_FLBAS_LBA_SHIFT = 1,
564564
NVME_NS_FLBAS_META_EXT = 0x10,
565565
NVME_NS_NMIC_SHARED = 1 << 0,
566+
NVME_NS_ROTATIONAL = 1 << 4,
566567
NVME_LBAF_RP_BEST = 0,
567568
NVME_LBAF_RP_BETTER = 1,
568569
NVME_LBAF_RP_GOOD = 2,

0 commit comments

Comments
 (0)