[PATCH V6 1/5] nvme: centralize setting req timeout

Christoph Hellwig hch at lst.de
Thu Nov 5 02:31:13 EST 2020


On Wed, Nov 04, 2020 at 12:37:32PM -0800, Chaitanya Kulkarni wrote:
>  
> +static inline void nvme_req_set_default_timeout(struct request *req)
> +{
> +	if (req->q->queuedata)
> +		req->timeout = NVME_IO_TIMEOUT;
> +	else /* no queuedata implies admin queue */
> +		req->timeout = ADMIN_TIMEOUT;
> +}

This just has a single caller now, so I think we can open code it.

> +
>  struct request *nvme_alloc_request(struct request_queue *q,
> -		struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid)
> +		struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid,
> +		unsigned int timeout)
>  {
>  	unsigned op = nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
>  	struct request *req;
> @@ -533,6 +542,11 @@ struct request *nvme_alloc_request(struct request_queue *q,
>  	if (IS_ERR(req))
>  		return req;
>  
> +	if (timeout)
> +		req->timeout = timeout;
> +	else
> +		nvme_req_set_default_timeout(req);

No need to pass the timeout argument here.  The callers that care
can set it in the caller instead of adding another parameter.



More information about the Linux-nvme mailing list