summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2019-04-08 18:54:46 +0530
committerAtin Mukherjee <amukherj@redhat.com>2019-04-11 15:19:30 +0000
commit7108913337f24d3d7a39d919a29872fe50072cf4 (patch)
tree826ecbcb91847225db611e6da5ea5767fab59b97
parent35dd17e222fe172866e15824e5ac9d242382178c (diff)
glusterd: remove glusterd_check_volume_exists() call
As the same functionality is covered in glusterd_volinfo_find Updates: bz#1193929 Change-Id: I2308c5fa9b2ca9edaa95f172d0bd914103808c36 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c11
5 files changed, 16 insertions, 23 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index df761e9f948..0af1e9a00d4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -779,13 +779,13 @@ static int
glusterd_validate_shared_storage(char *key, char *value, char *errstr)
{
int32_t ret = -1;
- int32_t exists = -1;
int32_t count = -1;
char *op = NULL;
char hook_script[PATH_MAX] = "";
xlator_t *this = NULL;
glusterd_conf_t *conf = NULL;
int32_t len = 0;
+ glusterd_volinfo_t *volinfo = NULL;
this = THIS;
GF_VALIDATE_OR_GOTO("glusterd", this, out);
@@ -853,8 +853,8 @@ glusterd_validate_shared_storage(char *key, char *value, char *errstr)
goto out;
}
- exists = glusterd_check_volume_exists(GLUSTER_SHARED_STORAGE);
- if (exists) {
+ ret = glusterd_volinfo_find(GLUSTER_SHARED_STORAGE, &volinfo);
+ if (!ret) {
snprintf(errstr, PATH_MAX,
"Shared storage volume(" GLUSTER_SHARED_STORAGE
") already exists.");
@@ -1734,11 +1734,11 @@ glusterd_op_stage_sync_volume(dict_t *dict, char **op_errstr)
int ret = -1;
char *volname = NULL;
char *hostname = NULL;
- gf_boolean_t exists = _gf_false;
glusterd_peerinfo_t *peerinfo = NULL;
char msg[2048] = {
0,
};
+ glusterd_volinfo_t *volinfo = NULL;
ret = dict_get_strn(dict, "hostname", SLEN("hostname"), &hostname);
if (ret) {
@@ -1753,14 +1753,13 @@ glusterd_op_stage_sync_volume(dict_t *dict, char **op_errstr)
// volname is not present in case of sync all
ret = dict_get_strn(dict, "volname", SLEN("volname"), &volname);
if (!ret) {
- exists = glusterd_check_volume_exists(volname);
- if (!exists) {
+ ret = glusterd_volinfo_find(volname, &volinfo);
+ if (ret) {
snprintf(msg, sizeof(msg),
"Volume %s "
"does not exist",
volname);
*op_errstr = gf_strdup(msg);
- ret = -1;
goto out;
}
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 8f5cd6de2aa..abbcb6288f4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -2247,6 +2247,7 @@ glusterd_snapshot_clone_prevalidate(dict_t *dict, char **op_errstr,
xlator_t *this = NULL;
uuid_t *snap_volid = NULL;
gf_loglevel_t loglevel = GF_LOG_ERROR;
+ glusterd_volinfo_t *volinfo = NULL;
this = THIS;
GF_ASSERT(op_errstr);
@@ -2267,7 +2268,8 @@ glusterd_snapshot_clone_prevalidate(dict_t *dict, char **op_errstr,
goto out;
}
- if (glusterd_check_volume_exists(clonename)) {
+ ret = glusterd_volinfo_find(clonename, &volinfo);
+ if (!ret) {
ret = -1;
snprintf(err_str, sizeof(err_str),
"Volume with name:%s "
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 565f8b7dc3b..87914c4799c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -569,14 +569,6 @@ out:
return ret;
}
-gf_boolean_t
-glusterd_check_volume_exists(char *volname)
-{
- glusterd_volinfo_t *volinfo = NULL;
-
- return (glusterd_volinfo_find(volname, &volinfo) == 0);
-}
-
glusterd_volinfo_t *
glusterd_volinfo_unref(glusterd_volinfo_t *volinfo)
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 3647c343b47..ae4bc5e8ecf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -145,9 +145,6 @@ glusterd_auth_set_password(glusterd_volinfo_t *volinfo, char *password);
void
glusterd_auth_cleanup(glusterd_volinfo_t *volinfo);
-gf_boolean_t
-glusterd_check_volume_exists(char *volname);
-
int32_t
glusterd_brickprocess_new(glusterd_brick_proc_t **brickprocess);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 5e8673640b6..fa3d620a4b0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -300,6 +300,7 @@ __glusterd_handle_create_volume(rpcsvc_request_t *req)
#else
char *addr_family = "inet";
#endif
+ glusterd_volinfo_t *volinfo = NULL;
GF_ASSERT(req);
@@ -353,7 +354,9 @@ __glusterd_handle_create_volume(rpcsvc_request_t *req)
goto out;
}
- if ((ret = glusterd_check_volume_exists(volname))) {
+ ret = glusterd_volinfo_find(volname, &volinfo);
+ if (!ret) {
+ ret = -1;
snprintf(err_str, sizeof(err_str), "Volume %s already exists", volname);
gf_msg(this->name, GF_LOG_ERROR, EEXIST, GD_MSG_VOL_ALREADY_EXIST, "%s",
err_str);
@@ -1136,7 +1139,6 @@ glusterd_op_stage_create_volume(dict_t *dict, char **op_errstr,
{
int ret = 0;
char *volname = NULL;
- gf_boolean_t exists = _gf_false;
char *bricks = NULL;
char *brick_list = NULL;
char *free_ptr = NULL;
@@ -1154,6 +1156,7 @@ glusterd_op_stage_create_volume(dict_t *dict, char **op_errstr,
uuid_t volume_uuid;
char *volume_uuid_str;
gf_boolean_t is_force = _gf_false;
+ glusterd_volinfo_t *volinfo = NULL;
this = THIS;
GF_ASSERT(this);
@@ -1168,8 +1171,8 @@ glusterd_op_stage_create_volume(dict_t *dict, char **op_errstr,
goto out;
}
- exists = glusterd_check_volume_exists(volname);
- if (exists) {
+ ret = glusterd_volinfo_find(volname, &volinfo);
+ if (!ret) {
snprintf(msg, sizeof(msg), "Volume %s already exists", volname);
ret = -1;
goto out;