]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nvme: helper for uring-passthrough checks
authorKanchan Joshi <joshi.k@samsung.com>
Fri, 20 May 2022 09:06:29 +0000 (14:36 +0530)
committerJens Axboe <axboe@kernel.dk>
Fri, 20 May 2022 12:17:33 +0000 (06:17 -0600)
Factor out a helper consolidating the error checks, and fix typo in a
comment too. This is in preparation to support admin commands on this
path.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220520090630.70394-2-joshi.k@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/ioctl.c

index 7b0e2c9cdcae33ac32e4cec30f2a7e6817b21aec..114b490592b090f9f2df90ca24039444397ad8a7 100644 (file)
@@ -556,22 +556,30 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        return __nvme_ioctl(ns, cmd, (void __user *)arg);
 }
 
-static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
-                            unsigned int issue_flags)
+static int nvme_uring_cmd_checks(unsigned int issue_flags)
 {
-       struct nvme_ctrl *ctrl = ns->ctrl;
-       int ret;
-
-       BUILD_BUG_ON(sizeof(struct nvme_uring_cmd_pdu) > sizeof(ioucmd->pdu));
-
        /* IOPOLL not supported yet */
        if (issue_flags & IO_URING_F_IOPOLL)
                return -EOPNOTSUPP;
 
-       /* NVMe passthrough requires bit SQE/CQE support */
+       /* NVMe passthrough requires big SQE/CQE support */
        if ((issue_flags & (IO_URING_F_SQE128|IO_URING_F_CQE32)) !=
            (IO_URING_F_SQE128|IO_URING_F_CQE32))
                return -EOPNOTSUPP;
+       return 0;
+}
+
+static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
+                            unsigned int issue_flags)
+{
+       struct nvme_ctrl *ctrl = ns->ctrl;
+       int ret;
+
+       BUILD_BUG_ON(sizeof(struct nvme_uring_cmd_pdu) > sizeof(ioucmd->pdu));
+
+       ret = nvme_uring_cmd_checks(issue_flags);
+       if (ret)
+               return ret;
 
        switch (ioucmd->cmd_op) {
        case NVME_URING_CMD_IO: