aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorWanlong Gao <gaowanlong@cn.fujitsu.com>2011-09-21 04:22:10 -0400
committerJens Axboe <axboe@kernel.dk>2011-09-21 04:22:10 -0400
commitd11bb4462c4cc6ddd45c6927c617ad79fa6fb8fc (patch)
tree248949fdd3c8894db0e161e9338a3a984c1ce0f7 /block
parent8ad6a56f5679a987bfeacad1bd818a2a381aa98e (diff)
blk-cgroup: be able to remove the record of unplugged device
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. Thanks for the comments of Paul, Zefan, and Vivek. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Paul Menage <paul@paulmenage.org> Acked-by: Vivek Goyal <vgoyal@redhat.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-cgroup.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index bcaf16ee6ad1..b596e54ddd71 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -785,10 +785,10 @@ static int blkio_policy_parse_and_set(char *buf,
785{ 785{
786 char *s[4], *p, *major_s = NULL, *minor_s = NULL; 786 char *s[4], *p, *major_s = NULL, *minor_s = NULL;
787 int ret; 787 int ret;
788 unsigned long major, minor, temp; 788 unsigned long major, minor;
789 int i = 0; 789 int i = 0;
790 dev_t dev; 790 dev_t dev;
791 u64 bps, iops; 791 u64 temp;
792 792
793 memset(s, 0, sizeof(s)); 793 memset(s, 0, sizeof(s));
794 794
@@ -826,20 +826,23 @@ static int blkio_policy_parse_and_set(char *buf,
826 826
827 dev = MKDEV(major, minor); 827 dev = MKDEV(major, minor);
828 828
829 ret = blkio_check_dev_num(dev); 829 ret = strict_strtoull(s[1], 10, &temp);
830 if (ret) 830 if (ret)
831 return ret; 831 return -EINVAL;
832 832
833 newpn->dev = dev; 833 /* For rule removal, do not check for device presence. */
834 if (temp) {
835 ret = blkio_check_dev_num(dev);
836 if (ret)
837 return ret;
838 }
834 839
835 if (s[1] == NULL) 840 newpn->dev = dev;
836 return -EINVAL;
837 841
838 switch (plid) { 842 switch (plid) {
839 case BLKIO_POLICY_PROP: 843 case BLKIO_POLICY_PROP:
840 ret = strict_strtoul(s[1], 10, &temp); 844 if ((temp < BLKIO_WEIGHT_MIN && temp > 0) ||
841 if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) || 845 temp > BLKIO_WEIGHT_MAX)
842 temp > BLKIO_WEIGHT_MAX)
843 return -EINVAL; 846 return -EINVAL;
844 847
845 newpn->plid = plid; 848 newpn->plid = plid;
@@ -850,26 +853,18 @@ static int blkio_policy_parse_and_set(char *buf,
850 switch(fileid) { 853 switch(fileid) {
851 case BLKIO_THROTL_read_bps_device: 854 case BLKIO_THROTL_read_bps_device:
852 case BLKIO_THROTL_write_bps_device: 855 case BLKIO_THROTL_write_bps_device:
853 ret = strict_strtoull(s[1], 10, &bps);
854 if (ret)
855 return -EINVAL;
856
857 newpn->plid = plid; 856 newpn->plid = plid;
858 newpn->fileid = fileid; 857 newpn->fileid = fileid;
859 newpn->val.bps = bps; 858 newpn->val.bps = temp;
860 break; 859 break;
861 case BLKIO_THROTL_read_iops_device: 860 case BLKIO_THROTL_read_iops_device:
862 case BLKIO_THROTL_write_iops_device: 861 case BLKIO_THROTL_write_iops_device:
863 ret = strict_strtoull(s[1], 10, &iops); 862 if (temp > THROTL_IOPS_MAX)
864 if (ret)
865 return -EINVAL;
866
867 if (iops > THROTL_IOPS_MAX)
868 return -EINVAL; 863 return -EINVAL;
869 864
870 newpn->plid = plid; 865 newpn->plid = plid;
871 newpn->fileid = fileid; 866 newpn->fileid = fileid;
872 newpn->val.iops = (unsigned int)iops; 867 newpn->val.iops = (unsigned int)temp;
873 break; 868 break;
874 } 869 }
875 break; 870 break;