提交 8ae060d3 编写于 作者: D Damien Le Moal 提交者: Cheng Jian

block: prevent merging of requests with different priorities

mainline inclusion
from mainline-5.0-rc1
commit 668ffc03
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27
CVE: NA
---------------------------

Growing in size a high priority request by merging it with a lower
priority BIO or request will increase the request execution time. This
is the opposite result of the desired effect of high I/O priorities,
namely getting low I/O latencies. Prevent merging of requests and BIOs
that have different I/O priorities to fix this.
Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>

Conflicts:
	block/blk-merge.c
	[ Patch 9cf2bab6("block: kill request ->cpu member") is not
	  applied. ]
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 13d6bc56
...@@ -1814,7 +1814,6 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req, ...@@ -1814,7 +1814,6 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
req->biotail->bi_next = bio; req->biotail->bi_next = bio;
req->biotail = bio; req->biotail = bio;
req->__data_len += bio->bi_iter.bi_size; req->__data_len += bio->bi_iter.bi_size;
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
blk_account_io_start(req, false); blk_account_io_start(req, false);
return true; return true;
...@@ -1838,7 +1837,6 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, ...@@ -1838,7 +1837,6 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
req->__sector = bio->bi_iter.bi_sector; req->__sector = bio->bi_iter.bi_sector;
req->__data_len += bio->bi_iter.bi_size; req->__data_len += bio->bi_iter.bi_size;
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
blk_account_io_start(req, false); blk_account_io_start(req, false);
return true; return true;
...@@ -1858,7 +1856,6 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, ...@@ -1858,7 +1856,6 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req,
req->biotail->bi_next = bio; req->biotail->bi_next = bio;
req->biotail = bio; req->biotail = bio;
req->__data_len += bio->bi_iter.bi_size; req->__data_len += bio->bi_iter.bi_size;
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
req->nr_phys_segments = segments + 1; req->nr_phys_segments = segments + 1;
blk_account_io_start(req, false); blk_account_io_start(req, false);
......
...@@ -727,6 +727,9 @@ static struct request *attempt_merge(struct request_queue *q, ...@@ -727,6 +727,9 @@ static struct request *attempt_merge(struct request_queue *q,
if (req->write_hint != next->write_hint) if (req->write_hint != next->write_hint)
return NULL; return NULL;
if (req->ioprio != next->ioprio)
return NULL;
/* /*
* If we are allowed to merge, then append bio list * If we are allowed to merge, then append bio list
* from next to rq and release next. merge_requests_fn * from next to rq and release next. merge_requests_fn
...@@ -782,7 +785,6 @@ static struct request *attempt_merge(struct request_queue *q, ...@@ -782,7 +785,6 @@ static struct request *attempt_merge(struct request_queue *q,
*/ */
blk_account_io_merge(next); blk_account_io_merge(next);
req->ioprio = ioprio_best(req->ioprio, next->ioprio);
if (blk_rq_cpu_valid(next)) if (blk_rq_cpu_valid(next))
req->cpu = next->cpu; req->cpu = next->cpu;
...@@ -865,6 +867,9 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) ...@@ -865,6 +867,9 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
if (rq->write_hint != bio->bi_write_hint) if (rq->write_hint != bio->bi_write_hint)
return false; return false;
if (rq->ioprio != bio_prio(bio))
return false;
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册