]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet: add a helper function for cqid checking
authorWilfred Mallawa <wilfred.mallawa@wdc.com>
Thu, 24 Apr 2025 05:13:49 +0000 (15:13 +1000)
committerChristoph Hellwig <hch@lst.de>
Tue, 20 May 2025 03:34:25 +0000 (05:34 +0200)
This patch adds a new helper function nvmet_check_io_cqid(). It is to be
used when parsing host commands for IO CQ creation/deletion and IO SQ
creation to ensure that the specified IO completion queue identifier
(CQID) is not 0 (Admin queue ID). This is a check that already occurs in
the nvmet_execute_x() functions prior to nvmet_check_cqid.

With the addition of this helper function, the CQ ID checks in the
nvmet_execute_x() function can be removed, and instead simply call
nvmet_check_io_cqid() in place of nvmet_check_cqid().

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/core.c
drivers/nvme/target/nvmet.h

index acc138bbf8f23d537879c30069ca0096dfe9d693..753166fbb13323ab312133e95592ddd941690ad7 100644 (file)
@@ -96,12 +96,7 @@ static void nvmet_execute_delete_cq(struct nvmet_req *req)
                goto complete;
        }
 
-       if (!cqid) {
-               status = NVME_SC_QID_INVALID | NVME_STATUS_DNR;
-               goto complete;
-       }
-
-       status = nvmet_check_cqid(ctrl, cqid);
+       status = nvmet_check_io_cqid(ctrl, cqid);
        if (status != NVME_SC_SUCCESS)
                goto complete;
 
@@ -127,12 +122,7 @@ static void nvmet_execute_create_cq(struct nvmet_req *req)
                goto complete;
        }
 
-       if (!cqid) {
-               status = NVME_SC_QID_INVALID | NVME_STATUS_DNR;
-               goto complete;
-       }
-
-       status = nvmet_check_cqid(ctrl, cqid);
+       status = nvmet_check_io_cqid(ctrl, cqid);
        if (status != NVME_SC_SUCCESS)
                goto complete;
 
index 245475c43127fb4275c8458a0bd4471764d84fff..3fc2b548b36f6ba0bbc44df6b68e30318f940eeb 100644 (file)
@@ -859,6 +859,13 @@ u16 nvmet_check_cqid(struct nvmet_ctrl *ctrl, u16 cqid)
        return NVME_SC_SUCCESS;
 }
 
+u16 nvmet_check_io_cqid(struct nvmet_ctrl *ctrl, u16 cqid)
+{
+       if (!cqid)
+               return NVME_SC_QID_INVALID | NVME_STATUS_DNR;
+       return nvmet_check_cqid(ctrl, cqid);
+}
+
 u16 nvmet_cq_create(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq,
                    u16 qid, u16 size)
 {
index b6db8b74dc4ad3b3339637d97626827f469989bb..2f70db1284c92397dabddedba1c9d4375e6becbf 100644 (file)
@@ -572,6 +572,7 @@ void nvmet_execute_get_features(struct nvmet_req *req);
 void nvmet_execute_keep_alive(struct nvmet_req *req);
 
 u16 nvmet_check_cqid(struct nvmet_ctrl *ctrl, u16 cqid);
+u16 nvmet_check_io_cqid(struct nvmet_ctrl *ctrl, u16 cqid);
 void nvmet_cq_setup(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq, u16 qid,
                u16 size);
 u16 nvmet_cq_create(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq, u16 qid,