Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: Fix where bio IO priority gets set

Commit 82b74cac2849 ("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: a78418e6a04c ("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>

authored by

Hongyu Jin and committed by
Jens Axboe
f3c89983 37358164

+10 -10
+10
block/blk-core.c
··· 49 49 #include "blk-pm.h" 50 50 #include "blk-cgroup.h" 51 51 #include "blk-throttle.h" 52 + #include "blk-ioprio.h" 52 53 53 54 struct dentry *blk_debugfs_root; 54 55 ··· 834 833 } 835 834 EXPORT_SYMBOL(submit_bio_noacct); 836 835 836 + static void bio_set_ioprio(struct bio *bio) 837 + { 838 + /* Nobody set ioprio so far? Initialize it based on task's nice value */ 839 + if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) 840 + bio->bi_ioprio = get_current_ioprio(); 841 + blkcg_set_ioprio(bio); 842 + } 843 + 837 844 /** 838 845 * submit_bio - submit a bio to the block device layer for I/O 839 846 * @bio: The &struct bio which describes the I/O ··· 864 855 count_vm_events(PGPGOUT, bio_sectors(bio)); 865 856 } 866 857 858 + bio_set_ioprio(bio); 867 859 submit_bio_noacct(bio); 868 860 } 869 861 EXPORT_SYMBOL(submit_bio);
-10
block/blk-mq.c
··· 40 40 #include "blk-stat.h" 41 41 #include "blk-mq-sched.h" 42 42 #include "blk-rq-qos.h" 43 - #include "blk-ioprio.h" 44 43 45 44 static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); 46 45 static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd); ··· 2943 2944 return true; 2944 2945 } 2945 2946 2946 - static void bio_set_ioprio(struct bio *bio) 2947 - { 2948 - /* Nobody set ioprio so far? Initialize it based on task's nice value */ 2949 - if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) 2950 - bio->bi_ioprio = get_current_ioprio(); 2951 - blkcg_set_ioprio(bio); 2952 - } 2953 - 2954 2947 /** 2955 2948 * blk_mq_submit_bio - Create and send a request to block device. 2956 2949 * @bio: Bio pointer. ··· 2967 2976 blk_status_t ret; 2968 2977 2969 2978 bio = blk_queue_bounce(bio, q); 2970 - bio_set_ioprio(bio); 2971 2979 2972 2980 if (plug) { 2973 2981 rq = rq_list_peek(&plug->cached_rq);