• Yu Kuai's avatar
    blk-throttle: support prioritized processing of metadata · 29390bb5
    Yu Kuai authored
    Currently, blk-throttle handle all IO fifo, hence if data IO is
    throttled and then meta IO is dispatched, the meta IO will have to wait
    for the data IO, causing priority inversion problems.
    
    This patch support to handle metadata first and then pay debt while
    throttling data.
    
    Test script: use cgroup v1 to throttle root cgroup, then create new
    dir and file while write back is throttled
    
    test() {
      mkdir /mnt/test/xxx
      touch /mnt/test/xxx/1
      sync /mnt/test/xxx
      sync /mnt/test/xxx
    }
    
    mkfs.ext4 -F /dev/nvme0n1 -E lazy_itable_init=0,lazy_journal_init=0
    mount /dev/nvme0n1 /mnt/test
    
    echo "259:0 $((1024*1024))" > /sys/fs/cgroup/blkio/blkio.throttle.write_bps_device
    dd if=/dev/zero of=/mnt/test/foo1 bs=16M count=1 conv=fdatasync status=none &
    sleep 4
    
    time test
    echo "259:0 0" > /sys/fs/cgroup/blkio/blkio.throttle.write_bps_device
    
    sleep 1
    umount /dev/nvme0n1
    
    Test result: time cost for creating new dir and file
    before this patch:  14s
    after this patch:   0.1s
    Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
    Acked-by: default avatarTejun Heo <tj@kernel.org>
    Link: https://lore.kernel.org/r/20240903135149.271857-3-yukuai1@huaweicloud.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    29390bb5
blk-throttle.c 45.6 KB