diff mbox

[for-2.7,1/2] throttle: Don't allow burst limits to be lower than the normal limits

Message ID 1e88093dfa1e7b1714a1cc94a01713dade46eed8.1469657519.git.berto@igalia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alberto Garcia July 27, 2016, 10:16 p.m. UTC
Setting FOO_max to a value that is lower than FOO does not make
sense, and it produces odd results depending on the value of
FOO_max_length. Although the user should not set that configuration
in the first place it's better to reject it explicitly.

https://bugzilla.redhat.com/show_bug.cgi?id=1355665

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Gu Nini <ngu@redhat.com>
---
 util/throttle.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Eric Blake July 27, 2016, 10:33 p.m. UTC | #1
On 07/27/2016 04:16 PM, Alberto Garcia wrote:
> Setting FOO_max to a value that is lower than FOO does not make
> sense, and it produces odd results depending on the value of
> FOO_max_length. Although the user should not set that configuration
> in the first place it's better to reject it explicitly.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1355665
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> Reported-by: Gu Nini <ngu@redhat.com>
> ---
>  util/throttle.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/util/throttle.c b/util/throttle.c
> index 654f95c..7a5c619 100644
> --- a/util/throttle.c
> +++ b/util/throttle.c
> @@ -348,6 +348,12 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
>                         " bps/iops values");
>              return false;
>          }
> +
> +        if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
> +            error_setg(errp, "if bps_max/iops_max is set it cannot be lower"
> +                       " than the bps/iops values");

Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower
than bps/iops values".  But the idea makes sense.
Alberto Garcia July 27, 2016, 10:45 p.m. UTC | #2
On Thu 28 Jul 2016 12:33:51 AM CEST, Eric Blake <eblake@redhat.com> wrote:
>> +        if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
>> +            error_setg(errp, "if bps_max/iops_max is set it cannot be lower"
>> +                       " than the bps/iops values");
>
> Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower
> than bps/iops values".  But the idea makes sense.

That's not strictly true since the default value of bps_max is 0 (unless
we forbid setting it explicitly to 0 as well).

Berto
Eric Blake July 27, 2016, 10:51 p.m. UTC | #3
On 07/27/2016 04:45 PM, Alberto Garcia wrote:
> On Thu 28 Jul 2016 12:33:51 AM CEST, Eric Blake <eblake@redhat.com> wrote:
>>> +        if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
>>> +            error_setg(errp, "if bps_max/iops_max is set it cannot be lower"
>>> +                       " than the bps/iops values");
>>
>> Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower
>> than bps/iops values".  But the idea makes sense.
> 
> That's not strictly true since the default value of bps_max is 0 (unless
> we forbid setting it explicitly to 0 as well).

The message can only be emitted if bps_max was set.  If bps_max is its
default value of 0 (or even if the user explicitly set it to zero), then
this message won't appear.  Therefore, telling the user that "if this is
set" is redundant, because the error is only issued when it IS set.
diff mbox

Patch

diff --git a/util/throttle.c b/util/throttle.c
index 654f95c..7a5c619 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -348,6 +348,12 @@  bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
                        " bps/iops values");
             return false;
         }
+
+        if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
+            error_setg(errp, "if bps_max/iops_max is set it cannot be lower"
+                       " than the bps/iops values");
+            return false;
+        }
     }
 
     return true;