summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-09-06 00:13:04 +0530
committerAnand Avati <avati@redhat.com>2012-09-06 00:34:15 -0700
commitd6c99b6134f1eb90b3a8020c3538101df266e9b5 (patch)
treea5ec27bcf3136ddfda5ce5f21917bea50ad3be58 /xlators/mgmt
parent54b71368ef290bc579f113e683a82b09893fb50a (diff)
libglusterfs/dict: make 'dict_t' a opaque object
* ie, don't dereference dict_t pointer, instead use APIs everywhere * other than dict_t only 'data_t' should be the valid export from dict.h * added 'dict_foreach_fnmatch()' API * changed dict_lookup() to use data_t, instead of data_pair_t Change-Id: I400bb0dd55519a7c5d2a107e67c8e7a7207228dc Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 850917 Reviewed-on: http://review.gluster.org/3829 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c15
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c17
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c9
8 files changed, 70 insertions, 52 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 808b1276b25..2a7cfca914b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -172,7 +172,7 @@ glusterd_urltransform_add (runner_t *runner, const char *url)
runner_add_arg (runner, url);
}
-static void
+static int
_glusterd_urltransform_add_iter (dict_t *dict, char *key, data_t *value, void *data)
{
runner_t *runner = (runner_t *)data;
@@ -182,6 +182,8 @@ _glusterd_urltransform_add_iter (dict_t *dict, char *key, data_t *value, void *d
GF_ASSERT (slave);
slave++;
runner_add_arg (runner, slave);
+
+ return 0;
}
static void
@@ -296,7 +298,7 @@ struct dictidxmark {
char *ikey;
};
-static void
+static int
_dict_mark_atindex (dict_t *dict, char *key, data_t *value, void *data)
{
struct dictidxmark *dim = data;
@@ -305,6 +307,7 @@ _dict_mark_atindex (dict_t *dict, char *key, data_t *value, void *data)
dim->ikey = key;
dim->ithis++;
+ return 0;
}
static char *
@@ -734,7 +737,7 @@ static int
glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo,
char *slave, dict_t *rsp_dict);
-static void
+static int
_get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
{
glusterd_gsync_status_temp_t *param = NULL;
@@ -750,15 +753,15 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
if (slave)
slave ++;
else
- return;
+ return 0;
ret = glusterd_get_gsync_status_mst_slv(param->volinfo,
slave, param->rsp_dict);
-
+ return 0;
}
-static void
+static int
_get_max_gsync_slave_num (dict_t *this, char *key, data_t *value, void *data)
{
int tmp_slvnum = 0;
@@ -767,6 +770,8 @@ _get_max_gsync_slave_num (dict_t *this, char *key, data_t *value, void *data)
sscanf (key, "slave%d", &tmp_slvnum);
if (tmp_slvnum > *slvnum)
*slvnum = tmp_slvnum;
+
+ return 0;
}
static int
@@ -1987,7 +1992,7 @@ glusterd_do_gsync_log_rotation_mst_slv (glusterd_volinfo_t *volinfo, char *slave
return ret;
}
-static void
+static int
_iterate_log_rotate_mst_slv (dict_t *this, char *key, data_t *value, void *data)
{
glusterd_gsync_status_temp_t *param = NULL;
@@ -2004,10 +2009,11 @@ _iterate_log_rotate_mst_slv (dict_t *this, char *key, data_t *value, void *data)
else {
gf_log ("", GF_LOG_ERROR, "geo-replication log-rotate: slave (%s) "
"not conforming to format", slave);
- return;
+ return -1;
}
(void) glusterd_do_gsync_log_rotation_mst_slv (param->volinfo, slave, NULL);
+ return 0;
}
static int
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 8804176dcc6..180b28294fd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -278,7 +278,6 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo = NULL;
char *buf = NULL;
int i = 1;
- data_pair_t *pairs = NULL;
char reconfig_key[256] = {0, };
dict_t *dict = NULL;
int opt_count = 0;
@@ -365,14 +364,15 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
goto out;
}
- for (pairs = dict->members_list; pairs != NULL; pairs = pairs->next) {
- snprintf (reconfig_key, 256, "volume%d.option.%s", count,
- pairs->key);
- ret = dict_set_str (volumes, reconfig_key, pairs->value->data);
+ int _build_option_key (dict_t *d, char *k, data_t *v, void *tmp)
+ {
+ snprintf (reconfig_key, 256, "volume%d.option.%s", count, k);
+ ret = dict_set_str (volumes, reconfig_key, v->data);
if (0 == ret)
- opt_count++;
-
+ opt_count++;
+ return 0;
}
+ dict_foreach (dict, _build_option_key, NULL);
snprintf (key, 256, "volume%d.opt_count", count);
ret = dict_set_int32 (volumes, key, opt_count);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index aea27500d6a..4385f876498 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -851,7 +851,7 @@ out:
}
-static void
+static int
_delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data)
{
int32_t *is_force = 0;
@@ -873,7 +873,7 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data)
key, value->data);
dict_del (this, key);
out:
- return;
+ return 0;
}
static int
@@ -3045,7 +3045,7 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
return ret;
}
-void
+int
_profile_volume_add_brick_rsp (dict_t *this, char *key, data_t *value,
void *data)
{
@@ -3058,6 +3058,7 @@ _profile_volume_add_brick_rsp (dict_t *this, char *key, data_t *value,
GF_ASSERT (new_value);
snprintf (new_key, sizeof (new_key), "%d-%s", rsp_ctx->count, key);
dict_set (rsp_ctx->dict, new_key, new_value);
+ return 0;
}
int
@@ -3113,7 +3114,7 @@ glusterd_profile_volume_brick_rsp (void *pending_entry,
//input-key: <replica-id>:<child-id>-*
//output-key: <brick-id>-*
-void
+int
_heal_volume_add_shd_rsp (dict_t *this, char *key, data_t *value, void *data)
{
char new_key[256] = {0,};
@@ -3170,7 +3171,7 @@ _heal_volume_add_shd_rsp (dict_t *this, char *key, data_t *value, void *data)
dict_set (rsp_ctx->dict, new_key, new_value);
out:
- return;
+ return 0;
}
int
@@ -3206,7 +3207,7 @@ out:
return ret;
}
-void
+int
_status_volume_add_brick_rsp (dict_t *this, char *key, data_t *value,
void *data)
{
@@ -3219,7 +3220,7 @@ _status_volume_add_brick_rsp (dict_t *this, char *key, data_t *value,
snprintf (new_key, sizeof (new_key), "brick%d.%s", rsp_ctx->count, key);
dict_set (rsp_ctx->dict, new_key, new_value);
- return;
+ return 0;
}
int
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index a3522a98c51..491a3255ec5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -942,7 +942,7 @@ out:
}
-void
+int
_profile_volume_add_friend_rsp (dict_t *this, char *key, data_t *value,
void *data)
{
@@ -953,7 +953,7 @@ _profile_volume_add_friend_rsp (dict_t *this, char *key, data_t *value,
char brick_key[256];
if (strcmp (key, "count") == 0)
- return;
+ return 0;
sscanf (key, "%d%s", &brick_count, brick_key);
rsp_ctx = data;
new_value = data_copy (value);
@@ -961,6 +961,7 @@ _profile_volume_add_friend_rsp (dict_t *this, char *key, data_t *value,
snprintf (new_key, sizeof (new_key), "%d%s",
rsp_ctx->count + brick_count, brick_key);
dict_set (rsp_ctx->dict, new_key, new_value);
+ return 0;
}
int
@@ -995,7 +996,7 @@ out:
return ret;
}
-void
+int
glusterd_volume_status_add_peer_rsp (dict_t *this, char *key, data_t *value,
void *data)
{
@@ -1008,7 +1009,7 @@ glusterd_volume_status_add_peer_rsp (dict_t *this, char *key, data_t *value,
if (!strcmp (key, "count") || !strcmp (key, "cmd") ||
!strcmp (key, "brick-index-max") || !strcmp (key, "other-count"))
- return;
+ return -1;
rsp_ctx = data;
new_value = data_copy (value);
@@ -1029,7 +1030,7 @@ glusterd_volume_status_add_peer_rsp (dict_t *this, char *key, data_t *value,
gf_log ("", GF_LOG_ERROR, "Unable to set key: %s in dict",
key);
- return;
+ return 0;
}
int
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index eef42fb341b..d11454bc4ba 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -541,7 +541,7 @@ out:
return ret;
}
-static void
+static int
_storeslaves (dict_t *this, char *key, data_t *value, void *data)
{
int32_t ret = 0;
@@ -556,12 +556,12 @@ _storeslaves (dict_t *this, char *key, data_t *value, void *data)
GF_ASSERT (value && value->data);
if ((!shandle) || (shandle->fd <= 0) || (!shandle->path))
- return;
+ return -1;
if (!key)
- return;
+ return -1;
if (!value || !value->data)
- return;
+ return -1;
gf_log ("", GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s",
key, value->data);
@@ -570,12 +570,13 @@ _storeslaves (dict_t *this, char *key, data_t *value, void *data)
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to write into store"
" handle for path: %s", shandle->path);
- return;
+ return -1;
}
+ return 0;
}
-void _storeopts (dict_t *this, char *key, data_t *value, void *data)
+int _storeopts (dict_t *this, char *key, data_t *value, void *data)
{
int32_t ret = 0;
int32_t exists = 0;
@@ -590,12 +591,12 @@ void _storeopts (dict_t *this, char *key, data_t *value, void *data)
GF_ASSERT (value && value->data);
if ((!shandle) || (shandle->fd <= 0) || (!shandle->path))
- return;
+ return -1;
if (!key)
- return;
+ return -1;
if (!value || !value->data)
- return;
+ return -1;
if (is_key_glusterd_hooks_friendly (key)) {
exists = 1;
@@ -611,15 +612,16 @@ void _storeopts (dict_t *this, char *key, data_t *value, void *data)
} else {
gf_log ("", GF_LOG_DEBUG, "Discarding:key= %s, val=%s",
key, value->data);
- return;
+ return 0;
}
ret = glusterd_store_save_value (shandle->fd, key, (char*)value->data);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to write into store"
" handle for path: %s", shandle->path);
- return;
+ return -1;
}
+ return 0;
}
int32_t
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 51478fb1246..3a48a41d76c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1615,7 +1615,7 @@ out:
return ret;
}
-void
+int
_add_volinfo_dict_to_prdict (dict_t *this, char *key, data_t *value, void *data)
{
glusterd_voldict_ctx_t *ctx = NULL;
@@ -1637,7 +1637,7 @@ _add_volinfo_dict_to_prdict (dict_t *this, char *key, data_t *value, void *data)
ctx->val_name, ctx->count, value->data);
ctx->opt_count++;
- return;
+ return ret;
}
int32_t
@@ -3495,7 +3495,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
return ret;
}
-void
+int
_local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
{
char *slave = NULL;
@@ -3509,11 +3509,13 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
if (slave)
slave ++;
else
- return;
+ return 0;
uuid_len = (slave - value->data - 1);
strncpy (uuid_str, (char*)value->data, uuid_len);
glusterd_start_gsync (volinfo, slave, uuid_str, NULL);
+
+ return 0;
}
int
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 28f480a3142..1375bd482ef 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -649,14 +649,14 @@ struct opthandler_data {
void *param;
};
-static void
+static int
process_option (dict_t *dict, char *key, data_t *value, void *param)
{
struct opthandler_data *odt = param;
struct volopt_map_entry vme = {0,};
if (odt->rv)
- return;
+ return 0;
odt->found = _gf_true;
vme.key = key;
@@ -675,6 +675,7 @@ process_option (dict_t *dict, char *key, data_t *value, void *param)
vme.value = value->data;
odt->rv = odt->handler (odt->graph, &vme, odt->param);
+ return 0;
}
static int
@@ -3637,16 +3638,18 @@ out:
return ret;
}
-static void
+static int
_check_globalopt (dict_t *this, char *key, data_t *value, void *ret_val)
{
int *ret = NULL;
ret = ret_val;
if (*ret)
- return;
+ return 0;
if (!glusterd_check_globaloption (key))
*ret = 1;
+
+ return 0;
}
int
@@ -3692,16 +3695,18 @@ out:
return ret;
}
-static void
+static int
_check_localopt (dict_t *this, char *key, data_t *value, void *ret_val)
{
int *ret = NULL;
ret = ret_val;
if (*ret)
- return;
+ return 0;
if (!glusterd_check_localoption (key))
*ret = 1;
+
+ return 0;
}
int
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 17a2063948f..f55b3ea51f2 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -655,7 +655,7 @@ check_prepare_mountbroker_root (char *mountbroker_root)
return ret;
}
-static void
+static int
_install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
{
glusterd_conf_t *priv = THIS->private;
@@ -671,7 +671,7 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
char *volfile_server = NULL;
if (*ret == -1)
- return;
+ return -1;
label = strtail (key, "mountbroker.");
@@ -688,7 +688,7 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
}
if (!label)
- return;
+ return -1;
mspec = GF_CALLOC (1, sizeof (*mspec), gf_gld_mt_mount_spec);
if (!mspec)
@@ -727,7 +727,7 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
list_add_tail (&mspec->speclist, &priv->mount_specs);
- return;
+ return 0;
err:
gf_log ("", GF_LOG_ERROR,
@@ -735,6 +735,7 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
georep ? GEOREP" " : "", label, pdesc);
*ret = -1;
+ return -1;
}
/*