block: Introduce get_current_ioprio()
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Родитель
e2b3fa5af7
Коммит
64845a1ddd
|
@ -813,18 +813,14 @@ out:
|
||||||
|
|
||||||
void blk_init_request_from_bio(struct request *req, struct bio *bio)
|
void blk_init_request_from_bio(struct request *req, struct bio *bio)
|
||||||
{
|
{
|
||||||
struct io_context *ioc = current->io_context;
|
|
||||||
|
|
||||||
if (bio->bi_opf & REQ_RAHEAD)
|
if (bio->bi_opf & REQ_RAHEAD)
|
||||||
req->cmd_flags |= REQ_FAILFAST_MASK;
|
req->cmd_flags |= REQ_FAILFAST_MASK;
|
||||||
|
|
||||||
req->__sector = bio->bi_iter.bi_sector;
|
req->__sector = bio->bi_iter.bi_sector;
|
||||||
if (ioprio_valid(bio_prio(bio)))
|
if (ioprio_valid(bio_prio(bio)))
|
||||||
req->ioprio = bio_prio(bio);
|
req->ioprio = bio_prio(bio);
|
||||||
else if (ioc)
|
|
||||||
req->ioprio = ioc->ioprio;
|
|
||||||
else
|
else
|
||||||
req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
|
req->ioprio = get_current_ioprio();
|
||||||
req->write_hint = bio->bi_write_hint;
|
req->write_hint = bio->bi_write_hint;
|
||||||
blk_rq_bio_prep(req->q, req, bio);
|
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;
|
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
|
* For inheritance, return the highest of the two given priorities
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче