hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID0C1D -------------------------------- The legacy blkio cgroup treats both `/sys/fs/cgroup/blkio` (the true root) and `/sys/fs/cgroup/blkio/1` (often the first user-created cgroup) as root when initializing the per-device (pd) structure. Consequently, if a default weight is set for the non-root cgroup (`/sys/fs/cgroup/blkio/1`), it is incorrectly overwritten and reset to 0 inside `ioinf_pd_init()`. This patch resolves the issue by increasing the priority of the `IOINFG_WEIGHT_UNINIT` check, ensuring that an explicitly set default weight is honored and is not reset when the `pd` is initialized. Fixes: a63e78514d11 ("blk-ioinf: introduce inflight-based IO QoS controller") Signed-off-by: Baokun Li <libaokun1@huawei.com> --- block/blk-ioinf.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/block/blk-ioinf.c b/block/blk-ioinf.c index 7432d88bf1f0..623c2715802b 100644 --- a/block/blk-ioinf.c +++ b/block/blk-ioinf.c @@ -1289,18 +1289,16 @@ static void ioinf_pd_init(struct blkg_policy_data *pd) struct blkcg_gq *parent = blkg->parent; infg->inf = q_to_inf(blkg->q); - if (!parent || parent->blkcg->css.cgroup->level == 0) { - infcg->dfl_user_weight = 0; - return; - } - - infg->user_weight = blkg_to_infg(parent)->user_weight; + if (parent) + infg->user_weight = blkg_to_infg(parent)->user_weight; /* Inherit the parent cgroup's dfl_user_weight if it was not set. */ if (infcg->dfl_user_weight == IOINFG_WEIGHT_UNINIT) { - struct ioinf_cgrp *parent_cgrp = blkcg_to_infcg(parent->blkcg); - - infcg->dfl_user_weight = parent_cgrp->dfl_user_weight; + if (!parent || parent->blkcg->css.cgroup->level == 0) + infcg->dfl_user_weight = 0; + else + infcg->dfl_user_weight = + blkcg_to_infcg(parent->blkcg)->dfl_user_weight; } infg->dfl_user_weight = infcg->dfl_user_weight; -- 2.46.1