bfq: Extract bfq_group_set_weight from bfq_io_set_weight_legacy
This function will be useful when we update weight from the soon-coming per-device interface. Signed-off-by: Fam Zheng <zhengfeiran@bytedance.com> Reviewed-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e9d3c866bf
commit
5ff047e328
@ -919,34 +919,16 @@ static int bfq_io_show_weight(struct seq_file *sf, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css,
|
static void bfq_group_set_weight(struct bfq_group *bfqg, u64 weight)
|
||||||
struct cftype *cftype,
|
|
||||||
u64 val)
|
|
||||||
{
|
{
|
||||||
struct blkcg *blkcg = css_to_blkcg(css);
|
|
||||||
struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg);
|
|
||||||
struct blkcg_gq *blkg;
|
|
||||||
int ret = -ERANGE;
|
|
||||||
|
|
||||||
if (val < BFQ_MIN_WEIGHT || val > BFQ_MAX_WEIGHT)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
spin_lock_irq(&blkcg->lock);
|
|
||||||
bfqgd->weight = (unsigned short)val;
|
|
||||||
hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
|
|
||||||
struct bfq_group *bfqg = blkg_to_bfqg(blkg);
|
|
||||||
|
|
||||||
if (!bfqg)
|
|
||||||
continue;
|
|
||||||
/*
|
/*
|
||||||
* Setting the prio_changed flag of the entity
|
* Setting the prio_changed flag of the entity
|
||||||
* to 1 with new_weight == weight would re-set
|
* to 1 with new_weight == weight would re-set
|
||||||
* the value of the weight to its ioprio mapping.
|
* the value of the weight to its ioprio mapping.
|
||||||
* Set the flag only if necessary.
|
* Set the flag only if necessary.
|
||||||
*/
|
*/
|
||||||
if ((unsigned short)val != bfqg->entity.new_weight) {
|
if ((unsigned short)weight != bfqg->entity.new_weight) {
|
||||||
bfqg->entity.new_weight = (unsigned short)val;
|
bfqg->entity.new_weight = (unsigned short)weight;
|
||||||
/*
|
/*
|
||||||
* Make sure that the above new value has been
|
* Make sure that the above new value has been
|
||||||
* stored in bfqg->entity.new_weight before
|
* stored in bfqg->entity.new_weight before
|
||||||
@ -966,6 +948,28 @@ static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css,
|
|||||||
bfqg->entity.prio_changed = 1;
|
bfqg->entity.prio_changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css,
|
||||||
|
struct cftype *cftype,
|
||||||
|
u64 val)
|
||||||
|
{
|
||||||
|
struct blkcg *blkcg = css_to_blkcg(css);
|
||||||
|
struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg);
|
||||||
|
struct blkcg_gq *blkg;
|
||||||
|
int ret = -ERANGE;
|
||||||
|
|
||||||
|
if (val < BFQ_MIN_WEIGHT || val > BFQ_MAX_WEIGHT)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
spin_lock_irq(&blkcg->lock);
|
||||||
|
bfqgd->weight = (unsigned short)val;
|
||||||
|
hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
|
||||||
|
struct bfq_group *bfqg = blkg_to_bfqg(blkg);
|
||||||
|
|
||||||
|
if (bfqg)
|
||||||
|
bfq_group_set_weight(bfqg, val);
|
||||||
|
}
|
||||||
spin_unlock_irq(&blkcg->lock);
|
spin_unlock_irq(&blkcg->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user