]> git.ipfire.org Git - thirdparty/linux.git/commit
blk-throttle: support prioritized processing of metadata
authorYu Kuai <yukuai3@huawei.com>
Tue, 3 Sep 2024 13:51:49 +0000 (21:51 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Sep 2024 22:31:41 +0000 (16:31 -0600)
commit29390bb5661d49d10424ad8e915230de1f7074c9
tree3b96ae1c52e1bd9b2730f08af00f6255d0e8b7e3
parent3bf73e6283ef0bae4e27dad62309e50e3bf7ee88
blk-throttle: support prioritized processing of metadata

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: Yu Kuai <yukuai3@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20240903135149.271857-3-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-throttle.c