Commit Message

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
Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
drivers/target/target_core_device.c | 58 ++++++++++++++++++++++++++++++++++++
drivers/target/target_core_iblock.c | 38 +++++++++++++++++++++++
include/target/target_core_backend.h | 4 +++
include/target/target_core_base.h | 2 ++
4 files changed, 102 insertions(+)