Commit a2f6a2b8 authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Christoph Hellwig

nvmet: add passthru admin timeout value attr

NVMeOF controller in the passsthru mode is capable of handling wide set
of admin commands including vender specific passhtru admin comands.

The vendor specific admin commands are used to read the large drive
logs and can take longer than default NVMe commands, i.e. 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
the ADMIN_TIMEOUT value when request queuedata is NULL.
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent dc96f938
...@@ -736,9 +736,29 @@ static ssize_t nvmet_passthru_enable_store(struct config_item *item, ...@@ -736,9 +736,29 @@ static ssize_t nvmet_passthru_enable_store(struct config_item *item,
} }
CONFIGFS_ATTR(nvmet_passthru_, enable); 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 timeout;
if (kstrtouint(page, 0, &timeout))
return -EINVAL;
subsys->admin_timeout = timeout;
return count;
}
CONFIGFS_ATTR(nvmet_passthru_, admin_timeout);
static struct configfs_attribute *nvmet_passthru_attrs[] = { static struct configfs_attribute *nvmet_passthru_attrs[] = {
&nvmet_passthru_attr_device_path, &nvmet_passthru_attr_device_path,
&nvmet_passthru_attr_enable, &nvmet_passthru_attr_enable,
&nvmet_passthru_attr_admin_timeout,
NULL, NULL,
}; };
......
...@@ -249,6 +249,7 @@ struct nvmet_subsys { ...@@ -249,6 +249,7 @@ struct nvmet_subsys {
struct nvme_ctrl *passthru_ctrl; struct nvme_ctrl *passthru_ctrl;
char *passthru_ctrl_path; char *passthru_ctrl_path;
struct config_group passthru_group; struct config_group passthru_group;
unsigned int admin_timeout;
#endif /* CONFIG_NVME_TARGET_PASSTHRU */ #endif /* CONFIG_NVME_TARGET_PASSTHRU */
}; };
......
...@@ -227,6 +227,7 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req) ...@@ -227,6 +227,7 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
struct request_queue *q = ctrl->admin_q; struct request_queue *q = ctrl->admin_q;
struct nvme_ns *ns = NULL; struct nvme_ns *ns = NULL;
struct request *rq = NULL; struct request *rq = NULL;
unsigned int timeout = 0;
u32 effects; u32 effects;
u16 status; u16 status;
int ret; int ret;
...@@ -242,6 +243,8 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req) ...@@ -242,6 +243,8 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
} }
q = ns->queue; q = ns->queue;
} else {
timeout = req->sq->ctrl->subsys->admin_timeout;
} }
rq = nvme_alloc_request(q, req->cmd, 0, NVME_QID_ANY); rq = nvme_alloc_request(q, req->cmd, 0, NVME_QID_ANY);
...@@ -250,6 +253,9 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req) ...@@ -250,6 +253,9 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
goto out_put_ns; goto out_put_ns;
} }
if (timeout)
rq->timeout = timeout;
if (req->sg_cnt) { if (req->sg_cnt) {
ret = nvmet_passthru_map_sg(req, rq); ret = nvmet_passthru_map_sg(req, rq);
if (unlikely(ret)) { if (unlikely(ret)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment