[PATCH V2 3/3] block: set ioprio for discard, write-zeroes etc

From: Chaitanya Kulkarni
Date: Wed Aug 21 2019 - 02:12:24 EST


Set the current process's iopriority for discard.

Reviewed-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx>
---
block/blk-lib.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 5f2c429d4378..500a857e5d9f 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -64,6 +64,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, bdev);
bio_set_op_attrs(bio, op, 0);
+ bio_set_prio(bio, get_current_ioprio());

bio->bi_iter.bi_size = req_sects << 9;
sector += req_sects;
@@ -162,6 +163,7 @@ static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
bio->bi_io_vec->bv_offset = 0;
bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev);
bio_set_op_attrs(bio, REQ_OP_WRITE_SAME, 0);
+ bio_set_prio(bio, get_current_ioprio());

if (nr_sects > max_write_same_sectors) {
bio->bi_iter.bi_size = max_write_same_sectors << 9;
@@ -234,6 +236,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, bdev);
bio->bi_opf = REQ_OP_WRITE_ZEROES;
+ bio_set_prio(bio, get_current_ioprio());
if (flags & BLKDEV_ZERO_NOUNMAP)
bio->bi_opf |= REQ_NOUNMAP;

@@ -286,6 +289,7 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, bdev);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
+ bio_set_prio(bio, get_current_ioprio());

while (nr_sects != 0) {
sz = min((sector_t) PAGE_SIZE, nr_sects << 9);
--
2.17.0