@@ -518,10 +518,31 @@ static inline void nvme_clear_nvme_request(struct request *req)
}
}
+static inline void nvme_init_req_from_cmd(struct request *req,
+ struct nvme_command *cmd)
+{
+ req->cmd_flags |= REQ_FAILFAST_DRIVER;
+ nvme_clear_nvme_request(req);
+ nvme_req(req)->cmd = cmd;
+}
+
+static inline unsigned int nvme_req_op(struct nvme_command *cmd)
+{
+ return nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
+}
+
+static inline void nvme_init_req_default_timeout(struct request *req)
+{
+ if (req->q->queuedata)
+ req->timeout = NVME_IO_TIMEOUT;
+ else /* no queuedata implies admin queue */
+ req->timeout = NVME_ADMIN_TIMEOUT;
+}
+
struct request *nvme_alloc_request(struct request_queue *q,
struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid)
{
- unsigned op = nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
+ unsigned op = nvme_req_op(cmd);
struct request *req;
if (qid == NVME_QID_ANY) {
@@ -533,14 +554,8 @@ 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 = NVME_ADMIN_TIMEOUT;
-
- req->cmd_flags |= REQ_FAILFAST_DRIVER;
- nvme_clear_nvme_request(req);
- nvme_req(req)->cmd = cmd;
+ nvme_init_req_timeout(req);
+ nvme_init_req_from_cmd(req, cmd);
return req;
}