Skip to content

Commit

Permalink
throttle: refuse iops-size without iops-total/read/write
Browse files Browse the repository at this point in the history
In a similar vein to commit ee2bdc3
("throttle: refuse bps_max/iops_max without bps/iops") it is likely that
the user made a configuration error if iops-size has been set but no
iops limit has been set.

Print an error message so the user can check their throttling
configuration.  They should either remove iops-size if they don't want
any throttling or specify one of iops-total, iops-read, or iops-write.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 1464828031-25601-1-git-send-email-stefanha@redhat.com
  • Loading branch information
stefanhaRH committed Jun 7, 2016
1 parent c8a9fd8 commit 8860eab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test-throttle.c
Expand Up @@ -398,6 +398,14 @@ static void test_max_is_missing_limit(void)
}
}

static void test_iops_size_is_missing_limit(void)
{
/* A total/read/write iops limit is required */
throttle_config_init(&cfg);
cfg.op_size = 4096;
g_assert(!throttle_is_valid(&cfg, NULL));
}

static void test_have_timer(void)
{
/* zero structures */
Expand Down Expand Up @@ -653,6 +661,8 @@ int main(int argc, char **argv)
g_test_add_func("/throttle/config/conflicting", test_conflicting_config);
g_test_add_func("/throttle/config/is_valid", test_is_valid);
g_test_add_func("/throttle/config/max", test_max_is_missing_limit);
g_test_add_func("/throttle/config/iops_size",
test_iops_size_is_missing_limit);
g_test_add_func("/throttle/config_functions", test_config_functions);
g_test_add_func("/throttle/accounting", test_accounting);
g_test_add_func("/throttle/groups", test_groups);
Expand Down
8 changes: 8 additions & 0 deletions util/throttle.c
Expand Up @@ -315,6 +315,14 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
return false;
}

if (cfg->op_size &&
!cfg->buckets[THROTTLE_OPS_TOTAL].avg &&
!cfg->buckets[THROTTLE_OPS_READ].avg &&
!cfg->buckets[THROTTLE_OPS_WRITE].avg) {
error_setg(errp, "iops size requires an iops value to be set");
return false;
}

for (i = 0; i < BUCKETS_COUNT; i++) {
if (cfg->buckets[i].avg < 0 ||
cfg->buckets[i].max < 0 ||
Expand Down

0 comments on commit 8860eab

Please sign in to comment.