block: Fix where bio IO priority gets set
[ Upstream commit f3c89983cb4fc00be64eb0d5cbcfcdf2cacb965e ] Commit82b74cac28
("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:a78418e6a0
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
532ba43dce
commit
c20e89c96f
|
@ -49,6 +49,7 @@
|
||||||
#include "blk-pm.h"
|
#include "blk-pm.h"
|
||||||
#include "blk-cgroup.h"
|
#include "blk-cgroup.h"
|
||||||
#include "blk-throttle.h"
|
#include "blk-throttle.h"
|
||||||
|
#include "blk-ioprio.h"
|
||||||
|
|
||||||
struct dentry *blk_debugfs_root;
|
struct dentry *blk_debugfs_root;
|
||||||
|
|
||||||
|
@ -819,6 +820,14 @@ end_io:
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(submit_bio_noacct);
|
EXPORT_SYMBOL(submit_bio_noacct);
|
||||||
|
|
||||||
|
static void bio_set_ioprio(struct bio *bio)
|
||||||
|
{
|
||||||
|
/* Nobody set ioprio so far? Initialize it based on task's nice value */
|
||||||
|
if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE)
|
||||||
|
bio->bi_ioprio = get_current_ioprio();
|
||||||
|
blkcg_set_ioprio(bio);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* submit_bio - submit a bio to the block device layer for I/O
|
* submit_bio - submit a bio to the block device layer for I/O
|
||||||
* @bio: The &struct bio which describes the I/O
|
* @bio: The &struct bio which describes the I/O
|
||||||
|
@ -841,6 +850,7 @@ void submit_bio(struct bio *bio)
|
||||||
count_vm_events(PGPGOUT, bio_sectors(bio));
|
count_vm_events(PGPGOUT, bio_sectors(bio));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bio_set_ioprio(bio);
|
||||||
submit_bio_noacct(bio);
|
submit_bio_noacct(bio);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(submit_bio);
|
EXPORT_SYMBOL(submit_bio);
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "blk-stat.h"
|
#include "blk-stat.h"
|
||||||
#include "blk-mq-sched.h"
|
#include "blk-mq-sched.h"
|
||||||
#include "blk-rq-qos.h"
|
#include "blk-rq-qos.h"
|
||||||
#include "blk-ioprio.h"
|
|
||||||
|
|
||||||
static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
|
static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
|
||||||
static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd);
|
static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd);
|
||||||
|
@ -2956,14 +2955,6 @@ static bool blk_mq_can_use_cached_rq(struct request *rq, struct blk_plug *plug,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bio_set_ioprio(struct bio *bio)
|
|
||||||
{
|
|
||||||
/* Nobody set ioprio so far? Initialize it based on task's nice value */
|
|
||||||
if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE)
|
|
||||||
bio->bi_ioprio = get_current_ioprio();
|
|
||||||
blkcg_set_ioprio(bio);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blk_mq_submit_bio - Create and send a request to block device.
|
* blk_mq_submit_bio - Create and send a request to block device.
|
||||||
* @bio: Bio pointer.
|
* @bio: Bio pointer.
|
||||||
|
@ -2988,7 +2979,6 @@ void blk_mq_submit_bio(struct bio *bio)
|
||||||
blk_status_t ret;
|
blk_status_t ret;
|
||||||
|
|
||||||
bio = blk_queue_bounce(bio, q);
|
bio = blk_queue_bounce(bio, q);
|
||||||
bio_set_ioprio(bio);
|
|
||||||
|
|
||||||
if (plug) {
|
if (plug) {
|
||||||
rq = rq_list_peek(&plug->cached_rq);
|
rq = rq_list_peek(&plug->cached_rq);
|
||||||
|
|
Loading…
Reference in New Issue