public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup:be able to remove the record of unplugged device
@ 2011-07-25  6:03 Wanlong Gao
  2011-07-25 20:45 ` Paul Menage
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Wanlong Gao @ 2011-07-25  6:03 UTC (permalink / raw)
  To: menage, lizf, axboe; +Cc: linux-kernel, Wanlong Gao

If doing like below:
Write a record like:
"echo 8:0 1000 > blkio.throttle.read_bps_device" to control the bps of the device.
And then unplug this device without doing
"8:0 0 > blkio.throttle.read_bps_device" to remove the record,
it will not be removed until reboot, because if the device is removed,
write some record will return "-ENODEV".

With this patch, when the device is removed, then if we want to remove
the record for this removed device, just write "0" then it'll not check
if it is a present device, just remove the present record.

BTW:If it can support hot-plug, will it be more better?

Thanks

Below is my test:
1. Test native:
[root@test ~]# mount -t cgroup -o blkio nodev /cgroup/
[root@test ~]# cd /cgroup/
[root@test cgroup]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 Jul 25 13:27 /dev/sda
brw-rw---- 1 root disk 8, 1 Jul 25 13:27 /dev/sda1
[root@test cgroup]# cat blkio.throttle.read_bps_device
[root@test cgroup]# echo 8:0 1000 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	1000
[root@test cgroup]# echo 8:0 0 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
[root@test cgroup]# echo 8:0 1000 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	1000
[root@test cgroup]# ll /dev/sd*
ls: cannot access /dev/sd*: No such file or directory
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	1000
[root@test cgroup]# echo 8:0 0 > blkio.throttle.read_bps_device
-bash: echo: write error: No such device
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	1000

2.Test with this patch:

[root@test ~]# mount -t cgroup -o blkio nodev /cgroup/
[root@test ~]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 Jul 25 13:11 /dev/sda
brw-rw---- 1 root disk 8, 1 Jul 25 13:11 /dev/sda1
[root@test ~]# cd /cgroup/
[root@test cgroup]# echo 8:0 1000 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	1000
[root@test cgroup]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 Jul 25 13:11 /dev/sda
brw-rw---- 1 root disk 8, 1 Jul 25 13:11 /dev/sda1
[root@test cgroup]# echo 8:0 0 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
[root@test cgroup]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 Jul 25 13:11 /dev/sda
brw-rw---- 1 root disk 8, 1 Jul 25 13:11 /dev/sda1
[root@test cgroup]# echo 8:0 2000 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	2000

[root@test cgroup]# ll /dev/sd*
ls: cannot access /dev/sd*: No such file or directory
[root@test cgroup]# cat blkio.throttle.read_bps_device
8:0	2000
[root@test cgroup]# echo 8:0 0 > blkio.throttle.read_bps_device
[root@test cgroup]# cat blkio.throttle.read_bps_device
[root@test cgroup]# echo 8:0 1000 > blkio.throttle.read_bps_device
-bash: echo: write error: No such device
[root@test cgroup]# echo 8:0 01100 > blkio.throttle.read_bps_device
-bash: echo: write error: No such device
[root@test cgroup]#

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 block/blk-cgroup.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index bcaf16e..ea32b01 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -826,15 +826,15 @@ static int blkio_policy_parse_and_set(char *buf,
 
 	dev = MKDEV(major, minor);
 
+	if (s[1] == NULL)
+		return -EINVAL;
+
 	ret = blkio_check_dev_num(dev);
-	if (ret)
+	if (ret && (strcmp(s[1], "0\0")))
 		return ret;
 
 	newpn->dev = dev;
 
-	if (s[1] == NULL)
-		return -EINVAL;
-
 	switch (plid) {
 	case BLKIO_POLICY_PROP:
 		ret = strict_strtoul(s[1], 10, &temp);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-08-17 14:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25  6:03 [PATCH] cgroup:be able to remove the record of unplugged device Wanlong Gao
2011-07-25 20:45 ` Paul Menage
2011-07-26  0:37 ` [PATCH v2] " Wanlong Gao
2011-07-26  1:29   ` Paul Menage
2011-07-26  1:56 ` [PATCH v3] blk-cgroup:be " Wanlong Gao
2011-07-26  2:23   ` Li Zefan
2011-07-26  3:00     ` [PATCH v4] " Wanlong Gao
2011-07-26 14:44   ` [PATCH v3] " Vivek Goyal
2011-07-26 14:59     ` Wanlong Gao
2011-07-26 17:17     ` Paul Menage
2011-07-26 17:41       ` Vivek Goyal
2011-07-26 18:40         ` Paul Menage
2011-07-26 19:24           ` Vivek Goyal
2011-07-27  0:11             ` [PATCH v5] " Wanlong Gao
2011-07-27 14:11               ` Vivek Goyal
2011-08-17 12:57                 ` Wanlong Gao
2011-08-17 14:18                   ` Vivek Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox