Skip to content

Commit f3c8998

Browse files
Hongyu Jinaxboe
authored andcommitted
block: Fix where bio IO priority gets set
Commit 82b74ca ("blk-ioprio: Convert from rqos policy to direct call") pushed setting bio I/O priority down into blk_mq_submit_bio() -- which is too low within block core's submit_bio() because it skips setting I/O priority for block drivers that implement fops->submit_bio() (e.g. DM, MD, etc). Fix this by moving bio_set_ioprio() up from blk-mq.c to blk-core.c and call it from submit_bio(). This ensures all block drivers call bio_set_ioprio() during initial bio submission. Fixes: a78418e ("block: Always initialize bio IO priority on submit") Co-developed-by: Yibin Ding <yibin.ding@unisoc.com> Signed-off-by: Yibin Ding <yibin.ding@unisoc.com> Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com> Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com> [snitzer: revised commit header] Signed-off-by: Mike Snitzer <snitzer@kernel.org> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20240130202638.62600-2-snitzer@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3735816 commit f3c8998

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

block/blk-core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "blk-pm.h"
5050
#include "blk-cgroup.h"
5151
#include "blk-throttle.h"
52+
#include "blk-ioprio.h"
5253

5354
struct dentry *blk_debugfs_root;
5455

@@ -833,6 +834,14 @@ void submit_bio_noacct(struct bio *bio)
833834
}
834835
EXPORT_SYMBOL(submit_bio_noacct);
835836

837+
static void bio_set_ioprio(struct bio *bio)
838+
{
839+
/* Nobody set ioprio so far? Initialize it based on task's nice value */
840+
if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE)
841+
bio->bi_ioprio = get_current_ioprio();
842+
blkcg_set_ioprio(bio);
843+
}
844+
836845
/**
837846
* submit_bio - submit a bio to the block device layer for I/O
838847
* @bio: The &struct bio which describes the I/O
@@ -855,6 +864,7 @@ void submit_bio(struct bio *bio)
855864
count_vm_events(PGPGOUT, bio_sectors(bio));
856865
}
857866

867+
bio_set_ioprio(bio);
858868
submit_bio_noacct(bio);
859869
}
860870
EXPORT_SYMBOL(submit_bio);

block/blk-mq.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "blk-stat.h"
4141
#include "blk-mq-sched.h"
4242
#include "blk-rq-qos.h"
43-
#include "blk-ioprio.h"
4443

4544
static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
4645
static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd);
@@ -2944,14 +2943,6 @@ static bool blk_mq_use_cached_rq(struct request *rq, struct blk_plug *plug,
29442943
return true;
29452944
}
29462945

2947-
static void bio_set_ioprio(struct bio *bio)
2948-
{
2949-
/* Nobody set ioprio so far? Initialize it based on task's nice value */
2950-
if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE)
2951-
bio->bi_ioprio = get_current_ioprio();
2952-
blkcg_set_ioprio(bio);
2953-
}
2954-
29552946
/**
29562947
* blk_mq_submit_bio - Create and send a request to block device.
29572948
* @bio: Bio pointer.
@@ -2976,7 +2967,6 @@ void blk_mq_submit_bio(struct bio *bio)
29762967
blk_status_t ret;
29772968

29782969
bio = blk_queue_bounce(bio, q);
2979-
bio_set_ioprio(bio);
29802970

29812971
if (plug) {
29822972
rq = rq_list_peek(&plug->cached_rq);

0 commit comments

Comments
 (0)