]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet: support for csi identify ns
authorKeith Busch <kbusch@kernel.org>
Fri, 1 Nov 2024 19:29:40 +0000 (12:29 -0700)
committerKeith Busch <kbusch@kernel.org>
Mon, 11 Nov 2024 17:49:49 +0000 (09:49 -0800)
Implements reporting the I/O Command Set Independent Identify Namespace
command.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/admin-cmd.c
include/linux/nvme.h

index 33b7ecfee3fec5452db19ca6b4dc60b08cd5d264..0a9fdc533186192da1e347fccd786d608a808c75 100644 (file)
@@ -912,6 +912,35 @@ out:
        nvmet_req_complete(req, status);
 }
 
+static void nvmet_execute_id_cs_indep(struct nvmet_req *req)
+{
+       struct nvme_id_ns_cs_indep *id;
+       u16 status;
+
+       status = nvmet_req_find_ns(req);
+       if (status)
+               goto out;
+
+       id = kzalloc(sizeof(*id), GFP_KERNEL);
+       if (!id) {
+               status = NVME_SC_INTERNAL;
+               goto out;
+       }
+
+       id->nstat = NVME_NSTAT_NRDY;
+       id->anagrpid = cpu_to_le32(req->ns->anagrpid);
+       id->nmic = NVME_NS_NMIC_SHARED;
+       if (req->ns->readonly)
+               id->nsattr |= NVME_NS_ATTR_RO;
+       if (req->ns->bdev && !bdev_nonrot(req->ns->bdev))
+               id->nsfeat |= NVME_NS_ROTATIONAL;
+
+       status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
+       kfree(id);
+out:
+       nvmet_req_complete(req, status);
+}
+
 static void nvmet_execute_identify(struct nvmet_req *req)
 {
        if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
@@ -959,6 +988,9 @@ static void nvmet_execute_identify(struct nvmet_req *req)
        case NVME_ID_CNS_NS_ACTIVE_LIST_CS:
                nvmet_execute_identify_nslist(req, true);
                return;
+       case NVME_ID_CNS_NS_CS_INDEP:
+               nvmet_execute_id_cs_indep(req);
+               return;
        case NVME_ID_CNS_ENDGRP_LIST:
                nvmet_execute_identify_endgrp_list(req);
                return;
index 99cf0ee73714201f70fa810820bf93a3767754f8..c136d64c7d73d05653629467681faa0a68ee2380 100644 (file)
@@ -563,6 +563,7 @@ enum {
        NVME_NS_FLBAS_LBA_SHIFT = 1,
        NVME_NS_FLBAS_META_EXT  = 0x10,
        NVME_NS_NMIC_SHARED     = 1 << 0,
+       NVME_NS_ROTATIONAL      = 1 << 4,
        NVME_LBAF_RP_BEST       = 0,
        NVME_LBAF_RP_BETTER     = 1,
        NVME_LBAF_RP_GOOD       = 2,