函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:block\blk-throttle.c Create Date:2022-07-27 19:17:27
首页 Copyright©Brick

295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
static uint64_t tg_bps_limit(struct throtl_grp *tg, int rw)
{
    struct blkcg_gq *blkg = tg_to_blkg(tg);
    struct throtl_data *td;
    uint64_t ret;
 
    if (cgroup_subsys_on_dfl(io_cgrp_subsys) && !blkg->parent)
        return U64_MAX;
 
    td = tg->td;
    ret = tg->bps[rw][td->limit_index];
    if (ret == 0 && td->limit_index == LIMIT_LOW) {
        /* intermediate node or iops isn't 0 */
        if (!list_empty(&blkg->blkcg->css.children) ||
            tg->iops[rw][td->limit_index])
            return U64_MAX;
        else
            return MIN_THROTL_BPS;
    }
 
    if (td->limit_index == LIMIT_MAX && tg->bps[rw][LIMIT_LOW] &&
        tg->bps[rw][LIMIT_LOW] != tg->bps[rw][LIMIT_MAX]) {
        uint64_t adjusted;
 
        adjusted = throtl_adjusted_limit(tg->bps[rw][LIMIT_LOW], td);
        ret = min(tg->bps[rw][LIMIT_MAX], adjusted);
    }
    return ret;
}