From c002b3d76486128ba78328b4a96ae0a1d8fe9cd0 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Thu, 6 Apr 2017 16:36:29 +0530 Subject: glusterd: Add validation for options rda-cache-limit rda-request-size Currently when prarallel readdir is enabled, setting any junk value to rda-cache-limit and rda-request-size succeeds. This is because of bug in the special handling of these options. Fixing the same in this patch Change-Id: I902cd9ac9134c158ab6f8aea4b001254a03547bd BUG: 1439640 Signed-off-by: Poornima G Reviewed-on: https://review.gluster.org/17008 NetBSD-regression: NetBSD Build System Smoke: Gluster Build System Reviewed-by: Atin Mukherjee CentOS-regression: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 41 ++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 59d1eceb182..30d22fadbf4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3787,17 +3787,44 @@ client_graph_set_rda_options (volgen_graph_t *graph, !glusterd_volinfo_get_boolean (volinfo, VKEY_READDIR_AHEAD)) goto out; - ret = glusterd_volinfo_get (volinfo, VKEY_RDA_CACHE_LIMIT, &rda_cache_s); - if (ret < 0) + /* glusterd_volinfo_get() will get the default value if nothing set + * explicitly. Hence it is important to check set_dict before checking + * glusterd_volinfo_get, so that we consider key value of the in + * progress volume set option. + */ + ret = dict_get_str (set_dict, VKEY_RDA_CACHE_LIMIT, &rda_cache_s); + if (ret < 0) { + ret = glusterd_volinfo_get (volinfo, VKEY_RDA_CACHE_LIMIT, + &rda_cache_s); + if (ret < 0) + goto out; + } + ret = gf_string2bytesize_uint64 (rda_cache_s, &rda_cache_size); + if (ret < 0) { + set_graph_errstr (graph, "invalid number format in option " + VKEY_RDA_CACHE_LIMIT); goto out; + } - gf_string2bytesize_uint64 (rda_cache_s, &rda_cache_size); - - ret = glusterd_volinfo_get (volinfo, VKEY_RDA_REQUEST_SIZE, &rda_req_s); - if (ret < 0) + ret = dict_get_str (set_dict, VKEY_RDA_REQUEST_SIZE, &rda_req_s); + if (ret < 0) { + ret = glusterd_volinfo_get (volinfo, VKEY_RDA_REQUEST_SIZE, + &rda_req_s); + if (ret < 0) + goto out; + } + gf_string2bytesize_uint64 (rda_req_s, &rda_req_size); + if (ret < 0) { + set_graph_errstr (graph, "invalid number format in option " + VKEY_RDA_REQUEST_SIZE); goto out; + } - gf_string2bytesize_uint64 (rda_req_s, &rda_req_size); + if (rda_cache_size == 0 || rda_req_size == 0) { + set_graph_errstr (graph, "Value cannot be 0"); + ret = -1; + goto out; + } new_cache_size = rda_cache_size / dist_count; if (new_cache_size < rda_req_size) { -- cgit