|
|
21ab4e |
From e34557b686ae1c51ba90be80c7d47b14122bbd38 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Csaba Henk <chenk@redhat.com>
|
|
|
21ab4e |
Date: Tue, 9 May 2017 15:52:43 +0200
|
|
|
21ab4e |
Subject: [PATCH 425/426] libglusterfs: stop special casing "cache-size" in
|
|
|
21ab4e |
size_t validation
|
|
|
21ab4e |
|
|
|
21ab4e |
The original situation was as follows:
|
|
|
21ab4e |
|
|
|
21ab4e |
The function that validates xlator options indicating a size,
|
|
|
21ab4e |
xlator_option_validate_sizet(), handles the case when the name
|
|
|
21ab4e |
of the option is "cache-size" in a special way.
|
|
|
21ab4e |
|
|
|
21ab4e |
- Xlator options (things of type volume_option_t) has a
|
|
|
21ab4e |
min and max attribute of type double.
|
|
|
21ab4e |
- An xlator option is endowed with a gluster specific type (not
|
|
|
21ab4e |
C type). An instance of an xlator option goes through a validation
|
|
|
21ab4e |
process by a type specific validator function (which are collected
|
|
|
21ab4e |
in option.c).
|
|
|
21ab4e |
- Validators of numeric types - size being one of them - make use the
|
|
|
21ab4e |
min and max attributes to perform a range check, except in one case:
|
|
|
21ab4e |
if an option is defined with min = max = 0, then this option will be
|
|
|
21ab4e |
exempt of range checking. (Note: the volume_option_t definition
|
|
|
21ab4e |
features the following comments along the min, max fields:
|
|
|
21ab4e |
|
|
|
21ab4e |
double min; /* 0 means no range */
|
|
|
21ab4e |
double max; /* 0 means no range */
|
|
|
21ab4e |
|
|
|
21ab4e |
which is slightly misleading as it lets one to conclude that
|
|
|
21ab4e |
zeroing min or max buys exemption from low or high boundary check,
|
|
|
21ab4e |
which is not true -- only *both* being zero buys exemption.)
|
|
|
21ab4e |
- Besides this, the validator for options of size type,
|
|
|
21ab4e |
xlator_option_validate_sizet() special cases options
|
|
|
21ab4e |
named "cache-size" so that only min is enforced. (The only consequence
|
|
|
21ab4e |
of a value exceeding max is that glusterd logs a warning about it, but
|
|
|
21ab4e |
the cli user who makes such a setting gets no feedback on it.)
|
|
|
21ab4e |
- This was introduced because a hard coded limit is not useful for
|
|
|
21ab4e |
io-cache and quick-read. They rather use a runtime calculated
|
|
|
21ab4e |
upper limit. (See changes
|
|
|
21ab4e |
I7dd4d8c53051b89a293696abf1ee8dc237e39a20
|
|
|
21ab4e |
I9c744b5ace10604d5a814e6218ca0d83c796db80
|
|
|
21ab4e |
about the last two points.)
|
|
|
21ab4e |
- As an unintended consequence, the upper limit check of
|
|
|
21ab4e |
cache-size of write-behind, for which a conventional hard coded limit
|
|
|
21ab4e |
is specified, is defeated.
|
|
|
21ab4e |
|
|
|
21ab4e |
What we do about it:
|
|
|
21ab4e |
|
|
|
21ab4e |
- Remove the special casing clause for cache-size in
|
|
|
21ab4e |
xlator_option_validate_sizet. Thus the general range
|
|
|
21ab4e |
check policy (as described above) will apply to
|
|
|
21ab4e |
cache-size too.
|
|
|
21ab4e |
- To implement a lower bound only check by the validator
|
|
|
21ab4e |
for cache-size of io-cache and quick-read, change the
|
|
|
21ab4e |
max attribute of these options to INFINITY.
|
|
|
21ab4e |
|
|
|
21ab4e |
The only behavioral difference is the omission of the warnings
|
|
|
21ab4e |
about cache-size of io-cache and quick-read exceeding the former max
|
|
|
21ab4e |
values. (They were rather heuristic anyway.)
|
|
|
21ab4e |
|
|
|
21ab4e |
> BUG: 1445609
|
|
|
21ab4e |
> Change-Id: I0bd8bd391fa7d926f76e214a2178833fe4673b4a
|
|
|
21ab4e |
> Signed-off-by: Csaba Henk <csaba@redhat.com>
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/17125
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
|
|
|
21ab4e |
> Tested-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
|
|
|
21ab4e |
BUG: 1297743
|
|
|
21ab4e |
Change-Id: Idd758c3ed47f0b50706d3becce281593005841ce
|
|
|
21ab4e |
Signed-off-by: Csaba Henk <chenk@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/105675
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
libglusterfs/src/options.c | 23 +++++++----------------
|
|
|
21ab4e |
xlators/performance/io-cache/src/io-cache.c | 3 ++-
|
|
|
21ab4e |
xlators/performance/quick-read/src/quick-read.c | 3 ++-
|
|
|
21ab4e |
3 files changed, 11 insertions(+), 18 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
|
|
|
21ab4e |
index 53bd779..02928a9 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/options.c
|
|
|
21ab4e |
+++ b/libglusterfs/src/options.c
|
|
|
21ab4e |
@@ -152,22 +152,13 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
if ((size < opt->min) || (size > opt->max)) {
|
|
|
21ab4e |
- if ((strncmp (key, "cache-size", 10) == 0) &&
|
|
|
21ab4e |
- (size > opt->max)) {
|
|
|
21ab4e |
- snprintf (errstr, 256, "Cache size %" GF_PRI_SIZET " is out of "
|
|
|
21ab4e |
- "range [%.0f - %.0f]",
|
|
|
21ab4e |
- size, opt->min, opt->max);
|
|
|
21ab4e |
- gf_msg (xl->name, GF_LOG_WARNING, 0,
|
|
|
21ab4e |
- LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
21ab4e |
- } else {
|
|
|
21ab4e |
- snprintf (errstr, 256,
|
|
|
21ab4e |
- "'%" GF_PRI_SIZET "' in 'option %s %s' "
|
|
|
21ab4e |
- "is out of range [%.0f - %.0f]",
|
|
|
21ab4e |
- size, key, value, opt->min, opt->max);
|
|
|
21ab4e |
- gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
- LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
21ab4e |
- ret = -1;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
+ snprintf (errstr, 256,
|
|
|
21ab4e |
+ "'%" GF_PRI_SIZET "' in 'option %s %s' "
|
|
|
21ab4e |
+ "is out of range [%.0f - %.0f]",
|
|
|
21ab4e |
+ size, key, value, opt->min, opt->max);
|
|
|
21ab4e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
21ab4e |
+ ret = -1;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
|
|
|
21ab4e |
index 98c3774..9de6ee1 100644
|
|
|
21ab4e |
--- a/xlators/performance/io-cache/src/io-cache.c
|
|
|
21ab4e |
+++ b/xlators/performance/io-cache/src/io-cache.c
|
|
|
21ab4e |
@@ -8,6 +8,7 @@
|
|
|
21ab4e |
cases as published by the Free Software Foundation.
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
|
|
|
21ab4e |
+#include <math.h>
|
|
|
21ab4e |
#include "glusterfs.h"
|
|
|
21ab4e |
#include "logging.h"
|
|
|
21ab4e |
#include "dict.h"
|
|
|
21ab4e |
@@ -2155,7 +2156,7 @@ struct volume_options options[] = {
|
|
|
21ab4e |
{ .key = {"cache-size"},
|
|
|
21ab4e |
.type = GF_OPTION_TYPE_SIZET,
|
|
|
21ab4e |
.min = 4 * GF_UNIT_MB,
|
|
|
21ab4e |
- .max = 32 * GF_UNIT_GB,
|
|
|
21ab4e |
+ .max = INFINITY,
|
|
|
21ab4e |
.default_value = "32MB",
|
|
|
21ab4e |
.description = "Size of the read cache."
|
|
|
21ab4e |
},
|
|
|
21ab4e |
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
|
|
|
21ab4e |
index 4e9c6dc..8edf495 100644
|
|
|
21ab4e |
--- a/xlators/performance/quick-read/src/quick-read.c
|
|
|
21ab4e |
+++ b/xlators/performance/quick-read/src/quick-read.c
|
|
|
21ab4e |
@@ -8,6 +8,7 @@
|
|
|
21ab4e |
cases as published by the Free Software Foundation.
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
|
|
|
21ab4e |
+#include <math.h>
|
|
|
21ab4e |
#include "quick-read.h"
|
|
|
21ab4e |
#include "statedump.h"
|
|
|
21ab4e |
#include "quick-read-messages.h"
|
|
|
21ab4e |
@@ -1144,7 +1145,7 @@ struct volume_options options[] = {
|
|
|
21ab4e |
{ .key = {"cache-size"},
|
|
|
21ab4e |
.type = GF_OPTION_TYPE_SIZET,
|
|
|
21ab4e |
.min = 0,
|
|
|
21ab4e |
- .max = 32 * GF_UNIT_GB,
|
|
|
21ab4e |
+ .max = INFINITY,
|
|
|
21ab4e |
.default_value = "128MB",
|
|
|
21ab4e |
.description = "Size of the read cache."
|
|
|
21ab4e |
},
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|