[Devel] [PATCH 2/3] [v2] target: allow to set a blkio cgroup for a backstore

Cyrill Gorcunov gorcunov at virtuozzo.com
Wed May 9 17:27:12 MSK 2018


On Tue, May 08, 2018 at 10:06:25AM +0300, Andrei Vagin wrote:
> The Block I/O (blkio) subsystem controls and monitors access to I/O on
> block devices by tasks in cgroups. With the introduced changes, a
> backstore will be like a task in a specified group.
> 
> One of interesting feature is an ability to set limits on a number of
> I/O operations and bytes per seconds.
> 
> A new attribute is added for backstores, it is called blkio_cgroup.
> 
> If we write 1 to the attribute file, a blkio cgroup from the current
> process is attached to the backstore.
> 
> If we write 0 to the attribute file, a current group will be detached
> from the backstore.
> 
> When we know a blkio cgroup the only thing, what we need to do to make it
> work, is to set this group for bio-s.
> 
> How to use:
>  # Create a test backstore
> $ targetcli
> targetcli shell version 2.1.fb46
> Copyright 2011-2013 by Datera, Inc and others.
> /backstores/block> create dev=/dev/loop0 loop0
> Created block storage object loop0 using /dev/loop0.
> /backstores/block> cd /loopback
> /loopback> create
> Created target naa.50014056fd3f341c.
> /loopback> cd naa.50014056fd3f341c/luns
> /loopback/naa...fd3f341c/luns> create /backstores/block/loop0
> Created LUN 0.
> /loopback/naa...fd3f341c/luns> exit
> 
>  # Create a test cgroup and set it to a test backstore
> $ CG_PATH=/sys/fs/cgroup/blkio/test
> $ BS_PATH=/sys/kernel/config/target/core/iblock_0/loop0/attrib/blkio_cgroup
> $ mkdir -p $CG_PATH
> $ bash -c "echo 0 > $CG_PATH/tasks && echo 1 > $BS_PATH"
> $ cat $BS_PATH
> /test
> 
>  # Set 6 MB/sec for the backstore
> $ echo "7:0 6291456" > $CG_PATH/blkio.throttle.read_bps_device
> 
>  # Check that everything work as expected
> $ dd if=/dev/sda of=/dev/null iflag=direct bs=1M count=100
> 100+0 records in
> 100+0 records out
> 104857600 bytes (105 MB, 100 MiB) copied, 16.6958 s, 6.3 MB/s
> 
> v2: handle errors of cgroup_path()
> 
> Signed-off-by: Andrei Vagin <avagin at openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>

To cgroup part since I'm not familiar with the rest of the code


More information about the Devel mailing list