我是靠谱客的博主 执着月饼,最近开发中收集的这篇文章主要介绍blk_peek_request,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1. blk_fetch_request

/**
 * blk_peek_request - peek at the top of a request queue
 * @q: request queue to peek at
 *
 * Description:
 *     Return the request at the top of @q.  The returned request
 *     should be started using blk_start_request() before LLD starts
 *     processing it.
 *
 * Return:
 *     Pointer to the request at the top of @q if available.  Null
 *     otherwise.
 *
 * Context:
 *     queue_lock must be held.
 */
struct request *blk_peek_request(struct request_queue *q)
{
	struct request *rq;
	int ret;
	while ((rq = __elv_next_request(q)) != NULL) {
		rq = blk_pm_peek_request(q, rq);

if (!rq)

break;

if (!(rq->cmd_flags & REQ_STARTED)) {

/*

 * This is the first time the device driver

 * sees this request (possibly after

 * requeueing).  Notify IO scheduler.

 */

if (rq->cmd_flags & REQ_SORTED)

elv_activate_rq(q, rq);

/*

 * just mark as started even if we don't start

 * it, a request that has been delayed should

 * not be passed by new incoming requests

 */

rq->cmd_flags |= REQ_STARTED;

trace_block_rq_issue(q, rq);

}

if (!q->boundary_rq || q->boundary_rq == rq) {

q->end_sector = rq_end_sector(rq);

q->boundary_rq = NULL;

}

if (rq->cmd_flags & REQ_DONTPREP)

break;

if (q->dma_drain_size && blk_rq_bytes(rq)) {

/*

 * make sure space for the drain appears we

 * know we can do this because max_hw_segments

 * has been adjusted to be one fewer than the

 * device can handle

 */

rq->nr_phys_segments++;

}

if (!q->prep_rq_fn)

break;

ret = q->prep_rq_fn(q, rq);

if (ret == BLKPREP_OK) {

break;

} else if (ret == BLKPREP_DEFER) {

/*

 * the request may have been (partially) prepped.

 * we need to keep this request in the front to

 * avoid resource deadlock.  REQ_STARTED will

 * prevent other fs requests from passing this one.

 */

if (q->dma_drain_size && blk_rq_bytes(rq) &&

    !(rq->cmd_flags & REQ_DONTPREP)) {

/*

 * remove the space for the drain we added

 * so that we don't add it again

 */

--rq->nr_phys_segments;

}

rq = NULL;

break;

} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {

int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;

rq->cmd_flags |= REQ_QUIET;

/*

 * Mark this request as started so we don't trigger

 * any debug logic in the end I/O path.

 */

blk_start_request(rq);

__blk_end_request_all(rq, err);

} else {

printk(KERN_ERR "%s: bad return=%dn", __func__, ret);

break;

}
	}
	return rq;
}

最后

以上就是执着月饼为你收集整理的blk_peek_request的全部内容,希望文章能够帮你解决blk_peek_request所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部