提交 dd783bde 编写于 作者: D Damien Le Moal 提交者: Caspar Zhang

block: Introduce get_current_ioprio()

commit 64845a1ddd655574886eb48e9a5eaeeb9b05bf0d upstream.

Define get_current_ioprio() as an inline helper to obtain the caller
I/O priority from its task I/O context. Use this helper in
blk_init_request_from_bio() to set a request ioprio.
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 35118adb
......@@ -1981,18 +1981,14 @@ unsigned int blk_plug_queued_count(struct request_queue *q)
void blk_init_request_from_bio(struct request *req, struct bio *bio)
{
struct io_context *ioc = rq_ioc(bio);
if (bio->bi_opf & REQ_RAHEAD)
req->cmd_flags |= REQ_FAILFAST_MASK;
req->__sector = bio->bi_iter.bi_sector;
if (ioprio_valid(bio_prio(bio)))
req->ioprio = bio_prio(bio);
else if (ioc)
req->ioprio = ioc->ioprio;
else
req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
req->ioprio = get_current_ioprio();
req->write_hint = bio->bi_write_hint;
blk_rq_bio_prep(req->q, req, bio);
}
......
......@@ -70,6 +70,19 @@ static inline int task_nice_ioclass(struct task_struct *task)
return IOPRIO_CLASS_BE;
}
/*
* If the calling process has set an I/O priority, use that. Otherwise, return
* the default I/O priority.
*/
static inline int get_current_ioprio(void)
{
struct io_context *ioc = current->io_context;
if (ioc)
return ioc->ioprio;
return IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
}
/*
* For inheritance, return the highest of the two given priorities
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册