Why I met "No such device" when using cgroup v2 io.max to limit the speed of IO?

Viewed 281

I was learning Cgroup v2.

I ran these:

mkdir -p /sys/fs/cgroup/group1
echo $$ > /sys/fs/cgroup/group1/cgroup.procs
echo "8:5 wbps=2097152" > /sys/fs/cgroup/group1/io.max

But the second echo command failed with:

bash: echo: write error: No such device

But I do have the 8:5 device.

# df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             1970236        0   1970236   0% /dev
tmpfs             400072     1900    398172   1% /run
/dev/sda5       61145932 30195508  27814680  53% /
tmpfs            2000348        0   2000348   0% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
/dev/loop2         63232    63232         0 100% /snap/core20/975
/dev/loop1         56832    56832         0 100% /snap/core18/2066
/dev/loop0         56832    56832         0 100% /snap/core18/2074
/dev/loop3         63232    63232         0 100% /snap/core20/1026
/dev/loop5         66688    66688         0 100% /snap/gtk-common-themes/1515
/dev/loop4         66432    66432         0 100% /snap/gtk-common-themes/1514
/dev/loop6         33152    33152         0 100% /snap/snapd/12398
/dev/loop7         52352    52352         0 100% /snap/snap-store/518
/dev/loop8         52224    52224         0 100% /snap/snap-store/547
/dev/loop9        224256   224256         0 100% /snap/gnome-3-34-1804/72
/dev/loop10        21760    21760         0 100% /snap/bashtop/299
/dev/loop11        33152    33152         0 100% /snap/snapd/12159
/dev/loop12       224256   224256         0 100% /snap/gnome-3-34-1804/66
/dev/loop13        22528    22528         0 100% /snap/bashtop/292
/dev/sda1         523248        4    523244   1% /boot/efi
tmpfs             400068       28    400040   1% /run/user/1000
# ls -l /dev/sda5
brw-rw---- 1 root disk 8, 5 Jul 14 11:26 /dev/sda5

/dev/sda5 is the device with major 8 and minor 5.

I am using Ubuntu 20.04 on VMware workstation, it is a virtual machine.

So why I met it and how to solve it?

1 Answers

Try running cat /proc/partitions, it will give you a list of partitions:

major minor  #blocks  name

   8        0   41943040 sda
   8        1   41942016 sda1

For cgroups, it only supports to limit a physical device's IO speed, if the device is a partition, it will report error (frankly speaking, the error reported "No such device" is not accurate).

The source code is likely to be this line: https://github.com/torvalds/linux/blob/master/block/blk-cgroup.c#L600

Related