From: Vivek Goyal <vgoyal@redhat.com>
To: linux-kernel@vger.kernel.org, axboe@kernel.dk
Cc: vgoyal@redhat.com
Subject: [PATCH 2/3] blkio-throttle: limit max iops value to UINT_MAX
Date: Fri, 1 Oct 2010 12:20:28 -0400 [thread overview]
Message-ID: <1285950029-30205-3-git-send-email-vgoyal@redhat.com> (raw)
In-Reply-To: <1285950029-30205-1-git-send-email-vgoyal@redhat.com>
- Limit max iops value to UINT_MAX and return error to user if value is more
than that instead of accepting bigger values and truncating implicitly.
---
block/blk-cgroup.c | 11 +++++++----
block/blk-cgroup.h | 3 +++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index e863418..b1febd0 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -656,10 +656,10 @@ 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, iops;
+ unsigned long major, minor, temp;
int i = 0;
dev_t dev;
- u64 bps;
+ u64 bps, iops;
memset(s, 0, sizeof(s));
@@ -731,13 +731,16 @@ static int blkio_policy_parse_and_set(char *buf,
break;
case BLKIO_THROTL_read_iops_device:
case BLKIO_THROTL_write_iops_device:
- ret = strict_strtoul(s[1], 10, &iops);
+ ret = strict_strtoull(s[1], 10, &iops);
if (ret)
return -EINVAL;
+ if (iops > THROTL_IOPS_MAX)
+ return -EINVAL;
+
newpn->plid = plid;
newpn->fileid = fileid;
- newpn->val.iops = iops;
+ newpn->val.iops = (unsigned int)iops;
break;
}
break;
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 034c355..ea4861b 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -20,6 +20,9 @@ enum blkio_policy_id {
BLKIO_POLICY_THROTL, /* Throttling */
};
+/* Max limits for throttle policy */
+#define THROTL_IOPS_MAX UINT_MAX
+
#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
#ifndef CONFIG_BLK_CGROUP
--
1.7.2.3
next prev parent reply other threads:[~2010-10-01 16:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-01 16:20 [PATCH 0/3] blkio-throttle: Few more cleanup and fixes Vivek Goyal
2010-10-01 16:20 ` [PATCH 1/3] blkio-throttle: There is no need to convert jiffies to milli seconds Vivek Goyal
2010-10-01 16:20 ` Vivek Goyal [this message]
2010-10-01 16:20 ` [PATCH 3/3] blkio-throttle: Fix possible multiplication overflow in iops calculations Vivek Goyal
2010-10-01 19:17 ` [PATCH 0/3] blkio-throttle: Few more cleanup and fixes Jens Axboe
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=1285950029-30205-3-git-send-email-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome