[PATCH V6 2/5] nvmet: add passthru admin timeout value attr
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Wed Nov 4 15:37:33 EST 2020
NVMeOF controller in the passsthru mode is capable of handling wide set
of admin commands including Vender unique passhtru admin comands (VUAC).
The VUACs are used to read the large driver logs and can take longer
than default NVMe commands, that is for passthru requests the timeout
value may differ from the passthru controller's default timeout values
(nvme-core:admin_timeout).
Add a configfs attribute so that user can set the admin timeout values.
In case if this configfs value is not set nvme_alloc_request() will set
use the ADMIN_TIMEOUT value.
This attribute setting is only allowed when ctrl is disable to avoid
rcu calls in the fast path, in future when needed we can always make it
fast path friendly using RCU.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/target/configfs.c | 32 ++++++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 1 +
drivers/nvme/target/passthru.c | 11 ++++++++++-
3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 37e1d7784e17..7625f8892fb5 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -736,9 +736,41 @@ static ssize_t nvmet_passthru_enable_store(struct config_item *item,
}
CONFIGFS_ATTR(nvmet_passthru_, enable);
+static ssize_t nvmet_passthru_admin_timeout_show(struct config_item *item,
+ char *page)
+{
+ return sprintf(page, "%u\n", to_subsys(item->ci_parent)->admin_timeout);
+}
+
+static ssize_t nvmet_passthru_admin_timeout_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct nvmet_subsys *subsys = to_subsys(item->ci_parent);
+ unsigned int admin_timeout;
+ int ret = 0;
+
+ mutex_lock(&subsys->lock);
+ if (subsys->passthru_ctrl) {
+ pr_err("disable passthru ctrl before setting admin_timeout\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (kstrtouint(page, 0, &admin_timeout)) {
+ ret = -EINVAL;
+ goto out;
+ }
+ subsys->admin_timeout = admin_timeout;
+out:
+ mutex_unlock(&subsys->lock);
+ return ret ? ret : count;
+}
+CONFIGFS_ATTR(nvmet_passthru_, admin_timeout);
+
static struct configfs_attribute *nvmet_passthru_attrs[] = {
&nvmet_passthru_attr_device_path,
&nvmet_passthru_attr_enable,
+ &nvmet_passthru_attr_admin_timeout,
NULL,
};
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 559a15ccc322..a0c80e5179a2 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -249,6 +249,7 @@ struct nvmet_subsys {
struct nvme_ctrl *passthru_ctrl;
char *passthru_ctrl_path;
struct config_group passthru_group;
+ unsigned int admin_timeout;
#endif /* CONFIG_NVME_TARGET_PASSTHRU */
};
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 2905c039b479..93d48b562f6d 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -221,6 +221,14 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
return 0;
}
+static inline unsigned int nvmet_passthru_req_timeout(struct nvmet_req *req,
+ struct request_queue *q)
+{
+ unsigned int admin_timeout = req->sq->ctrl->subsys->admin_timeout;
+
+ return q->queuedata == NULL ? admin_timeout : 0;
+}
+
static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
{
struct nvme_ctrl *ctrl = nvmet_req_passthru_ctrl(req);
@@ -244,7 +252,8 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
q = ns->queue;
}
- rq = nvme_alloc_request(q, req->cmd, 0, NVME_QID_ANY, 0);
+ rq = nvme_alloc_request(q, req->cmd, 0, NVME_QID_ANY,
+ nvmet_passthru_req_timeout(req, q));
if (IS_ERR(rq)) {
status = NVME_SC_INTERNAL;
goto out_put_ns;
--
2.22.1
More information about the Linux-nvme
mailing list