/** * blk_complete_request - end I/O on a request * @req: the request being processed * * Description: * Ends all I/O on a request. It does not handle partial completions, * unless the driver actually implements this in its completion callback * through requeueing. The actual completion happens out-of-order, * through a softirq handler. The user must have registered a completion * callback through blk_queue_softirq_done(). **/ void blk_complete_request(struct request *req) { if (unlikely(blk_should_fake_timeout(req->q))) return; if (!blk_mark_rq_complete(req)) __blk_complete_request(req); }
/** * blk_complete_request - end I/O on a request * @req: the request being processed * * Description: * Ends all I/O on a request. It does not handle partial completions, * unless the driver actually implements this in its completion callback * through requeueing. The actual completion happens out-of-order, * through a softirq handler. The user must have registered a completion * callback through blk_queue_softirq_done(). **/ void blk_complete_request(struct request *req) { /* Linux允许程序员通过注入错误的方式来模拟故障,来检查程序对故障的处理是否完善 */ if (unlikely(blk_should_fake_timeout(req->q))) /* 检查注入错误 */ return; if (!blk_mark_rq_complete(req)) /* 原子地设置REQ_ATOM_COMPLETE */ __blk_complete_request(req); }
/** * blk_abort_request -- Request request recovery for the specified command * @req: pointer to the request of interest * * This function requests that the block layer start recovery for the * request by deleting the timer and calling the q's timeout function. * LLDDs who implement their own error recovery MAY ignore the timeout * event if they generated blk_abort_req. Must hold queue lock. */ void blk_abort_request(struct request *req) { if (blk_mark_rq_complete(req)) return; blk_delete_timer(req); blk_rq_timed_out(req); }
/** * blk_complete_request - end I/O on a request * @req: the request being processed * * Description: * Ends all I/O on a request. It does not handle partial completions, * unless the driver actually implements this in its completion callback * through requeueing. The actual completion happens out-of-order, * through a softirq handler. The user must have registered a completion * callback through blk_queue_softirq_done(). **/ void blk_complete_request(struct request *req) { if (unlikely(blk_should_fake_timeout(req->q))) return; #ifdef CONFIG_HISI_IO_LATENCY_TRACE req_latency_check(req,REQ_PROC_STAGE_COMPLETE); #endif if (!blk_mark_rq_complete(req)) __blk_complete_request(req); }
/** * blk_abort_request -- Request request recovery for the specified command * @req: pointer to the request of interest * * This function requests that the block layer start recovery for the * request by deleting the timer and calling the q's timeout function. * LLDDs who implement their own error recovery MAY ignore the timeout * event if they generated blk_abort_req. Must hold queue lock. */ void blk_abort_request(struct request *req) { if (blk_mark_rq_complete(req)) return; blk_delete_timer(req); if (req->q->mq_ops) blk_mq_rq_timed_out(req, false); else blk_rq_timed_out(req); }
static void blk_rq_check_expired(struct request *rq, unsigned long *next_timeout, unsigned int *next_set) { if (time_after_eq(jiffies, rq->deadline)) { list_del_init(&rq->timeout_list); /* * Check if we raced with end io completion */ if (!blk_mark_rq_complete(rq)) blk_rq_timed_out(rq); } else if (!*next_set || time_after(*next_timeout, rq->deadline)) { *next_timeout = rq->deadline; *next_set = 1; } }