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.

blk-ioprio: remove per-disk structure

ioprio works on the blk-cgroup level, all disks in the same cgroup
are the same, and the struct ioprio_blkg doesn't have anything in it.
Hence register the policy is enough, because cpd_alloc/free_fn will
be handled for each blk-cgroup, and there is no need to activate the
policy for disk. Hence remove blk_ioprio_init/exit and
ioprio_alloc/free_pd.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240719071506.158075-4-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yu Kuai and committed by
Jens Axboe
79c6c60a d0e92795

-62
-8
block/blk-cgroup.c
··· 1458 1458 struct request_queue *q = disk->queue; 1459 1459 struct blkcg_gq *new_blkg, *blkg; 1460 1460 bool preloaded; 1461 - int ret; 1462 1461 1463 1462 new_blkg = blkg_alloc(&blkcg_root, disk, GFP_KERNEL); 1464 1463 if (!new_blkg) ··· 1477 1478 if (preloaded) 1478 1479 radix_tree_preload_end(); 1479 1480 1480 - ret = blk_ioprio_init(disk); 1481 - if (ret) 1482 - goto err_destroy_all; 1483 - 1484 1481 return 0; 1485 1482 1486 - err_destroy_all: 1487 - blkg_destroy_all(disk); 1488 - return ret; 1489 1483 err_unlock: 1490 1484 spin_unlock_irq(&q->queue_lock); 1491 1485 if (preloaded)
-45
block/blk-ioprio.c
··· 50 50 static struct blkcg_policy ioprio_policy; 51 51 52 52 /** 53 - * struct ioprio_blkg - Per (cgroup, request queue) data. 54 - * @pd: blkg_policy_data structure. 55 - */ 56 - struct ioprio_blkg { 57 - struct blkg_policy_data pd; 58 - }; 59 - 60 - /** 61 53 * struct ioprio_blkcg - Per cgroup data. 62 54 * @cpd: blkcg_policy_data structure. 63 55 * @prio_policy: One of the IOPRIO_CLASS_* values. See also <linux/ioprio.h>. ··· 58 66 struct blkcg_policy_data cpd; 59 67 enum prio_policy prio_policy; 60 68 }; 61 - 62 - static inline struct ioprio_blkg *pd_to_ioprio(struct blkg_policy_data *pd) 63 - { 64 - return pd ? container_of(pd, struct ioprio_blkg, pd) : NULL; 65 - } 66 69 67 70 static struct ioprio_blkcg *blkcg_to_ioprio_blkcg(struct blkcg *blkcg) 68 71 { ··· 93 106 return ret; 94 107 blkcg->prio_policy = ret; 95 108 return nbytes; 96 - } 97 - 98 - static struct blkg_policy_data * 99 - ioprio_alloc_pd(struct gendisk *disk, struct blkcg *blkcg, gfp_t gfp) 100 - { 101 - struct ioprio_blkg *ioprio_blkg; 102 - 103 - ioprio_blkg = kzalloc(sizeof(*ioprio_blkg), gfp); 104 - if (!ioprio_blkg) 105 - return NULL; 106 - 107 - return &ioprio_blkg->pd; 108 - } 109 - 110 - static void ioprio_free_pd(struct blkg_policy_data *pd) 111 - { 112 - struct ioprio_blkg *ioprio_blkg = pd_to_ioprio(pd); 113 - 114 - kfree(ioprio_blkg); 115 109 } 116 110 117 111 static struct blkcg_policy_data *ioprio_alloc_cpd(gfp_t gfp) ··· 137 169 138 170 .cpd_alloc_fn = ioprio_alloc_cpd, 139 171 .cpd_free_fn = ioprio_free_cpd, 140 - 141 - .pd_alloc_fn = ioprio_alloc_pd, 142 - .pd_free_fn = ioprio_free_pd, 143 172 }; 144 173 145 174 void blkcg_set_ioprio(struct bio *bio) ··· 172 207 IOPRIO_PRIO_VALUE(blkcg->prio_policy, 0)); 173 208 if (prio > bio->bi_ioprio) 174 209 bio->bi_ioprio = prio; 175 - } 176 - 177 - void blk_ioprio_exit(struct gendisk *disk) 178 - { 179 - blkcg_deactivate_policy(disk, &ioprio_policy); 180 - } 181 - 182 - int blk_ioprio_init(struct gendisk *disk) 183 - { 184 - return blkcg_activate_policy(disk, &ioprio_policy); 185 210 } 186 211 187 212 static int __init ioprio_init(void)
-9
block/blk-ioprio.h
··· 9 9 struct bio; 10 10 11 11 #ifdef CONFIG_BLK_CGROUP_IOPRIO 12 - int blk_ioprio_init(struct gendisk *disk); 13 - void blk_ioprio_exit(struct gendisk *disk); 14 12 void blkcg_set_ioprio(struct bio *bio); 15 13 #else 16 - static inline int blk_ioprio_init(struct gendisk *disk) 17 - { 18 - return 0; 19 - } 20 - static inline void blk_ioprio_exit(struct gendisk *disk) 21 - { 22 - } 23 14 static inline void blkcg_set_ioprio(struct bio *bio) 24 15 { 25 16 }