summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2017-07-13 08:10:27 -0400
committerJeff Darcy <jeff@pl.atyp.us>2017-07-14 02:42:23 +0000
commite648a291b02298d2f1063cedaad9a58614ebe0ad (patch)
tree48e9b1b66e47cb1855b4912bd940449f3fe6400b /xlators/mgmt
parentd2650feb4bfadf3fb0cdb90236bc78c33b5ea451 (diff)
core: miscellaneous cleanup
clean up things that I tripped over doing other changes. 1) fix mishmash of random spacing in struct decls in glusterfs.h. Not technically a problem, just ugly to look at. 2) replace open-coded strings constants with existing #define constants. A disaster waiting to happen. 3) Use sys_access() instead of sys_stat() or sys_lstat() to test simple existence of file. Why copy dozens of bytes from kernel to user space that aren't going to be used by anything? There are probably more instances like these. Change-Id: I28089bef4cc93d5e4e4213045fb1a2649d110f82 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/17769 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c4
4 files changed, 11 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index b86580f9f0b..3a6445d8ace 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -4721,11 +4721,12 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
}
}
- if (strcmp (key, "cluster.max-op-version") == 0) {
+ if (strcmp (key, GLUSTERD_MAX_OP_VERSION_KEY) == 0) {
ret = glusterd_get_global_max_op_version (req, dict, 1);
if (ret)
goto out;
- } else if (strcmp (key, "cluster.op-version") == 0) {
+ } else if (strcmp (key,
+ GLUSTERD_GLOBAL_OP_VERSION_KEY) == 0) {
sprintf (dict_key, "key%d", count);
ret = dict_set_str(dict, dict_key, key);
if (ret) {
@@ -4958,7 +4959,7 @@ glusterd_print_global_options (dict_t *opts, char *key, data_t *val, void *data)
GF_VALIDATE_OR_GOTO (THIS->name, val, out);
GF_VALIDATE_OR_GOTO (THIS->name, data, out);
- if (strcmp (key, "global-option-version") == 0)
+ if (strcmp (key, GLUSTERD_GLOBAL_OPT_VERSION) == 0)
goto out;
fp = (FILE *) data;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 6b12d603728..0ac64858c11 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -774,7 +774,6 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr)
char hook_script[PATH_MAX] = "";
xlator_t *this = NULL;
glusterd_conf_t *conf = NULL;
- struct stat stbuf = {0,};
this = THIS;
GF_VALIDATE_OR_GOTO ("glusterd", this, out);
@@ -806,7 +805,7 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr)
snprintf (hook_script, sizeof(hook_script),
"%s"GLUSTERD_SHRD_STRG_HOOK_SCRIPT, conf->workdir);
- ret = sys_lstat (hook_script, &stbuf);
+ ret = sys_access (hook_script, R_OK|X_OK);
if (ret) {
snprintf (errstr, PATH_MAX,
"The hook-script (%s) required "
@@ -900,7 +899,6 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
gf_boolean_t check_op_version = _gf_true;
gf_boolean_t trash_enabled = _gf_false;
gf_boolean_t all_vol = _gf_false;
- struct stat stbuf = {0, };
GF_ASSERT (dict);
this = THIS;
@@ -1128,7 +1126,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
/* Check if the key is cluster.op-version and set
* local_new_op_version to the value given if possible.
*/
- if (strcmp (key, "cluster.op-version") == 0) {
+ if (strcmp (key, GLUSTERD_GLOBAL_OP_VERSION_KEY) == 0) {
if (!all_vol) {
ret = -1;
snprintf (errstr, sizeof (errstr), "Option \""
@@ -1292,7 +1290,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
/* Checks whether a directory with
given option exists or not */
- if (!sys_stat (trash_path, &stbuf)) {
+ if (!sys_access (trash_path, R_OK)) {
snprintf (errstr,
sizeof (errstr),
"Path %s exists",
@@ -2508,7 +2506,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
/* If the key is cluster.op-version, set conf->op_version to the value
* if needed and save it.
*/
- if (strcmp(key, "cluster.op-version") == 0) {
+ if (strcmp(key, GLUSTERD_GLOBAL_OP_VERSION_KEY) == 0) {
ret = 0;
ret = gf_string2uint (value, &op_version);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index cf50e82e849..fce56b12e9c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -39,7 +39,7 @@
int32_t i = 0; \
\
if (!get_opt && (!strcmp (key, "all") || \
- !strcmp (key, "cluster.max-op-version"))) { \
+ !strcmp (key, GLUSTERD_MAX_OP_VERSION_KEY))) {\
ret = -1; \
*op_errstr = gf_strdup ("Not a valid option to set"); \
goto out; \
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 60a1d9be5fa..906fec07018 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -2859,12 +2859,12 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.value = BARRIER_TIMEOUT,
.op_version = GD_OP_VERSION_3_6_0,
},
- { .key = "cluster.op-version",
+ { .key = GLUSTERD_GLOBAL_OP_VERSION_KEY,
.voltype = "mgmt/glusterd",
.op_version = GD_OP_VERSION_3_6_0,
},
{
- .key = "cluster.max-op-version",
+ .key = GLUSTERD_MAX_OP_VERSION_KEY,
.voltype = "mgmt/glusterd",
.op_version = GD_OP_VERSION_3_10_0,
},