OSDN Git Service

nvme: centralize setting the timeout in nvme_alloc_request
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Tue, 10 Nov 2020 00:33:42 +0000 (16:33 -0800)
committerChristoph Hellwig <hch@lst.de>
Tue, 1 Dec 2020 19:36:35 +0000 (20:36 +0100)
The function nvme_alloc_request() is called from different context
(I/O and Admin queue) where callers do not consider the I/O timeout when
called from I/O queue context.

Update nvme_alloc_request() to set the default I/O and Admin timeout
value based on whether the queuedata is set or not.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c
drivers/nvme/host/lightnvm.c
drivers/nvme/host/pci.c

index 9b01afc..97348b1 100644 (file)
@@ -533,6 +533,11 @@ struct request *nvme_alloc_request(struct request_queue *q,
        if (IS_ERR(req))
                return req;
 
+       if (req->q->queuedata)
+               req->timeout = NVME_IO_TIMEOUT;
+       else /* no queuedata implies admin queue */
+               req->timeout = ADMIN_TIMEOUT;
+
        req->cmd_flags |= REQ_FAILFAST_DRIVER;
        nvme_clear_nvme_request(req);
        nvme_req(req)->cmd = cmd;
@@ -901,7 +906,8 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       req->timeout = timeout ? timeout : ADMIN_TIMEOUT;
+       if (timeout)
+               req->timeout = timeout;
 
        if (buffer && bufflen) {
                ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL);
@@ -1071,7 +1077,8 @@ static int nvme_submit_user_cmd(struct request_queue *q,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       req->timeout = timeout ? timeout : ADMIN_TIMEOUT;
+       if (timeout)
+               req->timeout = timeout;
        nvme_req(req)->flags |= NVME_REQ_USERCMD;
 
        if (ubuffer && bufflen) {
index 8e562d0..88a7c8e 100644 (file)
@@ -774,7 +774,8 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q,
                goto err_cmd;
        }
 
-       rq->timeout = timeout ? timeout : ADMIN_TIMEOUT;
+       if (timeout)
+               rq->timeout = timeout;
 
        if (ppa_buf && ppa_len) {
                ppa_list = dma_pool_alloc(dev->dma_pool, GFP_KERNEL, &ppa_dma);
index 0578ff2..76465d3 100644 (file)
@@ -1310,7 +1310,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
                return BLK_EH_RESET_TIMER;
        }
 
-       abort_req->timeout = ADMIN_TIMEOUT;
        abort_req->end_io_data = NULL;
        blk_execute_rq_nowait(abort_req->q, NULL, abort_req, 0, abort_endio);
 
@@ -2223,7 +2222,6 @@ static int nvme_delete_queue(struct nvme_queue *nvmeq, u8 opcode)
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       req->timeout = ADMIN_TIMEOUT;
        req->end_io_data = nvmeq;
 
        init_completion(&nvmeq->delete_done);