All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: menage@google.com, Vivek Goyal <vgoyal@redhat.com>,
	axboe@kernel.dk, linux-kernel@vger.kernel.org,
	wanlong.gao@gmail.com
Subject: Re: [PATCH v3] blk-cgroup:be able to remove the record of unplugged device
Date: Tue, 26 Jul 2011 10:23:25 +0800	[thread overview]
Message-ID: <4E2E251D.6040108@cn.fujitsu.com> (raw)
In-Reply-To: <1311645400-19434-1-git-send-email-gaowanlong@cn.fujitsu.com>

patch looks good to me, just some minor nits below..

09:56, Wanlong Gao wrote:
> 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.
> 
> 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]#
> 

The changelog is too verbose. How about:

The bug is we're not able to remove the device from blkio cgroup's
per-device control files if it gets unplugged.

To reproduce the bug:

  # mount -t cgroup -o blkio xxx /cgroup
  # cd /cgroup
  # echo "8:0 1000" > blkio.throttle.read_bps_device
  # unplug the device
  # cat blkio.throttle.read_bps_device
  8:0	1000
  # echo "8:0 0" > blkio.throttle.read_bps_device
  -bash: echo: write error: No such device

After patching, the device removal will succeed.

> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  block/blk-cgroup.c |   18 +++++++++---------
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index bcaf16e..246645c 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -785,7 +785,7 @@ static int blkio_policy_parse_and_set(char *buf,
>  {
>  	char *s[4], *p, *major_s = NULL, *minor_s = NULL;
>  	int ret;
> -	unsigned long major, minor, temp;
> +	unsigned long major, minor, weight;
>  	int i = 0;
>  	dev_t dev;
>  	u64 bps, iops;
> @@ -826,25 +826,25 @@ static int blkio_policy_parse_and_set(char *buf,
>  
>  	dev = MKDEV(major, minor);
>  
> -	ret = blkio_check_dev_num(dev);
> +	ret = strict_strtoul(s[1], 10, &weight);
>  	if (ret)
> +		return -EINVAL;
> +
> +	ret = blkio_check_dev_num(dev);
> +	if (ret && (weight != 0))

unnecessary parentheses.

if (ret && weight != 0)

or

if (ret && !weight)

>  		return ret;
>  
>  	newpn->dev = dev;
>  
> -	if (s[1] == NULL)
> -		return -EINVAL;
> -
>  	switch (plid) {
>  	case BLKIO_POLICY_PROP:
> -		ret = strict_strtoul(s[1], 10, &temp);
> -		if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
> -			temp > BLKIO_WEIGHT_MAX)
> +		if ((weight < BLKIO_WEIGHT_MIN && weight > 0) ||
> +			weight > BLKIO_WEIGHT_MAX)
>  			return -EINVAL;

Normally we align the above lines this way:

if ((weight < BLKIO_WEIGHT_MIN && weight > 0) ||
    weight > BLKIO_WEIGHT_MAX)
	return -EINVAL;

>  
>  		newpn->plid = plid;
>  		newpn->fileid = fileid;
> -		newpn->val.weight = temp;
> +		newpn->val.weight = weight;
>  		break;
>  	case BLKIO_POLICY_THROTL:
>  		switch(fileid) {

  reply	other threads:[~2011-07-26  2:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2E251D.6040108@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=axboe@kernel.dk \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    --cc=vgoyal@redhat.com \
    --cc=wanlong.gao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.