[PATCH 1/2] nvme: retry command if driver control flag given for passthru
From: Minwoo Im <hidden>
Date: 2021-02-15 13:06:12
Subsystem:
nvm express driver, the rest · Maintainers:
Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg, Linus Torvalds
ioctl passthru commands are REQ_FAILFAST_DRIVER requests which are non-retry requests if failed. This patch introduced `driver_ctrl` flag to the ioctl command structure: nvme_passthru_cmd, nvme_passthru_cmd64. `driver_ctrl` field has not been appended, but replaced existing reserved field. Clear the REQ_FAILFASTER_DRIVER flag from the request if `driver_ctrl` is given with NVME_DRIVER_CTRL_RETRY set to make it retry-able if failed without DNR. Signed-off-by: Minwoo Im <redacted> --- drivers/nvme/host/core.c | 12 ++++++++---- include/uapi/linux/nvme_ioctl.h | 15 +++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d77f3f26d8d3..20cd4a815944 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c@@ -1143,7 +1143,7 @@ EXPORT_SYMBOL_NS_GPL(nvme_execute_passthru_rq, NVME_TARGET_PASSTHRU); static int nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd, void __user *ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, - u32 meta_seed, u64 *result, unsigned timeout) + u32 meta_seed, u64 *result, unsigned timeout, u16 driver_ctrl) { bool write = nvme_is_write(cmd); struct nvme_ns *ns = q->queuedata;
@@ -1157,6 +1157,9 @@ static int nvme_submit_user_cmd(struct request_queue *q, if (IS_ERR(req)) return PTR_ERR(req); + if (driver_ctrl & NVME_DRIVER_CTRL_RETRY) + req->cmd_flags &= ~REQ_FAILFAST_DRIVER; + if (timeout) req->timeout = timeout; nvme_req(req)->flags |= NVME_REQ_USERCMD;
@@ -1615,7 +1618,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) return nvme_submit_user_cmd(ns->queue, &c, nvme_to_user_ptr(io.addr), length, - metadata, meta_len, lower_32_bits(io.slba), NULL, 0); + metadata, meta_len, lower_32_bits(io.slba), NULL, 0, + io.driver_ctrl); } static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
@@ -1653,7 +1657,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, nvme_to_user_ptr(cmd.addr), cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, - 0, &result, timeout); + 0, &result, timeout, cmd.driver_ctrl); if (status >= 0) { if (put_user(result, &ucmd->result))
@@ -1697,7 +1701,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns, status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, nvme_to_user_ptr(cmd.addr), cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, - 0, &cmd.result, timeout); + 0, &cmd.result, timeout, cmd.driver_ctrl); if (status >= 0) { if (put_user(cmd.result, &ucmd->result))
diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index d99b5a772698..b247b3eee2e3 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h@@ -14,7 +14,7 @@ struct nvme_user_io { __u8 flags; __u16 control; __u16 nblocks; - __u16 rsvd; + __u16 driver_ctrl; __u64 metadata; __u64 addr; __u64 slba;
@@ -27,7 +27,7 @@ struct nvme_user_io { struct nvme_passthru_cmd { __u8 opcode; __u8 flags; - __u16 rsvd1; + __u16 driver_ctrl; __u32 nsid; __u32 cdw2; __u32 cdw3;
@@ -48,7 +48,7 @@ struct nvme_passthru_cmd { struct nvme_passthru_cmd64 { __u8 opcode; __u8 flags; - __u16 rsvd1; + __u16 driver_ctrl; __u32 nsid; __u32 cdw2; __u32 cdw3;
@@ -63,7 +63,7 @@ struct nvme_passthru_cmd64 { __u32 cdw14; __u32 cdw15; __u32 timeout_ms; - __u32 rsvd2; + __u32 rsvd; __u64 result; };
@@ -79,4 +79,11 @@ struct nvme_passthru_cmd64 { #define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64) #define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64) +enum { + /* Retry command if failed with !DNR for <= nvme_max_retries */ + __NVME_DRIVER_CTRL_RETRY, +}; + +#define NVME_DRIVER_CTRL_RETRY (1 << __NVME_DRIVER_CTRL_RETRY) + #endif /* _UAPI_LINUX_NVME_IOCTL_H */
--
2.17.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme