Some (mgmt) xlators: use dict_{setn|getn|deln|get_int32n|set_int32n|set_strn}
In a previous patch (https://review.gluster.org/20769) we've added the key length to be passed to dict_* funcs, to remove the need to strlen() it. This patch moves some xlators to use it. - It also adds dict_get_int32n which was missing. - It also reduces the size of some key variables. They were set to 1024b or PATH_MAX, where sometimes 64 bytes were really enough. Please review carefully: 1. That I did not reduce some the size of the key variables too much. 2. That I did not mix up some keys. Compile-tested only! Change-Id: Ic729baf179f40e8d02bc2350491d4bb9b6934266 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
This commit is contained in:
parent
44e4db05a9
commit
09198e203e
@ -1809,6 +1809,32 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
dict_get_int32n (dict_t *this, char *key, const int keylen, int32_t *val)
|
||||
{
|
||||
data_t * data = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!this || !key || !val) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = dict_get_with_refn (this, key, keylen, &data);
|
||||
if (ret != 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
VALIDATE_DATA_AND_LOG(data, GF_DATA_TYPE_INT, key, -EINVAL);
|
||||
|
||||
ret = data_to_int32_ptr (data, val);
|
||||
|
||||
err:
|
||||
if (data)
|
||||
data_unref (data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
dict_get_int32 (dict_t *this, char *key, int32_t *val)
|
||||
{
|
||||
@ -1835,6 +1861,25 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
dict_set_int32n (dict_t *this, char *key, const int keylen, int32_t val)
|
||||
{
|
||||
data_t * data = NULL;
|
||||
int ret = 0;
|
||||
|
||||
data = data_from_int32 (val);
|
||||
if (!data) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = dict_setn (this, key, keylen, data);
|
||||
if (ret < 0)
|
||||
data_destroy (data);
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
dict_set_int32 (dict_t *this, char *key, int32_t val)
|
||||
|
@ -113,7 +113,8 @@ int32_t dict_setn (dict_t *this, char *key, const int keylen, data_t *value);
|
||||
int32_t dict_add (dict_t *this, char *key, data_t *value);
|
||||
int32_t dict_addn (dict_t *this, char *key, const int keylen, data_t *value);
|
||||
int dict_get_with_ref (dict_t *this, char *key, data_t **data);
|
||||
int dict_get_with_refn (dict_t *this, char *key, const int keylen, data_t **data);
|
||||
int dict_get_with_refn (dict_t *this, char *key, const int keylen,
|
||||
data_t **data);
|
||||
data_t *dict_get (dict_t *this, char *key);
|
||||
data_t *dict_getn (dict_t *this, char *key, const int keylen);
|
||||
void dict_del (dict_t *this, char *key);
|
||||
@ -219,7 +220,11 @@ GF_MUST_CHECK int dict_get_int16 (dict_t *this, char *key, int16_t *val);
|
||||
GF_MUST_CHECK int dict_set_int16 (dict_t *this, char *key, int16_t val);
|
||||
|
||||
GF_MUST_CHECK int dict_get_int32 (dict_t *this, char *key, int32_t *val);
|
||||
GF_MUST_CHECK int dict_get_int32n (dict_t *this, char *key, const int keylen,
|
||||
int32_t *val);
|
||||
GF_MUST_CHECK int dict_set_int32 (dict_t *this, char *key, int32_t val);
|
||||
GF_MUST_CHECK int dict_set_int32n (dict_t *this, char *key, const int keylen,
|
||||
int32_t val);
|
||||
|
||||
GF_MUST_CHECK int dict_get_int64 (dict_t *this, char *key, int64_t *val);
|
||||
GF_MUST_CHECK int dict_set_int64 (dict_t *this, char *key, int64_t val);
|
||||
@ -251,14 +256,18 @@ GF_MUST_CHECK int dict_set_static_bin (dict_t *this, char *key, void *ptr, size_
|
||||
|
||||
GF_MUST_CHECK int dict_set_option (dict_t *this, char *key, char *str);
|
||||
GF_MUST_CHECK int dict_set_str (dict_t *this, char *key, char *str);
|
||||
GF_MUST_CHECK int dict_set_strn (dict_t *this, char *key, const int keylen, char *str);
|
||||
GF_MUST_CHECK int dict_set_nstrn (dict_t *this, char *key, const int keylen, char *str, const int vallen);
|
||||
GF_MUST_CHECK int dict_set_strn (dict_t *this, char *key, const int keylen,
|
||||
char *str);
|
||||
GF_MUST_CHECK int dict_set_nstrn (dict_t *this, char *key, const int keylen,
|
||||
char *str, const int vallen);
|
||||
GF_MUST_CHECK int dict_set_dynstr (dict_t *this, char *key, char *str);
|
||||
GF_MUST_CHECK int dict_set_dynstrn (dict_t *this, char *key, const int keylen, char *str);
|
||||
GF_MUST_CHECK int dict_set_dynstrn (dict_t *this, char *key, const int keylen,
|
||||
char *str);
|
||||
GF_MUST_CHECK int dict_set_dynstr_with_alloc (dict_t *this, char *key, const char *str);
|
||||
GF_MUST_CHECK int dict_add_dynstr_with_alloc (dict_t *this, char *key, char *str);
|
||||
GF_MUST_CHECK int dict_get_str (dict_t *this, char *key, char **str);
|
||||
GF_MUST_CHECK int dict_get_strn (dict_t *this, char *key, const int keylen, char **str);
|
||||
GF_MUST_CHECK int dict_get_strn (dict_t *this, char *key, const int keylen,
|
||||
char **str);
|
||||
|
||||
GF_MUST_CHECK int dict_get_str_boolean (dict_t *this, char *key, int default_val);
|
||||
GF_MUST_CHECK int dict_rename_key (dict_t *this, char *key, char *replace_key);
|
||||
|
@ -354,11 +354,13 @@ default_put_resume
|
||||
__dentry_grep
|
||||
dht_is_linkfile
|
||||
dict_add
|
||||
dict_addn
|
||||
dict_add_dynstr_with_alloc
|
||||
dict_allocate_and_serialize
|
||||
dict_copy
|
||||
dict_copy_with_ref
|
||||
dict_del
|
||||
dict_deln
|
||||
dict_dump_to_statedump
|
||||
dict_dump_to_str
|
||||
dict_dump_to_log
|
||||
@ -367,17 +369,20 @@ dict_foreach_fnmatch
|
||||
dict_foreach_match
|
||||
dict_for_key_value
|
||||
dict_get
|
||||
dict_getn
|
||||
dict_get_bin
|
||||
dict_get_double
|
||||
dict_get_gfuuid
|
||||
dict_get_iatt
|
||||
dict_get_int16
|
||||
dict_get_int32
|
||||
dict_get_int32n
|
||||
dict_get_int64
|
||||
dict_get_int8
|
||||
dict_get_ptr
|
||||
dict_get_ptr_and_len
|
||||
dict_get_str
|
||||
dict_get_strn
|
||||
dict_get_str_boolean
|
||||
dict_get_uint32
|
||||
dict_get_uint64
|
||||
@ -396,21 +401,25 @@ dict_serialize
|
||||
dict_serialized_length
|
||||
dict_serialize_value_with_delim
|
||||
dict_set
|
||||
dict_setn
|
||||
dict_set_bin
|
||||
dict_set_double
|
||||
dict_set_dynptr
|
||||
dict_set_dynstr
|
||||
dict_set_dynstrn
|
||||
dict_set_dynstr_with_alloc
|
||||
dict_set_gfuuid
|
||||
dict_set_iatt
|
||||
dict_set_int16
|
||||
dict_set_int32
|
||||
dict_set_int32n
|
||||
dict_set_int64
|
||||
dict_set_int8
|
||||
dict_set_static_bin
|
||||
dict_set_static_ptr
|
||||
dict_set_str
|
||||
dict_set_strn
|
||||
dict_setn_nstrn
|
||||
dict_set_nstrn
|
||||
dict_set_uint32
|
||||
dict_set_uint64
|
||||
|
@ -465,7 +465,7 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
@ -484,7 +484,7 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
"brick count");
|
||||
@ -493,28 +493,31 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count", SLEN ("replica-count"),
|
||||
&replica_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS, "replica-count is %d",
|
||||
replica_count);
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "arbiter-count", &arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count", SLEN ("arbiter-count"),
|
||||
&arbiter_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS, "arbiter-count is %d",
|
||||
arbiter_count);
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "stripe-count", &stripe_count);
|
||||
ret = dict_get_int32n (dict, "stripe-count", SLEN ("stripe-count"),
|
||||
&stripe_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS, "stripe-count is %d",
|
||||
stripe_count);
|
||||
}
|
||||
|
||||
if (!dict_get (dict, "force")) {
|
||||
if (!dict_getn (dict, "force", SLEN ("force"))) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get flag");
|
||||
goto out;
|
||||
@ -532,7 +535,7 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
|
||||
total_bricks = volinfo->brick_count + brick_count;
|
||||
|
||||
if (dict_get (dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
||||
snprintf (err_str, sizeof (err_str),
|
||||
"Volume %s is already a tier.", volname);
|
||||
@ -550,7 +553,7 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "hot-type", &type);
|
||||
ret = dict_get_int32n (dict, "hot-type", SLEN ("hot-type"), &type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -608,7 +611,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
if (ret == 1)
|
||||
stripe_count = 0;
|
||||
|
||||
ret = dict_set_int32 (dict, "stripe-count", stripe_count);
|
||||
ret = dict_set_int32n (dict, "stripe-count",
|
||||
SLEN ("stripe-count"), stripe_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -632,7 +636,8 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
if (ret == 1)
|
||||
replica_count = 0;
|
||||
|
||||
ret = dict_set_int32 (dict, "replica-count", replica_count);
|
||||
ret = dict_set_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), replica_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -641,7 +646,7 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
|
||||
brick_val:
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
"bricks");
|
||||
@ -651,7 +656,7 @@ brick_val:
|
||||
}
|
||||
|
||||
if (type != volinfo->type) {
|
||||
ret = dict_set_int32 (dict, "type", type);
|
||||
ret = dict_set_int32n (dict, "type", SLEN ("type"), type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -805,7 +810,7 @@ glusterd_set_detach_bricks(dict_t *dict, glusterd_volinfo_t *volinfo)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_set_int32(dict, "count", hot_brick_num);
|
||||
ret = dict_set_int32n (dict, "count", SLEN ("count"), hot_brick_num);
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
@ -886,6 +891,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
int32_t count = 0;
|
||||
char *brick = NULL;
|
||||
char key[64] = "";
|
||||
int keylen;
|
||||
int i = 1;
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
glusterd_brickinfo_t *brickinfo = NULL;
|
||||
@ -935,7 +941,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
"name");
|
||||
@ -944,7 +950,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &count);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get brick "
|
||||
"count");
|
||||
@ -971,7 +977,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "command", &cmd);
|
||||
ret = dict_get_int32n (dict, "command", SLEN ("command"), &cmd);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get cmd "
|
||||
"ccommand");
|
||||
@ -989,7 +995,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count", SLEN ("replica-count"),
|
||||
&replica_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1002,12 +1009,13 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
itself */
|
||||
goto out;
|
||||
}
|
||||
dict_del (dict, "replica-count");
|
||||
dict_deln (dict, "replica-count", SLEN ("replica-count"));
|
||||
if (ret) {
|
||||
replica_count = 0;
|
||||
} else {
|
||||
ret = dict_set_int32 (dict, "replica-count",
|
||||
replica_count);
|
||||
ret = dict_set_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"),
|
||||
replica_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_WARNING, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -1104,8 +1112,8 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
|
||||
while ( i <= count) {
|
||||
snprintf (key, sizeof (key), "brick%d", i);
|
||||
ret = dict_get_str (dict, key, &brick);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d", i);
|
||||
ret = dict_get_strn (dict, key, keylen, &brick);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get %s",
|
||||
key);
|
||||
@ -1233,7 +1241,8 @@ _glusterd_restart_gsync_session (dict_t *this, char *key,
|
||||
else
|
||||
return 0;
|
||||
|
||||
ret = dict_set_dynstr (param->rsp_dict, "slave", slave_buf);
|
||||
ret = dict_set_dynstrn (param->rsp_dict, "slave", SLEN ("slave"),
|
||||
slave_buf);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -1344,23 +1353,26 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
|
||||
brick = strtok_r (brick_list+1, " \n", &saveptr);
|
||||
|
||||
if (dict) {
|
||||
ret = dict_get_int32 (dict, "stripe-count", &stripe_count);
|
||||
ret = dict_get_int32n (dict, "stripe-count",
|
||||
SLEN ("stripe-count"), &stripe_count);
|
||||
if (!ret)
|
||||
gf_msg (THIS->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS,
|
||||
"stripe-count is set %d", stripe_count);
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), &replica_count);
|
||||
if (!ret)
|
||||
gf_msg (THIS->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS,
|
||||
"replica-count is set %d", replica_count);
|
||||
ret = dict_get_int32 (dict, "arbiter-count", &arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count",
|
||||
SLEN ("arbiter-count"), &arbiter_count);
|
||||
if (!ret)
|
||||
gf_msg (THIS->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS,
|
||||
"arbiter-count is set %d", arbiter_count);
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (!ret)
|
||||
gf_msg (THIS->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS,
|
||||
@ -1417,7 +1429,7 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
|
||||
brickinfo->statfs_fsid = brickstat.f_fsid;
|
||||
}
|
||||
/* hot tier bricks are added to head of brick list */
|
||||
if (dict_get (dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
cds_list_add (&brickinfo->brick_list, &volinfo->bricks);
|
||||
} else if (stripe_count || replica_count) {
|
||||
add_brick_at_right_order (brickinfo, volinfo, (i - 1),
|
||||
@ -1443,9 +1455,10 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
|
||||
*/
|
||||
if (type && glusterd_is_volume_replicate (volinfo) &&
|
||||
conf->op_version >= GD_OP_VERSION_3_12_2) {
|
||||
ret = dict_set_str (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
"off");
|
||||
ret = dict_set_nstrn (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
SLEN ("performance.client-io-threads"),
|
||||
"off", SLEN ("off"));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set "
|
||||
@ -1500,7 +1513,7 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
|
||||
*/
|
||||
if (glusterd_is_volume_replicate (volinfo)) {
|
||||
if (replica_count &&
|
||||
!dict_get (dict, "attach-tier") &&
|
||||
!dict_getn (dict, "attach-tier", SLEN ("attach-tier")) &&
|
||||
conf->op_version >= GD_OP_VERSION_3_7_10) {
|
||||
is_valid_add_brick = _gf_true;
|
||||
ret = generate_dummy_client_volfiles (volinfo);
|
||||
@ -1688,7 +1701,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
conf = this->private;
|
||||
GF_ASSERT (conf);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1708,13 +1721,15 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count", SLEN ("replica-count"),
|
||||
&replica_count);
|
||||
if (ret) {
|
||||
gf_msg_debug (THIS->name, 0,
|
||||
"Unable to get replica count");
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "arbiter-count", &arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count",
|
||||
SLEN ("arbiter-count"), &arbiter_count);
|
||||
if (ret) {
|
||||
gf_msg_debug (THIS->name, 0,
|
||||
"No arbiter count present in the dict");
|
||||
@ -1736,7 +1751,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
* is being increased.
|
||||
*/
|
||||
if (conf->op_version >= GD_OP_VERSION_3_7_10 &&
|
||||
!dict_get (dict, "attach-tier") &&
|
||||
!dict_getn (dict, "attach-tier", SLEN ("attach-tier")) &&
|
||||
replica_count &&
|
||||
GLUSTERD_STATUS_STOPPED == volinfo->status) {
|
||||
ret = -1;
|
||||
@ -1831,7 +1846,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get(dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
|
||||
/*
|
||||
* This check is needed because of add/remove brick
|
||||
@ -1854,14 +1869,14 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &count);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get count");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get bricks");
|
||||
@ -1968,8 +1983,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
i++;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "brick_count",
|
||||
local_brick_count);
|
||||
ret = dict_set_int32n (rsp_dict, "brick_count", SLEN ("brick_count"),
|
||||
local_brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -1999,6 +2014,7 @@ glusterd_remove_brick_validate_bricks (gf1_op_commands cmd, int32_t brick_count,
|
||||
char *brick = NULL;
|
||||
char msg[2048] = "";
|
||||
char key[64] = "";
|
||||
int keylen;
|
||||
glusterd_brickinfo_t *brickinfo = NULL;
|
||||
glusterd_peerinfo_t *peerinfo = NULL;
|
||||
int i = 0;
|
||||
@ -2010,8 +2026,8 @@ glusterd_remove_brick_validate_bricks (gf1_op_commands cmd, int32_t brick_count,
|
||||
/* Check whether all the nodes of the bricks to be removed are
|
||||
* up, if not fail the operation */
|
||||
for (i = 1; i <= brick_count; i++) {
|
||||
snprintf (key, sizeof (key), "brick%d", i);
|
||||
ret = dict_get_str (dict, key, &brick);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d", i);
|
||||
ret = dict_get_strn (dict, key, keylen, &brick);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg),
|
||||
"Unable to get %s", key);
|
||||
@ -2159,7 +2175,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED, "Unable to get volume name");
|
||||
@ -2178,7 +2194,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_int32 (dict, "command", &flag);
|
||||
ret = dict_get_int32n (dict, "command", SLEN ("command"), &flag);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2187,7 +2203,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
cmd = flag;
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get brick count");
|
||||
@ -2225,7 +2241,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
case GF_OP_CMD_START:
|
||||
{
|
||||
if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) &&
|
||||
dict_get (dict, "replica-count")) {
|
||||
dict_getn (dict, "replica-count",
|
||||
SLEN ("replica-count"))) {
|
||||
snprintf (msg, sizeof(msg), "Migration of data is not "
|
||||
"needed when reducing replica count. Use the"
|
||||
" 'force' option");
|
||||
@ -2302,7 +2319,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
|
||||
if (is_origin_glusterd (dict)) {
|
||||
ret = glusterd_generate_and_set_task_id
|
||||
(dict, GF_REMOVE_BRICK_TID_KEY);
|
||||
(dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_TASKID_GEN_FAIL,
|
||||
@ -2310,8 +2328,9 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_WARNING, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2521,21 +2540,27 @@ glusterd_op_perform_attach_tier (dict_t *dict,
|
||||
volinfo->tier_info.cold_disperse_count = volinfo->disperse_count;
|
||||
volinfo->tier_info.cold_redundancy_count = volinfo->redundancy_count;
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), &replica_count);
|
||||
if (!ret)
|
||||
volinfo->tier_info.hot_replica_count = replica_count;
|
||||
else
|
||||
volinfo->tier_info.hot_replica_count = 1;
|
||||
volinfo->tier_info.hot_brick_count = count;
|
||||
ret = dict_get_int32 (dict, "hot-type", &type);
|
||||
ret = dict_get_int32n (dict, "hot-type", SLEN ("hot-type"), &type);
|
||||
volinfo->tier_info.hot_type = type;
|
||||
ret = dict_set_int32 (dict, "type", GF_CLUSTER_TYPE_TIER);
|
||||
ret = dict_set_int32n (dict, "type", SLEN ("type"),
|
||||
GF_CLUSTER_TYPE_TIER);
|
||||
|
||||
if (!ret)
|
||||
ret = dict_set_str (volinfo->dict, "features.ctr-enabled", "on");
|
||||
ret = dict_set_nstrn (volinfo->dict, "features.ctr-enabled",
|
||||
SLEN ("features.ctr-enabled"),
|
||||
"on", SLEN ("on"));
|
||||
|
||||
if (!ret)
|
||||
ret = dict_set_str (volinfo->dict, "cluster.tier-mode", "cache");
|
||||
ret = dict_set_nstrn (volinfo->dict, "cluster.tier-mode",
|
||||
SLEN ("cluster.tier-mode"),
|
||||
"cache", SLEN ("cache"));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2557,7 +2582,7 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr)
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
@ -2573,7 +2598,7 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &count);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get count");
|
||||
@ -2581,14 +2606,14 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get bricks");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get(dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
gf_msg_debug (THIS->name, 0, "Adding tier");
|
||||
glusterd_op_perform_attach_tier (dict, volinfo, count, bricks);
|
||||
}
|
||||
@ -2637,7 +2662,7 @@ glusterd_op_add_tier_brick (dict_t *dict, char **op_errstr)
|
||||
priv = this->private;
|
||||
GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
@ -2653,7 +2678,7 @@ glusterd_op_add_tier_brick (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &count);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get count");
|
||||
@ -2661,14 +2686,14 @@ glusterd_op_add_tier_brick (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get bricks");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get(dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
gf_msg_debug (THIS->name, 0, "Adding tier");
|
||||
glusterd_op_perform_attach_tier (dict, volinfo, count, bricks);
|
||||
}
|
||||
@ -2720,6 +2745,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
int32_t count = 0;
|
||||
int32_t i = 1;
|
||||
char key[64] = "";
|
||||
int keylen;
|
||||
int32_t flag = 0;
|
||||
int need_rebalance = 0;
|
||||
int force = 0;
|
||||
@ -2746,7 +2772,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
conf = this->private;
|
||||
GF_VALIDATE_OR_GOTO (this->name, conf, out);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -2761,7 +2787,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "command", &flag);
|
||||
ret = dict_get_int32n (dict, "command", SLEN ("command"), &flag);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get command");
|
||||
@ -2781,7 +2807,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) {
|
||||
ret = glusterd_copy_uuid_to_dict
|
||||
(volinfo->rebal.rebalance_id, dict,
|
||||
GF_REMOVE_BRICK_TID_KEY);
|
||||
GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_REMOVE_BRICK_ID_SET_FAIL,
|
||||
@ -2850,7 +2877,9 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
*/
|
||||
volinfo->rebal.defrag_cmd = cmd;
|
||||
volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_NOT_STARTED;
|
||||
ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY, &task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, errno,
|
||||
"Missing remove-brick-id");
|
||||
@ -2876,8 +2905,10 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
* Revisit this code when this constraint no
|
||||
* longer exist.
|
||||
*/
|
||||
dict_del (volinfo->dict, "features.ctr-enabled");
|
||||
dict_del (volinfo->dict, "cluster.tier-mode");
|
||||
dict_deln (volinfo->dict, "features.ctr-enabled",
|
||||
SLEN ("features.ctr-enabled"));
|
||||
dict_deln (volinfo->dict, "cluster.tier-mode",
|
||||
SLEN ("cluster.tier-mode"));
|
||||
|
||||
hot_shd_key = gd_get_shd_key (volinfo->tier_info.hot_type);
|
||||
cold_shd_key = gd_get_shd_key (volinfo->tier_info.cold_type);
|
||||
@ -2923,7 +2954,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &count);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get count");
|
||||
@ -2944,7 +2975,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
ret = dict_set_int32 (bricks_dict, "count", count);
|
||||
ret = dict_set_int32n (bricks_dict, "count",
|
||||
SLEN ("count"), count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -2954,8 +2986,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
while ( i <= count) {
|
||||
snprintf (key, sizeof(key), "brick%d", i);
|
||||
ret = dict_get_str (dict, key, &brick);
|
||||
keylen = snprintf (key, sizeof(key), "brick%d", i);
|
||||
ret = dict_get_strn (dict, key, keylen, &brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get %s",
|
||||
@ -2972,7 +3004,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
"Failed to duplicate brick name");
|
||||
goto out;
|
||||
}
|
||||
ret = dict_set_dynstr (bricks_dict, key, brick_tmpstr);
|
||||
ret = dict_set_dynstrn (bricks_dict, key, keylen,
|
||||
brick_tmpstr);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -2998,7 +3031,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
if (start_remove)
|
||||
volinfo->rebal.dict = dict_ref (bricks_dict);
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), &replica_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -3036,9 +3070,10 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
|
||||
|
||||
if (!glusterd_is_volume_replicate (volinfo) &&
|
||||
conf->op_version >= GD_OP_VERSION_3_12_2) {
|
||||
ret = dict_set_str (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
"on");
|
||||
ret = dict_set_nstrn (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
SLEN ("performance.client-io-threads"),
|
||||
"on", SLEN ("on"));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set "
|
||||
@ -3135,7 +3170,7 @@ glusterd_op_stage_barrier (dict_t *dict, char **op_errstr)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Volname not present in "
|
||||
@ -3184,7 +3219,7 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Volname not present in "
|
||||
@ -3200,7 +3235,7 @@ glusterd_op_barrier (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "barrier", &barrier_op);
|
||||
ret = dict_get_strn (dict, "barrier", SLEN ("barrier"), &barrier_op);
|
||||
if (ret) {
|
||||
gf_asprintf (op_errstr, "Barrier op for volume %s not present "
|
||||
"in dict", volname);
|
||||
@ -3287,7 +3322,7 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
@ -3306,7 +3341,7 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
"brick count");
|
||||
@ -3315,21 +3350,23 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), &replica_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS, "replica-count is %d",
|
||||
replica_count);
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "arbiter-count", &arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count",
|
||||
SLEN ("arbiter-count"), &arbiter_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_SUCCESS, "arbiter-count is %d",
|
||||
arbiter_count);
|
||||
}
|
||||
|
||||
if (!dict_get (dict, "force")) {
|
||||
if (!dict_getn (dict, "force", SLEN ("force"))) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get flag");
|
||||
ret = -1;
|
||||
@ -3354,7 +3391,7 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get (dict, "attach-tier")) {
|
||||
if (dict_getn (dict, "attach-tier", SLEN ("attach-tier"))) {
|
||||
if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
||||
snprintf (err_str, sizeof (err_str),
|
||||
"Volume %s is already a tier.", volname);
|
||||
@ -3364,7 +3401,8 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "hot-type", &type);
|
||||
ret = dict_get_int32n (dict, "hot-type", SLEN ("hot-type"),
|
||||
&type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -3374,7 +3412,7 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
"bricks");
|
||||
@ -3384,7 +3422,7 @@ __glusterd_handle_add_tier_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
|
||||
if (type != volinfo->type) {
|
||||
ret = dict_set_int32 (dict, "type", type);
|
||||
ret = dict_set_int32n (dict, "type", SLEN ("type"), type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
|
@ -41,7 +41,9 @@ glusterd_conn_init (glusterd_conn_t *conn, char *sockpath,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_str (options, "transport.socket.ignore-enoent", "on");
|
||||
ret = dict_set_nstrn (options, "transport.socket.ignore-enoent",
|
||||
SLEN ("transport.socket.ignore-enoent"),
|
||||
"on", SLEN ("on"));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
@ -109,8 +109,9 @@ int glusterd_gfproxydsvc_init (glusterd_volinfo_t *volinfo)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get_str (this->options, "transport.socket.bind-address",
|
||||
&volfileserver) != 0) {
|
||||
if (dict_get_strn (this->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) != 0) {
|
||||
volfileserver = "localhost";
|
||||
}
|
||||
ret = glusterd_proc_init (&(svc->proc), gfproxyd_svc_name, pidfile,
|
||||
@ -325,8 +326,9 @@ glusterd_gfproxydsvc_start (glusterd_svc_t *svc, int flags)
|
||||
|
||||
if (volinfo->memory_accounting)
|
||||
runner_add_arg (&runner, "--mem-accounting");
|
||||
if (dict_get_str (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
&localtime_logging) == 0) {
|
||||
if (dict_get_strn (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
SLEN (GLUSTERD_LOCALTIME_LOGGING_KEY),
|
||||
&localtime_logging) == 0) {
|
||||
if (strcmp (localtime_logging, "enable") == 0)
|
||||
runner_add_arg (&runner, "--localtime-logging");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -396,7 +396,9 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict,
|
||||
"tier detach commit failed.");
|
||||
goto out;
|
||||
}
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"),
|
||||
&cmd);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "cmd not found");
|
||||
goto out;
|
||||
@ -477,7 +479,8 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
||||
}
|
||||
case GD_OP_ADD_BRICK:
|
||||
{
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get"
|
||||
@ -505,7 +508,8 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
||||
}
|
||||
case GD_OP_START_VOLUME:
|
||||
{
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get"
|
||||
@ -532,7 +536,8 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
||||
}
|
||||
case GD_OP_STOP_VOLUME:
|
||||
{
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get"
|
||||
@ -551,7 +556,8 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
||||
}
|
||||
case GD_OP_ADD_TIER_BRICK:
|
||||
{
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get"
|
||||
@ -574,7 +580,8 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
||||
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get"
|
||||
@ -1196,7 +1203,8 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict,
|
||||
case GD_OP_RESET_BRICK:
|
||||
case GD_OP_ADD_TIER_BRICK:
|
||||
{
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname",
|
||||
SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_CRITICAL, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1684,15 +1692,15 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
|
||||
if (!peerinfo->connected) {
|
||||
if (op == GD_OP_TIER_STATUS || op ==
|
||||
GD_OP_DETACH_TIER_STATUS) {
|
||||
ret = dict_get_int32 (args.dict, "count",
|
||||
&count);
|
||||
ret = dict_get_int32n (args.dict, "count",
|
||||
SLEN ("count"), &count);
|
||||
if (ret)
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
"failed to get index");
|
||||
count++;
|
||||
ret = dict_set_int32 (args.dict, "count",
|
||||
count);
|
||||
ret = dict_set_int32n (args.dict, "count",
|
||||
SLEN ("count"), count);
|
||||
if (ret)
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2330,7 +2338,7 @@ glusterd_set_barrier_value (dict_t *dict, char *option)
|
||||
* As of now only snapshot of single volume is supported,
|
||||
* Hence volname1 is directly fetched
|
||||
*/
|
||||
ret = dict_get_str (dict, "volname1", &volname);
|
||||
ret = dict_get_strn (dict, "volname1", SLEN ("volname1"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Volname not present in "
|
||||
@ -2435,7 +2443,8 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
||||
}
|
||||
|
||||
/* Marking the operation as complete synctasked */
|
||||
ret = dict_set_int32 (dict, "is_synctasked", _gf_true);
|
||||
ret = dict_set_int32n (dict, "is_synctasked",
|
||||
SLEN ("is_synctasked"), _gf_true);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -2530,7 +2539,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
||||
above and along with it the originator glusterd also goes down?
|
||||
Who will initiate the cleanup?
|
||||
*/
|
||||
ret = dict_set_int32 (req_dict, "cleanup", 1);
|
||||
ret = dict_set_int32n (req_dict, "cleanup", SLEN ("cleanup"), 1);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "failed to set dict");
|
||||
|
@ -540,8 +540,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)
|
||||
GF_ASSERT (op_errno);
|
||||
*op_errno = 0;
|
||||
|
||||
if (dict_get_str (this->options, "mountbroker-root",
|
||||
&mountbroker_root) != 0) {
|
||||
if (dict_get_strn (this->options, "mountbroker-root",
|
||||
SLEN ("mountbroker-root"),
|
||||
&mountbroker_root) != 0) {
|
||||
*op_errno = ENOENT;
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "'option mountbroker-root' "
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -621,8 +621,8 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict,
|
||||
}
|
||||
count++;
|
||||
}
|
||||
snprintf (key, sizeof (key), "%s.address-count", prefix);
|
||||
ret = dict_set_int32 (dict, key, count);
|
||||
ret = snprintf (key, sizeof (key), "%s.address-count", prefix);
|
||||
ret = dict_set_int32n (dict, key, ret, count);
|
||||
if (ret)
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -768,8 +768,8 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
|
||||
GF_VALIDATE_OR_GOTO (this->name, (dict != NULL), out);
|
||||
GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out);
|
||||
|
||||
snprintf (key, sizeof (key), "%s.hostname", prefix);
|
||||
ret = dict_get_str (dict, key, &hostname);
|
||||
ret = snprintf (key, sizeof (key), "%s.hostname", prefix);
|
||||
ret = dict_get_strn (dict, key, ret, &hostname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Key %s not present in "
|
||||
@ -793,8 +793,8 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
|
||||
goto out;
|
||||
}
|
||||
|
||||
snprintf (key, sizeof (key), "%s.address-count", prefix);
|
||||
ret = dict_get_int32 (dict, key, &count);
|
||||
ret = snprintf (key, sizeof (key), "%s.address-count", prefix);
|
||||
ret = dict_get_int32n (dict, key, ret, &count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Key %s not present in "
|
||||
@ -803,8 +803,8 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
|
||||
}
|
||||
hostname = NULL;
|
||||
for (i = 0; i < count; i++) {
|
||||
snprintf (key, sizeof (key), "%s.hostname%d",prefix, i);
|
||||
ret = dict_get_str (dict, key, &hostname);
|
||||
ret = snprintf (key, sizeof (key), "%s.hostname%d", prefix, i);
|
||||
ret = dict_get_strn (dict, key, ret, &hostname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Key %s not present "
|
||||
@ -862,8 +862,8 @@ gd_peerinfo_from_dict (dict_t *dict, const char *prefix)
|
||||
goto out;
|
||||
}
|
||||
|
||||
snprintf (key, sizeof (key), "%s.uuid", prefix);
|
||||
ret = dict_get_str (dict, key, &uuid_str);
|
||||
ret = snprintf (key, sizeof (key), "%s.uuid", prefix);
|
||||
ret = dict_get_strn (dict, key, ret, &uuid_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Key %s not present in "
|
||||
@ -917,8 +917,8 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
|
||||
count++;
|
||||
}
|
||||
|
||||
snprintf (key, sizeof (key), "%s.hostname_count", prefix);
|
||||
ret = dict_set_int32 (dict, key, count);
|
||||
ret = snprintf (key, sizeof (key), "%s.hostname_count", prefix);
|
||||
ret = dict_set_int32n (dict, key, ret, count);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
@ -930,41 +930,43 @@ gd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *friends,
|
||||
{
|
||||
|
||||
int ret = -1;
|
||||
char key[256] = {0, };
|
||||
char key[64] = {0, };
|
||||
int keylen;
|
||||
char *peer_uuid_str = NULL;
|
||||
|
||||
GF_ASSERT (peerinfo);
|
||||
GF_ASSERT (friends);
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.uuid", count);
|
||||
peer_uuid_str = gd_peer_uuid_str (peerinfo);
|
||||
ret = dict_set_str (friends, key, peer_uuid_str);
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.uuid", count);
|
||||
ret = dict_set_strn (friends, key, keylen, peer_uuid_str);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.hostname", count);
|
||||
ret = dict_set_str (friends, key, peerinfo->hostname);
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.hostname", count);
|
||||
ret = dict_set_strn (friends, key, keylen, peerinfo->hostname);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.port", count);
|
||||
ret = dict_set_int32 (friends, key, peerinfo->port);
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.port", count);
|
||||
ret = dict_set_int32n (friends, key, keylen, peerinfo->port);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.stateId", count);
|
||||
ret = dict_set_int32 (friends, key, peerinfo->state.state);
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.stateId", count);
|
||||
ret = dict_set_int32n (friends, key, keylen, peerinfo->state.state);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.state", count);
|
||||
ret = dict_set_str (friends, key,
|
||||
glusterd_friend_sm_state_name_get(peerinfo->state.state));
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.state", count);
|
||||
ret = dict_set_strn (friends, key, keylen,
|
||||
glusterd_friend_sm_state_name_get(peerinfo->state.state));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "friend%d.connected", count);
|
||||
ret = dict_set_int32 (friends, key, (int32_t)peerinfo->connected);
|
||||
keylen = snprintf (key, sizeof (key), "friend%d.connected", count);
|
||||
ret = dict_set_int32n (friends, key, keylen,
|
||||
(int32_t)peerinfo->connected);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
@ -162,7 +162,7 @@ __glusterd_handle_quota (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Unable to get volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -171,7 +171,7 @@ __glusterd_handle_quota (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Unable to get type of command");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -281,8 +281,9 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get_str (THIS->options, "transport.socket.bind-address",
|
||||
&volfileserver) != 0)
|
||||
if (dict_get_strn (THIS->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) != 0)
|
||||
volfileserver = "localhost";
|
||||
|
||||
len = snprintf (vol_id, sizeof (vol_id),
|
||||
@ -529,7 +530,8 @@ glusterd_quota_get_default_soft_limit (glusterd_volinfo_t *volinfo,
|
||||
else
|
||||
val = gf_strdup ("80%");
|
||||
|
||||
ret = dict_set_dynstr (rsp_dict, "default-soft-limit", val);
|
||||
ret = dict_set_dynstrn (rsp_dict, "default-soft-limit",
|
||||
SLEN ("default-soft-limit"), val);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set default "
|
||||
@ -1326,7 +1328,7 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "path", &path);
|
||||
ret = dict_get_strn (dict, "path", SLEN ("path"), &path);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to fetch path");
|
||||
@ -1336,15 +1338,17 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_str (dict, "hard-limit", &hard_limit);
|
||||
ret = dict_get_strn (dict, "hard-limit", SLEN ("hard-limit"),
|
||||
&hard_limit);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to fetch hard limit");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get (dict, "soft-limit")) {
|
||||
ret = dict_get_str (dict, "soft-limit", &soft_limit);
|
||||
if (dict_getn (dict, "soft-limit", SLEN ("soft-limit"))) {
|
||||
ret = dict_get_strn (dict, "soft-limit", SLEN ("soft-limit"),
|
||||
&soft_limit);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to fetch "
|
||||
@ -1369,7 +1373,7 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "gfid", &gfid_str);
|
||||
ret = dict_get_strn (dict, "gfid", SLEN ("gfid"), &gfid_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get gfid of path "
|
||||
@ -1459,7 +1463,7 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "path", &path);
|
||||
ret = dict_get_strn (dict, "path", SLEN ("path"), &path);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to fetch path");
|
||||
@ -1477,7 +1481,7 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "gfid", &gfid_str);
|
||||
ret = dict_get_strn (dict, "gfid", SLEN ("gfid"), &gfid_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get gfid of path "
|
||||
@ -1516,7 +1520,7 @@ glusterd_set_quota_option (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "value", &value);
|
||||
ret = dict_get_strn (dict, "value", SLEN ("value"), &value);
|
||||
if(ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Option value absent.");
|
||||
@ -1587,7 +1591,7 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -1600,7 +1604,7 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
|
||||
if (!glusterd_is_quota_supported (type, op_errstr)) {
|
||||
ret = -1;
|
||||
@ -1767,7 +1771,8 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo,
|
||||
xlator_t *this = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
glusterd_brickinfo_t *brickinfo = NULL;
|
||||
char key[256] = {0,};
|
||||
char key[64] = {0,};
|
||||
int keylen;
|
||||
char *gfid_str = NULL;
|
||||
uuid_t gfid;
|
||||
|
||||
@ -1776,7 +1781,7 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo,
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = dict_get_str (dict, "path", &path);
|
||||
ret = dict_get_strn (dict, "path", SLEN ("path"), &path);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get path");
|
||||
@ -1818,7 +1823,7 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo,
|
||||
ret = 0;
|
||||
continue;
|
||||
}
|
||||
snprintf (key, sizeof (key), "gfid%d", count);
|
||||
keylen = snprintf (key, sizeof (key), "gfid%d", count);
|
||||
|
||||
gfid_str = gf_strdup (uuid_utoa (gfid));
|
||||
if (!gfid_str) {
|
||||
@ -1826,7 +1831,7 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_dynstr (rsp_dict, key, gfid_str);
|
||||
ret = dict_set_dynstrn (rsp_dict, key, keylen, gfid_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to place "
|
||||
@ -1837,7 +1842,7 @@ glusterd_get_gfid_from_brick (dict_t *dict, glusterd_volinfo_t *volinfo,
|
||||
count++;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "count", count);
|
||||
ret = dict_set_int32n (rsp_dict, "count", SLEN ("count"), count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set count");
|
||||
@ -1886,7 +1891,7 @@ _glusterd_validate_quota_opts (dict_t *dict, int type, char **errstr)
|
||||
GD_MSG_UNKNOWN_KEY, "Unknown option: %s", key);
|
||||
goto out;
|
||||
}
|
||||
ret = dict_get_str (dict, "value", &value);
|
||||
ret = dict_get_strn (dict, "value", SLEN ("value"), &value);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Value not found for key %s",
|
||||
@ -1950,8 +1955,9 @@ glusterd_create_quota_auxiliary_mount (xlator_t *this, char *volname, int type)
|
||||
DEFAULT_LOG_FILE_DIRECTORY, volname);
|
||||
snprintf(qpid, 15, "%d", GF_CLIENT_PID_QUOTA_MOUNT);
|
||||
|
||||
if (dict_get_str (this->options, "transport.socket.bind-address",
|
||||
&volfileserver) != 0)
|
||||
if (dict_get_strn (this->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) != 0)
|
||||
volfileserver = "localhost";
|
||||
|
||||
synclock_unlock (&priv->big_lock);
|
||||
@ -2015,7 +2021,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
GF_ASSERT (dict);
|
||||
GF_ASSERT (op_errstr);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -2041,7 +2047,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
*op_errstr = gf_strdup ("Volume quota failed, internal error, "
|
||||
"unable to get type of operation");
|
||||
@ -2104,7 +2110,8 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
|
||||
switch (type) {
|
||||
case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE:
|
||||
ret = dict_get_str (dict, "hard-limit", &hard_limit_str);
|
||||
ret = dict_get_strn (dict, "hard-limit", SLEN ("hard-limit"),
|
||||
&hard_limit_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
|
@ -132,8 +132,8 @@ glusterd_quotadsvc_start (glusterd_svc_t *svc, int flags)
|
||||
goto out;
|
||||
|
||||
for (i = 0; options[i]; i++) {
|
||||
snprintf (key, sizeof (key), "arg%d", i);
|
||||
ret = dict_set_str (cmdline, key, options[i]);
|
||||
ret = snprintf (key, sizeof (key), "arg%d", i);
|
||||
ret = dict_set_strn (cmdline, key, ret, options[i]);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
@ -261,8 +261,9 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
|
||||
|
||||
snprintf (volname, sizeof(volname), "rebalance/%s", volinfo->volname);
|
||||
|
||||
if (dict_get_str (this->options, "transport.socket.bind-address",
|
||||
&volfileserver) == 0) {
|
||||
if (dict_get_strn (this->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) == 0) {
|
||||
/*In the case of running multiple glusterds on a single machine,
|
||||
*we should ensure that log file and unix socket file should be
|
||||
*unique in given cluster */
|
||||
@ -309,7 +310,8 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
|
||||
runner_argprintf (&runner, logfile);
|
||||
if (volinfo->memory_accounting)
|
||||
runner_add_arg (&runner, "--mem-accounting");
|
||||
if (dict_get_str (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
if (dict_get_strn (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
SLEN (GLUSTERD_LOCALTIME_LOGGING_KEY),
|
||||
&localtime_logging) == 0) {
|
||||
if (strcmp (localtime_logging, "enable") == 0)
|
||||
runner_add_arg (&runner, "--localtime-logging");
|
||||
@ -534,7 +536,7 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Failed to get volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -542,7 +544,8 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), (int32_t*)&cmd);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Failed to get command");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -640,13 +643,14 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "volname not found");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "cmd not found");
|
||||
goto out;
|
||||
@ -660,7 +664,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
switch (cmd) {
|
||||
case GF_DEFRAG_CMD_START_TIER:
|
||||
ret = dict_get_int32 (dict, "force", &is_force);
|
||||
ret = dict_get_int32n (dict, "force", SLEN ("force"),
|
||||
&is_force);
|
||||
if (ret)
|
||||
is_force = 0;
|
||||
|
||||
@ -712,7 +717,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
ret = glusterd_generate_and_set_task_id
|
||||
(op_ctx, GF_REBALANCE_TID_KEY);
|
||||
(op_ctx, GF_REBALANCE_TID_KEY,
|
||||
SLEN (GF_REBALANCE_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_TASKID_GEN_FAIL,
|
||||
@ -720,8 +726,9 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REBALANCE_TID_KEY,
|
||||
SLEN (GF_REBALANCE_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg),
|
||||
"Missing rebalance-id");
|
||||
@ -744,7 +751,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
|
||||
case GF_DEFRAG_CMD_STATUS:
|
||||
case GF_DEFRAG_CMD_STOP:
|
||||
|
||||
ret = dict_get_str (dict, "cmd-str", &cmd_str);
|
||||
ret = dict_get_strn (dict, "cmd-str", SLEN ("cmd-str"),
|
||||
&cmd_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get "
|
||||
@ -840,13 +848,14 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "volname not given");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "command not given");
|
||||
goto out;
|
||||
@ -879,11 +888,13 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
if (GD_OP_REMOVE_BRICK == volinfo->rebal.op)
|
||||
ret = glusterd_copy_uuid_to_dict
|
||||
(volinfo->rebal.rebalance_id, ctx,
|
||||
GF_REMOVE_BRICK_TID_KEY);
|
||||
GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY));
|
||||
else
|
||||
ret = glusterd_copy_uuid_to_dict
|
||||
(volinfo->rebal.rebalance_id, ctx,
|
||||
GF_REBALANCE_TID_KEY);
|
||||
GF_REBALANCE_TID_KEY,
|
||||
SLEN (GF_REBALANCE_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_TASKID_GEN_FAIL,
|
||||
@ -900,7 +911,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
case GF_DEFRAG_CMD_START_TIER:
|
||||
|
||||
|
||||
ret = dict_get_int32 (dict, "force", &is_force);
|
||||
ret = dict_get_int32n (dict, "force", SLEN ("force"),
|
||||
&is_force);
|
||||
if (ret)
|
||||
is_force = 0;
|
||||
if (!is_force) {
|
||||
@ -911,8 +923,9 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
volinfo->rebal.defrag_status =
|
||||
GF_DEFRAG_STATUS_NOT_STARTED;
|
||||
|
||||
ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REBALANCE_TID_KEY,
|
||||
SLEN (GF_REBALANCE_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "Missing rebalance"
|
||||
" id");
|
||||
@ -953,8 +966,9 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
volinfo->rebal.defrag_cmd = cmd;
|
||||
volinfo->rebal.op = GD_OP_REBALANCE;
|
||||
|
||||
ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REBALANCE_TID_KEY,
|
||||
SLEN (GF_REBALANCE_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "Missing rebalance"
|
||||
" id");
|
||||
@ -1051,7 +1065,7 @@ glusterd_defrag_event_notify_handle (dict_t *dict)
|
||||
GF_ASSERT (this);
|
||||
GF_ASSERT (dict);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get volname");
|
||||
|
@ -84,7 +84,7 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Could not get volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -92,7 +92,8 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "operation", &cli_op);
|
||||
ret = dict_get_strn (dict, "operation", SLEN ("operation"),
|
||||
&cli_op);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0,
|
||||
"dict_get on operation failed");
|
||||
@ -113,7 +114,8 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "src-brick", &src_brick);
|
||||
ret = dict_get_strn (dict, "src-brick", SLEN ("src-brick"),
|
||||
&src_brick);
|
||||
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Failed to get src brick");
|
||||
@ -127,7 +129,8 @@ __glusterd_handle_replace_brick (rpcsvc_request_t *req)
|
||||
if (!strcmp (cli_op, "GF_RESET_OP_COMMIT") ||
|
||||
!strcmp (cli_op, "GF_RESET_OP_COMMIT_FORCE") ||
|
||||
!strcmp (cli_op, "GF_REPLACE_OP_COMMIT_FORCE")) {
|
||||
ret = dict_get_str (dict, "dst-brick", &dst_brick);
|
||||
ret = dict_get_strn (dict, "dst-brick", SLEN ("dst-brick"),
|
||||
&dst_brick);
|
||||
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Failed to get"
|
||||
@ -332,7 +335,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "brick_count", 1);
|
||||
ret = dict_set_int32n (rsp_dict, "brick_count",
|
||||
SLEN ("brick_count"), 1);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -394,7 +398,9 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
|
||||
* introduced in gluster-3.6.0
|
||||
*/
|
||||
if (conf->op_version >= GD_OP_VERSION_3_6_0) {
|
||||
ret = dict_get_str (dict, "brick1.mount_dir", &brick_mount_dir);
|
||||
ret = dict_get_strn (dict, "brick1.mount_dir",
|
||||
SLEN ("brick1.mount_dir"),
|
||||
&brick_mount_dir);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_BRICK_MOUNTDIR_GET_FAIL,
|
||||
@ -461,7 +467,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = dict_get_str (dict, "src-brick", &src_brick);
|
||||
ret = dict_get_strn (dict, "src-brick", SLEN ("src-brick"),
|
||||
&src_brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get src brick");
|
||||
@ -470,7 +477,8 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
|
||||
gf_msg_debug (this->name, 0, "src brick=%s", src_brick);
|
||||
|
||||
ret = dict_get_str (dict, "dst-brick", &dst_brick);
|
||||
ret = dict_get_strn (dict, "dst-brick", SLEN ("dst-brick"),
|
||||
&dst_brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get dst brick");
|
||||
@ -479,14 +487,15 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
|
||||
gf_msg_debug (this->name, 0, "dst brick=%s", dst_brick);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "operation", &replace_op);
|
||||
ret = dict_get_strn (dict, "operation", SLEN ("operation"),
|
||||
&replace_op);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0,
|
||||
"dict_get on operation failed");
|
||||
@ -622,7 +631,8 @@ glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (rpcsvc_request_t *req,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (dict, "is_synctasked", _gf_true);
|
||||
ret = dict_set_int32n (dict, "is_synctasked",
|
||||
SLEN ("is_synctasked"), _gf_true);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
|
@ -154,7 +154,8 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
|
||||
volinfo->rep_brick.src_brick = src_brickinfo;
|
||||
volinfo->rep_brick.dst_brick = dst_brickinfo;
|
||||
|
||||
ret = dict_get_int32 (dict, "ignore-partition", &ignore_partition);
|
||||
ret = dict_get_int32n (dict, "ignore-partition",
|
||||
SLEN ("ignore-partition"), &ignore_partition);
|
||||
ret = 0;
|
||||
if (gf_is_local_addr (host)) {
|
||||
ret = glusterd_validate_and_create_brickpath
|
||||
@ -217,7 +218,8 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "brick_count", 1);
|
||||
ret = dict_set_int32n (rsp_dict, "brick_count",
|
||||
SLEN ( "brick_count"), 1);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -254,14 +256,14 @@ glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = dict_get_str (dict, "operation", &op);
|
||||
ret = dict_get_strn (dict, "operation", SLEN ("operation"), &op);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0,
|
||||
"dict_get on operation failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -272,7 +274,8 @@ glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_str (dict, "src-brick", &src_brick);
|
||||
ret = dict_get_strn (dict, "src-brick", SLEN ("src-brick"),
|
||||
&src_brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get src brick");
|
||||
@ -305,7 +308,8 @@ glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
|
||||
|
||||
} else if (!strcmp (op, "GF_RESET_OP_COMMIT") ||
|
||||
!strcmp (op, "GF_RESET_OP_COMMIT_FORCE")) {
|
||||
ret = dict_get_str (dict, "dst-brick", &dst_brick);
|
||||
ret = dict_get_strn (dict, "dst-brick", SLEN ("dst-brick"),
|
||||
&dst_brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
|
@ -63,7 +63,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
||||
case GD_OP_REMOVE_BRICK:
|
||||
{
|
||||
if (ctx)
|
||||
ret = dict_get_str (ctx, "errstr", &errstr);
|
||||
ret = dict_get_strn (ctx, "errstr", SLEN ("errstr"),
|
||||
&errstr);
|
||||
break;
|
||||
}
|
||||
case GD_OP_RESET_VOLUME:
|
||||
@ -79,7 +80,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
||||
case GD_OP_DEFRAG_BRICK_VOLUME:
|
||||
{
|
||||
if (ctx) {
|
||||
ret = dict_get_int32 (ctx, "status", &status);
|
||||
ret = dict_get_int32n (ctx, "status",
|
||||
SLEN ("status"), &status);
|
||||
if (ret) {
|
||||
gf_msg_trace (this->name, 0,
|
||||
"failed to get status");
|
||||
@ -91,8 +93,11 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
||||
case GD_OP_GSYNC_SET:
|
||||
{
|
||||
if (ctx) {
|
||||
ret = dict_get_str (ctx, "errstr", &errstr);
|
||||
ret = dict_set_str (ctx, "glusterd_workdir", conf->workdir);
|
||||
ret = dict_get_strn (ctx, "errstr", SLEN ("errstr"),
|
||||
&errstr);
|
||||
ret = dict_set_strn (ctx, "glusterd_workdir",
|
||||
SLEN ("glusterd_workdir"),
|
||||
conf->workdir);
|
||||
/* swallow error here, that will be re-triggered in cli */
|
||||
|
||||
}
|
||||
@ -101,8 +106,10 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
||||
}
|
||||
case GD_OP_PROFILE_VOLUME:
|
||||
{
|
||||
if (ctx && dict_get_int32 (ctx, "count", &count)) {
|
||||
ret = dict_set_int32 (ctx, "count", 0);
|
||||
if (ctx && dict_get_int32n (ctx, "count", SLEN ("count"),
|
||||
&count)) {
|
||||
ret = dict_set_int32n (ctx, "count", SLEN ("count"),
|
||||
0);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -160,15 +167,18 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
||||
case GD_OP_COPY_FILE:
|
||||
{
|
||||
if (ctx)
|
||||
ret = dict_get_str (ctx, "errstr", &errstr);
|
||||
ret = dict_get_strn (ctx, "errstr", SLEN ("errstr"),
|
||||
&errstr);
|
||||
break;
|
||||
}
|
||||
case GD_OP_SYS_EXEC:
|
||||
{
|
||||
if (ctx) {
|
||||
ret = dict_get_str (ctx, "errstr", &errstr);
|
||||
ret = dict_set_str (ctx, "glusterd_workdir",
|
||||
conf->workdir);
|
||||
ret = dict_get_strn (ctx, "errstr", SLEN ("errstr"),
|
||||
&errstr);
|
||||
ret = dict_set_strn (ctx, "glusterd_workdir",
|
||||
SLEN ("glusterd_workdir"),
|
||||
conf->workdir);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1503,10 +1513,11 @@ glusterd_rpc_probe (call_frame_t *frame, xlator_t *this,
|
||||
priv = this->private;
|
||||
|
||||
GF_ASSERT (priv);
|
||||
ret = dict_get_str (dict, "hostname", &hostname);
|
||||
ret = dict_get_strn (dict, "hostname", SLEN ("hostname"),
|
||||
&hostname);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = dict_get_int32 (dict, "port", &port);
|
||||
ret = dict_get_int32n (dict, "port", SLEN ("port"), &port);
|
||||
if (ret)
|
||||
port = GF_DEFAULT_BASE_PORT;
|
||||
|
||||
@ -1706,7 +1717,7 @@ glusterd_rpc_friend_update (call_frame_t *frame, xlator_t *this,
|
||||
if (ret)
|
||||
goto out;
|
||||
/* Don't want to send the pointer over */
|
||||
dict_del (friends, "peerinfo");
|
||||
dict_deln (friends, "peerinfo", SLEN ("peerinfo"));
|
||||
|
||||
ret = dict_allocate_and_serialize (friends, &req.friends.friends_val,
|
||||
&req.friends.friends_len);
|
||||
@ -1795,7 +1806,7 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this,
|
||||
goto out;
|
||||
|
||||
//peerinfo should not be in payload
|
||||
dict_del (dict, "peerinfo");
|
||||
dict_deln (dict, "peerinfo", SLEN ("peerinfo"));
|
||||
|
||||
glusterd_get_uuid (&req.uuid);
|
||||
|
||||
@ -1875,7 +1886,7 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this,
|
||||
goto out;
|
||||
|
||||
//peerinfo should not be in payload
|
||||
dict_del (dict, "peerinfo");
|
||||
dict_deln (dict, "peerinfo", SLEN ("peerinfo"));
|
||||
|
||||
glusterd_get_uuid (&req.uuid);
|
||||
|
||||
@ -1999,7 +2010,7 @@ glusterd_stage_op (call_frame_t *frame, xlator_t *this,
|
||||
goto out;
|
||||
|
||||
//peerinfo should not be in payload
|
||||
dict_del (dict, "peerinfo");
|
||||
dict_deln (dict, "peerinfo", SLEN ("peerinfo"));
|
||||
|
||||
glusterd_get_uuid (&req.uuid);
|
||||
req.op = glusterd_op_get_op ();
|
||||
@ -2080,7 +2091,7 @@ glusterd_commit_op (call_frame_t *frame, xlator_t *this,
|
||||
goto out;
|
||||
|
||||
//peerinfo should not be in payload
|
||||
dict_del (dict, "peerinfo");
|
||||
dict_deln (dict, "peerinfo", SLEN ("peerinfo"));
|
||||
|
||||
glusterd_get_uuid (&req.uuid);
|
||||
req.op = glusterd_op_get_op ();
|
||||
@ -2212,7 +2223,7 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
if (GD_OP_STATUS_VOLUME == req_ctx->op) {
|
||||
node = frame->cookie;
|
||||
index = node->index;
|
||||
ret = dict_set_int32 (dict, "index", index);
|
||||
ret = dict_set_int32n (dict, "index", SLEN ("index"), index);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
|
@ -129,7 +129,8 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
|
||||
glusterd_peerinfo_t *peerinfo = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
dict_t *friends = NULL;
|
||||
char key[100] = {0,};
|
||||
char key[64] = {0,};
|
||||
int keylen;
|
||||
int32_t count = 0;
|
||||
|
||||
this = THIS;
|
||||
@ -144,17 +145,17 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
|
||||
if (!friends)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32 (friends, key, ctx.op);
|
||||
keylen = snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32n (friends, key, keylen, ctx.op);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "hostname");
|
||||
ret = dict_set_str (friends, key, hostname);
|
||||
keylen = snprintf (key, sizeof (key), "hostname");
|
||||
ret = dict_set_strn (friends, key, keylen, hostname);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_int32 (friends, "count", count);
|
||||
ret = dict_set_int32n (friends, "count", SLEN ("count"), count);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -380,11 +381,13 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
dict = dict_new ();
|
||||
if (!dict)
|
||||
goto out;
|
||||
ret = dict_set_str (dict, "hostname", probe_ctx->hostname);
|
||||
ret = dict_set_strn (dict, "hostname", SLEN ("hostname"),
|
||||
probe_ctx->hostname);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_int32 (dict, "port", probe_ctx->port);
|
||||
ret = dict_set_int32n (dict, "port", SLEN ("port"),
|
||||
probe_ctx->port);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -524,7 +527,8 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
glusterd_friend_update_ctx_t ev_ctx = {{0}};
|
||||
glusterd_conf_t *priv = NULL;
|
||||
dict_t *friends = NULL;
|
||||
char key[100] = {0,};
|
||||
char key[64] = {0,};
|
||||
int keylen;
|
||||
int32_t count = 0;
|
||||
|
||||
GF_ASSERT (event);
|
||||
@ -551,8 +555,8 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
if (!friends)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32 (friends, key, ev_ctx.op);
|
||||
keylen = snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32n (friends, key, keylen, ev_ctx.op);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -568,7 +572,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (friends, "count", count);
|
||||
ret = dict_set_int32n (friends, "count", SLEN ("count"), count);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -618,7 +622,8 @@ glusterd_ac_update_friend (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
glusterd_friend_update_ctx_t ev_ctx = {{0}};
|
||||
glusterd_conf_t *priv = NULL;
|
||||
dict_t *friends = NULL;
|
||||
char key[100] = {0,};
|
||||
char key[64] = {0,};
|
||||
int keylen;
|
||||
int32_t count = 0;
|
||||
|
||||
GF_ASSERT (event);
|
||||
@ -654,8 +659,8 @@ glusterd_ac_update_friend (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
if (!friends)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32 (friends, key, ev_ctx.op);
|
||||
keylen = snprintf (key, sizeof (key), "op");
|
||||
ret = dict_set_int32n (friends, key, keylen, ev_ctx.op);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -671,7 +676,7 @@ glusterd_ac_update_friend (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (friends, "count", count);
|
||||
ret = dict_set_int32n (friends, "count", SLEN ("count"), count);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -1012,8 +1017,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
|
||||
|
||||
new_event->ctx = new_ev_ctx;
|
||||
|
||||
ret = dict_get_str (ev_ctx->vols, "hostname_in_cluster",
|
||||
&hostname);
|
||||
ret = dict_get_strn (ev_ctx->vols, "hostname_in_cluster",
|
||||
SLEN ("hostname_in_cluster"), &hostname);
|
||||
if (ret || !hostname) {
|
||||
gf_msg_debug (this->name, 0,
|
||||
"Unable to fetch local hostname from peer");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -97,8 +97,9 @@ glusterd_svc_init_common (glusterd_svc_t *svc,
|
||||
glusterd_svc_build_volfileid_path (svc_name, volfileid,
|
||||
sizeof(volfileid));
|
||||
|
||||
if (dict_get_str (this->options, "transport.socket.bind-address",
|
||||
&volfileserver) != 0) {
|
||||
if (dict_get_strn (this->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) != 0) {
|
||||
volfileserver = "localhost";
|
||||
}
|
||||
|
||||
@ -199,13 +200,15 @@ glusterd_svc_start (glusterd_svc_t *svc, int flags, dict_t *cmdline)
|
||||
"-S", svc->conn.sockpath,
|
||||
NULL);
|
||||
|
||||
if (dict_get_str (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
&localtime_logging) == 0) {
|
||||
if (dict_get_strn (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
SLEN (GLUSTERD_LOCALTIME_LOGGING_KEY),
|
||||
&localtime_logging) == 0) {
|
||||
if (strcmp (localtime_logging, "enable") == 0)
|
||||
runner_add_arg (&runner, "--localtime-logging");
|
||||
}
|
||||
if (dict_get_str (priv->opts, GLUSTERD_DAEMON_LOG_LEVEL_KEY,
|
||||
&log_level) == 0) {
|
||||
if (dict_get_strn (priv->opts, GLUSTERD_DAEMON_LOG_LEVEL_KEY,
|
||||
SLEN (GLUSTERD_DAEMON_LOG_LEVEL_KEY),
|
||||
&log_level) == 0) {
|
||||
snprintf (daemon_log_level, 30, "--log-level=%s", log_level);
|
||||
runner_add_arg (&runner, daemon_log_level);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Unable to get volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
@ -95,7 +95,8 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Unable to get the command");
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
@ -119,8 +120,9 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
GD_OP_VERSION_3_7_5);
|
||||
switch (cmd) {
|
||||
case GF_DEFRAG_CMD_DETACH_STOP:
|
||||
ret = dict_set_int32 (dict, "rebalance-command",
|
||||
GF_DEFRAG_CMD_STOP_DETACH_TIER);
|
||||
ret = dict_set_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"),
|
||||
GF_DEFRAG_CMD_STOP_DETACH_TIER);
|
||||
break;
|
||||
|
||||
case GF_DEFRAG_CMD_DETACH_COMMIT:
|
||||
@ -133,8 +135,9 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
ret = glusterd_set_detach_bricks (dict, volinfo);
|
||||
ret = dict_set_int32 (dict, "command",
|
||||
GF_OP_CMD_DETACH_COMMIT);
|
||||
ret = dict_set_int32n (dict, "command",
|
||||
SLEN ("command"),
|
||||
GF_OP_CMD_DETACH_COMMIT);
|
||||
break;
|
||||
case GF_DEFRAG_CMD_DETACH_COMMIT_FORCE:
|
||||
ret = glusterd_volinfo_find (volname, &volinfo);
|
||||
@ -146,8 +149,9 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
ret = glusterd_set_detach_bricks (dict, volinfo);
|
||||
ret = dict_set_int32 (dict, "command",
|
||||
GF_OP_CMD_DETACH_COMMIT_FORCE);
|
||||
ret = dict_set_int32n (dict, "command",
|
||||
SLEN ("command"),
|
||||
GF_OP_CMD_DETACH_COMMIT_FORCE);
|
||||
break;
|
||||
case GF_DEFRAG_CMD_DETACH_START:
|
||||
ret = glusterd_volinfo_find (volname, &volinfo);
|
||||
@ -159,8 +163,9 @@ __glusterd_handle_tier (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
ret = glusterd_set_detach_bricks (dict, volinfo);
|
||||
ret = dict_set_int32 (dict, "command",
|
||||
GF_OP_CMD_DETACH_START);
|
||||
ret = dict_set_int32n (dict, "command",
|
||||
SLEN ("command"),
|
||||
GF_OP_CMD_DETACH_START);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -256,6 +261,7 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
int32_t count = 0;
|
||||
int32_t i = 1;
|
||||
char key[256] = {0,};
|
||||
int keylen;
|
||||
int32_t flag = 0;
|
||||
char err_str[4096] = {0,};
|
||||
int need_rebalance = 0;
|
||||
@ -283,7 +289,7 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -297,7 +303,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
|
||||
"cmd not found");
|
||||
@ -309,7 +316,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) {
|
||||
ret = glusterd_copy_uuid_to_dict
|
||||
(volinfo->rebal.rebalance_id, dict,
|
||||
GF_REMOVE_BRICK_TID_KEY);
|
||||
GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_REMOVE_BRICK_ID_SET_FAIL,
|
||||
@ -394,16 +402,18 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
"detach start", volname);
|
||||
goto out;
|
||||
}
|
||||
ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, errno,
|
||||
"Missing remove-brick-id");
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = dict_set_str (rsp_dict,
|
||||
GF_REMOVE_BRICK_TID_KEY,
|
||||
task_id_str);
|
||||
ret = dict_set_strn (rsp_dict,
|
||||
GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY),
|
||||
task_id_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_WARNING, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -453,8 +463,10 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
* Revisit this code when this constraint no
|
||||
* longer exist.
|
||||
*/
|
||||
dict_del (volinfo->dict, "features.ctr-enabled");
|
||||
dict_del (volinfo->dict, "cluster.tier-mode");
|
||||
dict_deln (volinfo->dict, "features.ctr-enabled",
|
||||
SLEN ("features.ctr-enabled"));
|
||||
dict_deln (volinfo->dict, "cluster.tier-mode",
|
||||
SLEN ("cluster.tier-mode"));
|
||||
|
||||
hot_shd_key = gd_get_shd_key
|
||||
(volinfo->tier_info.hot_type);
|
||||
@ -517,7 +529,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
ret = dict_set_int32 (bricks_dict, "count", count);
|
||||
ret = dict_set_int32n (bricks_dict, "count", SLEN ("count"),
|
||||
count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -527,8 +540,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
}
|
||||
|
||||
while (i <= count) {
|
||||
snprintf (key, 256, "brick%d", i);
|
||||
ret = dict_get_str (dict, key, &brick);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d", i);
|
||||
ret = dict_get_strn (dict, key, keylen, &brick);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get %s",
|
||||
@ -545,7 +558,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
"Failed to duplicate brick name");
|
||||
goto out;
|
||||
}
|
||||
ret = dict_set_dynstr (bricks_dict, key, brick_tmpstr);
|
||||
ret = dict_set_dynstrn (bricks_dict, key,
|
||||
keylen, brick_tmpstr);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -571,7 +585,8 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
if (cmd == GF_DEFRAG_CMD_DETACH_START)
|
||||
volinfo->tier.dict = dict_ref (bricks_dict);
|
||||
|
||||
ret = dict_get_int32 (dict, "replica-count", &replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count", SLEN ("replica-count"),
|
||||
&replica_count);
|
||||
if (!ret) {
|
||||
gf_msg (this->name, GF_LOG_INFO, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -701,7 +716,7 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -714,7 +729,8 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get cmd from "
|
||||
@ -747,12 +763,14 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
/* we check if its running and skip so that we don't get a
|
||||
* failure during force start
|
||||
*/
|
||||
ret = dict_get_int32 (dict, "force", &is_force);
|
||||
ret = dict_get_int32n (dict, "force", SLEN ("force"),
|
||||
&is_force);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, 0, "Unable to get is_force"
|
||||
" from dict");
|
||||
}
|
||||
ret = dict_set_int32 (volinfo->dict, "force", is_force);
|
||||
ret = dict_set_int32n (volinfo->dict, "force", SLEN ("force"),
|
||||
is_force);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, errno, "Unable to set"
|
||||
" is_force to dict");
|
||||
@ -828,14 +846,15 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
priv = this->private;
|
||||
GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
|
||||
"volname not found");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "rebalance-command", &cmd);
|
||||
ret = dict_get_int32n (dict, "rebalance-command",
|
||||
SLEN ("rebalance-command"), &cmd);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
|
||||
"cmd not found");
|
||||
@ -893,7 +912,8 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
|
||||
switch (cmd) {
|
||||
case GF_DEFRAG_CMD_START_TIER:
|
||||
ret = dict_get_int32 (dict, "force", &is_force);
|
||||
ret = dict_get_int32n (dict, "force", SLEN ("force"),
|
||||
&is_force);
|
||||
if (ret)
|
||||
is_force = 0;
|
||||
|
||||
@ -950,7 +970,8 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
case GF_DEFRAG_CMD_DETACH_START:
|
||||
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"),
|
||||
&brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -996,7 +1017,8 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
|
||||
if (is_origin_glusterd (dict)) {
|
||||
ret = glusterd_generate_and_set_task_id
|
||||
(dict, GF_REMOVE_BRICK_TID_KEY);
|
||||
(dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_TASKID_GEN_FAIL,
|
||||
@ -1004,8 +1026,9 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
&task_id_str);
|
||||
ret = dict_get_strn (dict, GF_REMOVE_BRICK_TID_KEY,
|
||||
SLEN (GF_REMOVE_BRICK_TID_KEY),
|
||||
&task_id_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_WARNING, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1055,7 +1078,8 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"),
|
||||
&brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, errno,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1112,8 +1136,8 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo,
|
||||
int ret = -1;
|
||||
int32_t pid = -1;
|
||||
int32_t brick_online = -1;
|
||||
char key[1024] = {0};
|
||||
char base_key[32] = {0};
|
||||
char key[64] = {0};
|
||||
int keylen;
|
||||
char pidfile[PATH_MAX] = {0};
|
||||
xlator_t *this = NULL;
|
||||
|
||||
@ -1123,14 +1147,15 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo,
|
||||
GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
|
||||
GF_VALIDATE_OR_GOTO (this->name, dict, out);
|
||||
|
||||
snprintf (base_key, sizeof (base_key), "brick%d", count);
|
||||
snprintf (key, sizeof (key), "%s.hostname", base_key);
|
||||
ret = dict_set_str (dict, key, "Tier Daemon");
|
||||
keylen = snprintf (key, sizeof (key), "brick%d.hostname", count);
|
||||
ret = dict_set_nstrn (dict, key, keylen,
|
||||
"Tier Daemon", SLEN ("Tier Daemon"));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "%s.path", base_key);
|
||||
ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (MY_UUID)));
|
||||
keylen = snprintf (key, sizeof (key), "brick%d.path", count);
|
||||
ret = dict_set_dynstrn (dict, key, keylen,
|
||||
gf_strdup (uuid_utoa (MY_UUID)));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -1138,8 +1163,8 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo,
|
||||
* an zero value to parse.
|
||||
* */
|
||||
|
||||
snprintf (key, sizeof (key), "%s.port", base_key);
|
||||
ret = dict_set_int32 (dict, key, 0);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d.port", count);
|
||||
ret = dict_set_int32n (dict, key, keylen, 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -1147,13 +1172,13 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo,
|
||||
|
||||
brick_online = gf_is_service_running (pidfile, &pid);
|
||||
|
||||
snprintf (key, sizeof (key), "%s.pid", base_key);
|
||||
ret = dict_set_int32 (dict, key, pid);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d.pid", count);
|
||||
ret = dict_set_int32n (dict, key, keylen, pid);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (key, sizeof (key), "%s.status", base_key);
|
||||
ret = dict_set_int32 (dict, key, brick_online);
|
||||
keylen = snprintf (key, sizeof (key), "brick%d.status", count);
|
||||
ret = dict_set_int32n (dict, key, keylen, brick_online);
|
||||
|
||||
out:
|
||||
if (ret)
|
||||
|
@ -106,8 +106,9 @@ glusterd_tierdsvc_init (void *data)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dict_get_str (this->options, "transport.socket.bind-address",
|
||||
&volfileserver) != 0) {
|
||||
if (dict_get_strn (this->options, "transport.socket.bind-address",
|
||||
SLEN ("transport.socket.bind-address"),
|
||||
&volfileserver) != 0) {
|
||||
volfileserver = "localhost";
|
||||
}
|
||||
ret = glusterd_proc_init (&(svc->proc), tierd_svc_name, pidfile, logdir,
|
||||
@ -178,7 +179,8 @@ glusterd_tierdsvc_manager (glusterd_svc_t *svc, void *data, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (volinfo->dict, "force", &is_force);
|
||||
ret = dict_get_int32n (volinfo->dict, "force", SLEN ("force"),
|
||||
&is_force);
|
||||
if (ret) {
|
||||
gf_msg_debug (this->name, errno, "Unable to get"
|
||||
" is_force from dict");
|
||||
@ -362,8 +364,9 @@ glusterd_tierdsvc_start (glusterd_svc_t *svc, int flags)
|
||||
volinfo->rebal.commit_hash);
|
||||
if (volinfo->memory_accounting)
|
||||
runner_add_arg (&runner, "--mem-accounting");
|
||||
if (dict_get_str (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
&localtime_logging) == 0) {
|
||||
if (dict_get_strn (priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY,
|
||||
SLEN (GLUSTERD_LOCALTIME_LOGGING_KEY),
|
||||
&localtime_logging) == 0) {
|
||||
if (strcmp (localtime_logging, "enable") == 0)
|
||||
runner_add_arg (&runner, "--localtime-logging");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -566,14 +566,15 @@ int
|
||||
glusterd_get_next_global_opt_version_str (dict_t *opts, char **version_str);
|
||||
|
||||
int
|
||||
glusterd_generate_and_set_task_id (dict_t *dict, char *key);
|
||||
glusterd_generate_and_set_task_id (dict_t *dict, char *key, const int keylen);
|
||||
|
||||
int
|
||||
glusterd_validate_and_set_gfid (dict_t *op_ctx, dict_t *req_dict,
|
||||
char **op_errstr);
|
||||
|
||||
int
|
||||
glusterd_copy_uuid_to_dict (uuid_t uuid, dict_t *dict, char *key);
|
||||
glusterd_copy_uuid_to_dict (uuid_t uuid, dict_t *dict, char *key,
|
||||
const int keylen);
|
||||
|
||||
gf_boolean_t
|
||||
glusterd_is_same_address (char *name1, char *name2);
|
||||
|
@ -114,7 +114,7 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
ai_list->info = NULL;
|
||||
CDS_INIT_LIST_HEAD (&ai_list->list);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -122,7 +122,7 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
snprintf (err_str, 512, "Unable to get type of volume %s",
|
||||
volname);
|
||||
@ -132,7 +132,7 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &brick_list);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &brick_list);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Bricks check : Could not "
|
||||
@ -140,7 +140,7 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Bricks check : Could not "
|
||||
@ -149,7 +149,8 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
}
|
||||
|
||||
if (type != GF_CLUSTER_TYPE_DISPERSE) {
|
||||
ret = dict_get_int32 (dict, "replica-count", &sub_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"), &sub_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Bricks check : Could"
|
||||
@ -159,7 +160,8 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
|
||||
gf_msg_debug (this->name, 0, "Replicate cluster type "
|
||||
"found. Checking brick order.");
|
||||
} else {
|
||||
ret = dict_get_int32 (dict, "disperse-count", &sub_count);
|
||||
ret = dict_get_int32n (dict, "disperse-count",
|
||||
SLEN ("disperse-count"), &sub_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Bricks check : Could"
|
||||
@ -337,7 +339,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get volume "
|
||||
@ -355,7 +357,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get brick count"
|
||||
" for volume %s", volname);
|
||||
@ -364,7 +366,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get type of "
|
||||
"volume %s", volname);
|
||||
@ -375,7 +377,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
|
||||
|
||||
|
||||
ret = dict_get_str (dict, "transport", &trans_type);
|
||||
ret = dict_get_strn (dict, "transport", SLEN ("transport"),
|
||||
&trans_type);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get "
|
||||
"transport-type of volume %s", volname);
|
||||
@ -384,8 +387,9 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (this->options, "transport.address-family",
|
||||
&address_family_str);
|
||||
ret = dict_get_strn (this->options, "transport.address-family",
|
||||
SLEN ("transport.address-family"),
|
||||
&address_family_str);
|
||||
|
||||
if (!ret) {
|
||||
ret = dict_set_dynstr_with_alloc (dict,
|
||||
@ -413,7 +417,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get bricks for "
|
||||
"volume %s", volname);
|
||||
@ -422,7 +426,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!dict_get (dict, "force")) {
|
||||
if (!dict_getn (dict, "force", SLEN ("force"))) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get 'force' flag");
|
||||
goto out;
|
||||
@ -430,7 +434,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
|
||||
gf_uuid_generate (volume_id);
|
||||
free_ptr = gf_strdup (uuid_utoa (volume_id));
|
||||
ret = dict_set_dynstr (dict, "volume-id", free_ptr);
|
||||
ret = dict_set_dynstrn (dict, "volume-id", SLEN ("volume-id"),
|
||||
free_ptr);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to set volume "
|
||||
"id of volume %s", volname);
|
||||
@ -444,7 +449,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
|
||||
gf_uuid_generate (tmp_uuid);
|
||||
username = gf_strdup (uuid_utoa (tmp_uuid));
|
||||
ret = dict_set_dynstr (dict, "internal-username", username);
|
||||
ret = dict_set_dynstrn (dict, "internal-username",
|
||||
SLEN ("internal-username"), username);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set username for "
|
||||
@ -454,7 +460,8 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
|
||||
|
||||
gf_uuid_generate (tmp_uuid);
|
||||
password = gf_strdup (uuid_utoa (tmp_uuid));
|
||||
ret = dict_set_dynstr (dict, "internal-password", password);
|
||||
ret = dict_set_dynstrn (dict, "internal-password",
|
||||
SLEN ("internal-password"), password);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set password for "
|
||||
@ -536,7 +543,7 @@ __glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (errstr, sizeof (errstr), "Unable to get volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -624,7 +631,7 @@ __glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &dup_volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &dup_volname);
|
||||
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Failed to get volume "
|
||||
@ -715,7 +722,7 @@ __glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Failed to get volume "
|
||||
"name");
|
||||
@ -754,19 +761,22 @@ glusterd_handle_shd_option_for_tier (glusterd_volinfo_t *volinfo,
|
||||
char *value, dict_t *dict)
|
||||
{
|
||||
int count = 0;
|
||||
char dict_key[1024] = {0, };
|
||||
char dict_key[64] = {0, };
|
||||
int keylen;
|
||||
char *key = NULL;
|
||||
int ret = 0;
|
||||
|
||||
key = gd_get_shd_key (volinfo->tier_info.cold_type);
|
||||
if (key) {
|
||||
count++;
|
||||
snprintf (dict_key, sizeof (dict_key), "key%d", count);
|
||||
ret = dict_set_str (dict, dict_key, key);
|
||||
keylen = snprintf (dict_key, sizeof (dict_key), "key%d",
|
||||
count);
|
||||
ret = dict_set_strn (dict, dict_key, keylen, key);
|
||||
if (ret)
|
||||
goto out;
|
||||
snprintf (dict_key, sizeof (dict_key), "value%d", count);
|
||||
ret = dict_set_str (dict, dict_key, value);
|
||||
keylen = snprintf (dict_key, sizeof (dict_key), "value%d",
|
||||
count);
|
||||
ret = dict_set_strn (dict, dict_key, keylen, value);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
@ -774,17 +784,19 @@ glusterd_handle_shd_option_for_tier (glusterd_volinfo_t *volinfo,
|
||||
key = gd_get_shd_key (volinfo->tier_info.hot_type);
|
||||
if (key) {
|
||||
count++;
|
||||
snprintf (dict_key, sizeof (dict_key), "key%d", count);
|
||||
ret = dict_set_str (dict, dict_key, key);
|
||||
keylen = snprintf (dict_key, sizeof (dict_key), "key%d",
|
||||
count);
|
||||
ret = dict_set_strn (dict, dict_key, keylen, key);
|
||||
if (ret)
|
||||
goto out;
|
||||
snprintf (dict_key, sizeof (dict_key), "value%d", count);
|
||||
ret = dict_set_str (dict, dict_key, value);
|
||||
keylen = snprintf (dict_key, sizeof (dict_key), "value%d",
|
||||
count);
|
||||
ret = dict_set_strn (dict, dict_key, keylen, value);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (dict, "count", count);
|
||||
ret = dict_set_int32n (dict, "count", SLEN ("count"), count);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -801,7 +813,8 @@ glusterd_handle_heal_options_enable_disable (rpcsvc_request_t *req,
|
||||
char *key = NULL;
|
||||
char *value = NULL;
|
||||
|
||||
ret = dict_get_int32 (dict, "heal-op", (int32_t *)&heal_op);
|
||||
ret = dict_get_int32n (dict, "heal-op", SLEN ("heal-op"),
|
||||
(int32_t *)&heal_op);
|
||||
if (ret || (heal_op == GF_SHD_OP_INVALID)) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
@ -862,15 +875,15 @@ glusterd_handle_heal_options_enable_disable (rpcsvc_request_t *req,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_set_str (dict, "key1", key);
|
||||
ret = dict_set_strn (dict, "key1", SLEN ("key1"), key);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_str (dict, "value1", value);
|
||||
ret = dict_set_strn (dict, "value1", SLEN ("value1"), value);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_int32 (dict, "count", 1);
|
||||
ret = dict_set_int32n (dict, "count", SLEN ("count"), 1);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -925,7 +938,7 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (op_errstr, sizeof (op_errstr), "Unable to find "
|
||||
"volume name");
|
||||
@ -964,7 +977,8 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_set_int32 (dict, "count", volinfo->brick_count);
|
||||
ret = dict_set_int32n (dict, "count", SLEN ("count"),
|
||||
volinfo->brick_count);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -1035,16 +1049,16 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get the volume "
|
||||
"name");
|
||||
snprintf (err_str, sizeof (err_str),
|
||||
"Unable to get the volume name");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "%s", err_str);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "options", &options);
|
||||
ret = dict_get_strn (dict, "options", SLEN ("options"), &options);
|
||||
if (ret) {
|
||||
snprintf (err_str, sizeof (err_str), "Unable to get options");
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -1052,7 +1066,8 @@ __glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "option_cnt", &option_cnt);
|
||||
ret = dict_get_int32n (dict, "option_cnt", SLEN ("option_cnt"),
|
||||
&option_cnt);
|
||||
if (ret) {
|
||||
snprintf (err_str , sizeof (err_str), "Unable to get option "
|
||||
"count");
|
||||
@ -1204,7 +1219,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
char *bricks = NULL;
|
||||
char *brick_list = NULL;
|
||||
char *free_ptr = NULL;
|
||||
char key[PATH_MAX] = "";
|
||||
char key[64] = "";
|
||||
glusterd_brickinfo_t *brick_info = NULL;
|
||||
int32_t brick_count = 0;
|
||||
int32_t local_brick_count = 0;
|
||||
@ -1225,7 +1240,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
GF_ASSERT (priv);
|
||||
GF_ASSERT (rsp_dict);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -1242,7 +1257,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"), &brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get brick count "
|
||||
@ -1250,7 +1265,8 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volume-id", &volume_uuid_str);
|
||||
ret = dict_get_strn (dict, "volume-id", SLEN ("volume-id"),
|
||||
&volume_uuid_str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume id of "
|
||||
@ -1267,7 +1283,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -1378,7 +1394,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
* force at the end of command not given then check brick order.
|
||||
*/
|
||||
if (is_origin_glusterd (dict)) {
|
||||
ret = dict_get_int32 (dict, "type", &type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof (msg), "Unable to get type of "
|
||||
"volume %s", volname);
|
||||
@ -1395,15 +1411,16 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
||||
if (ret) {
|
||||
gf_msg(this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_BAD_BRKORDER, "Not "
|
||||
"creating volume because of bad "
|
||||
"brick order");
|
||||
"creating volume because of "
|
||||
"bad brick order");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "brick_count", local_brick_count);
|
||||
ret = dict_set_int32n (rsp_dict, "brick_count", SLEN ("brick_count"),
|
||||
local_brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -1437,14 +1454,14 @@ glusterd_op_stop_volume_args_get (dict_t *dict, char** volname, int *flags)
|
||||
if (!dict || !volname || !flags)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_str (dict, "volname", volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "flags", flags);
|
||||
ret = dict_get_int32n (dict, "flags", SLEN ("flags"), flags);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get flags");
|
||||
@ -1463,21 +1480,22 @@ glusterd_op_statedump_volume_args_get (dict_t *dict, char **volname,
|
||||
if (!dict || !volname || !options || !option_cnt)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_str (dict, "volname", volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volname");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "options", options);
|
||||
ret = dict_get_strn (dict, "options", SLEN ("options"), options);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get options");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "option_cnt", option_cnt);
|
||||
ret = dict_get_int32n (dict, "option_cnt", SLEN ("option_cnt"),
|
||||
option_cnt);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get option count");
|
||||
@ -1494,7 +1512,7 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr,
|
||||
{
|
||||
int ret = 0;
|
||||
char *volname = NULL;
|
||||
char key[PATH_MAX] = "";
|
||||
char key[64] = "";
|
||||
int flags = 0;
|
||||
int32_t brick_count = 0;
|
||||
int32_t local_brick_count = 0;
|
||||
@ -1688,7 +1706,8 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr,
|
||||
#endif
|
||||
}
|
||||
|
||||
ret = dict_set_int32 (rsp_dict, "brick_count", local_brick_count);
|
||||
ret = dict_set_int32n (rsp_dict, "brick_count", SLEN ("brick_count"),
|
||||
local_brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED,
|
||||
@ -1802,7 +1821,7 @@ glusterd_op_stage_delete_volume (dict_t *dict, char **op_errstr)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -1878,7 +1897,8 @@ glusterd_handle_heal_cmd (xlator_t *this, glusterd_volinfo_t *volinfo,
|
||||
"Check self-heal daemon log file.";
|
||||
|
||||
priv = this->private;
|
||||
ret = dict_get_int32 (dict, "heal-op", (int32_t*)&heal_op);
|
||||
ret = dict_get_int32n (dict, "heal-op", SLEN ("heal-op"),
|
||||
(int32_t*)&heal_op);
|
||||
if (ret) {
|
||||
ret = -1;
|
||||
*op_errstr = gf_strdup("Heal operation not specified");
|
||||
@ -1976,7 +1996,7 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -2109,7 +2129,7 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr)
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
char msg[2048] = {0,};
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof(msg), "Failed to get volume name");
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
@ -2118,7 +2138,7 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "path", &path);
|
||||
ret = dict_get_strn (dict, "path", SLEN ("path"), &path);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof(msg), "Failed to get path");
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
@ -2127,7 +2147,7 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "kind", &kind);
|
||||
ret = dict_get_strn (dict, "kind", SLEN ("kind"), &kind);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof(msg), "Failed to get kind");
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
@ -2136,7 +2156,7 @@ glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "type", &type);
|
||||
ret = dict_get_strn (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
snprintf (msg, sizeof(msg), "Failed to get type");
|
||||
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
||||
@ -2218,7 +2238,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -2234,7 +2254,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
|
||||
GF_ASSERT (volinfo->volname);
|
||||
|
||||
ret = dict_get_int32 (dict, "type", &volinfo->type);
|
||||
ret = dict_get_int32n (dict, "type", SLEN ("type"), &volinfo->type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get type of volume"
|
||||
@ -2242,7 +2262,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "count", &volinfo->brick_count);
|
||||
ret = dict_get_int32n (dict, "count", SLEN ("count"),
|
||||
&volinfo->brick_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get brick count of"
|
||||
@ -2250,14 +2271,14 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_int32 (dict, "port", &volinfo->port);
|
||||
ret = dict_get_int32n (dict, "port", SLEN ("port"), &volinfo->port);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get port");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "bricks", &bricks);
|
||||
ret = dict_get_strn (dict, "bricks", SLEN ("bricks"), &bricks);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get bricks for "
|
||||
@ -2278,9 +2299,10 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
* replicate volumes
|
||||
*/
|
||||
if (priv->op_version >= GD_OP_VERSION_3_12_2) {
|
||||
ret = dict_set_str (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
"off");
|
||||
ret = dict_set_nstrn (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
SLEN ("performance.client-io-threads"),
|
||||
"off", SLEN ("off"));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set "
|
||||
@ -2288,8 +2310,9 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ret = dict_get_int32 (dict, "replica-count",
|
||||
&volinfo->replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"),
|
||||
&volinfo->replica_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get "
|
||||
@ -2298,11 +2321,13 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
/* coverity[unused_value] arbiter count is optional */
|
||||
ret = dict_get_int32 (dict, "arbiter-count",
|
||||
&volinfo->arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count",
|
||||
SLEN ("arbiter-count"),
|
||||
&volinfo->arbiter_count);
|
||||
} else if (GF_CLUSTER_TYPE_STRIPE == volinfo->type) {
|
||||
ret = dict_get_int32 (dict, "stripe-count",
|
||||
&volinfo->stripe_count);
|
||||
ret = dict_get_int32n (dict, "stripe-count",
|
||||
SLEN ("stripe-count"),
|
||||
&volinfo->stripe_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get stripe"
|
||||
@ -2317,9 +2342,10 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
* replicate volumes
|
||||
*/
|
||||
if (priv->op_version >= GD_OP_VERSION_3_12_2) {
|
||||
ret = dict_set_str (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
"off");
|
||||
ret = dict_set_nstrn (volinfo->dict,
|
||||
"performance.client-io-threads",
|
||||
SLEN ("performance.client-io-threads"),
|
||||
"off", SLEN ("off"));
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_SET_FAILED, "Failed to set "
|
||||
@ -2327,16 +2353,18 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ret = dict_get_int32 (dict, "stripe-count",
|
||||
&volinfo->stripe_count);
|
||||
ret = dict_get_int32n (dict, "stripe-count",
|
||||
SLEN ("stripe-count"),
|
||||
&volinfo->stripe_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get stripe"
|
||||
" count for volume %s", volname);
|
||||
goto out;
|
||||
}
|
||||
ret = dict_get_int32 (dict, "replica-count",
|
||||
&volinfo->replica_count);
|
||||
ret = dict_get_int32n (dict, "replica-count",
|
||||
SLEN ("replica-count"),
|
||||
&volinfo->replica_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get "
|
||||
@ -2345,19 +2373,22 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
|
||||
/* coverity[unused_value] arbiter count is optional */
|
||||
ret = dict_get_int32 (dict, "arbiter-count",
|
||||
&volinfo->arbiter_count);
|
||||
ret = dict_get_int32n (dict, "arbiter-count",
|
||||
SLEN ("arbiter-count"),
|
||||
&volinfo->arbiter_count);
|
||||
} else if (GF_CLUSTER_TYPE_DISPERSE == volinfo->type) {
|
||||
ret = dict_get_int32 (dict, "disperse-count",
|
||||
&volinfo->disperse_count);
|
||||
ret = dict_get_int32n (dict, "disperse-count",
|
||||
SLEN ("disperse-count"),
|
||||
&volinfo->disperse_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get "
|
||||
"disperse count for volume %s", volname);
|
||||
goto out;
|
||||
}
|
||||
ret = dict_get_int32 (dict, "redundancy-count",
|
||||
&volinfo->redundancy_count);
|
||||
ret = dict_get_int32n (dict, "redundancy-count",
|
||||
SLEN ("redundancy-count"),
|
||||
&volinfo->redundancy_count);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get "
|
||||
@ -2387,7 +2418,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
if (volinfo->dist_leaf_count > 1)
|
||||
volinfo->sub_count = volinfo->dist_leaf_count;
|
||||
|
||||
ret = dict_get_str (dict, "transport", &trans_type);
|
||||
ret = dict_get_strn (dict, "transport", SLEN ("transport"),
|
||||
&trans_type);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2395,7 +2427,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "volume-id", &str);
|
||||
ret = dict_get_strn (dict, "volume-id", SLEN ("volume-id"), &str);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2410,7 +2442,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "internal-username", &username);
|
||||
ret = dict_get_strn (dict, "internal-username",
|
||||
SLEN ("internal-username"), &username);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2420,7 +2453,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
}
|
||||
glusterd_auth_set_username (volinfo, username);
|
||||
|
||||
ret = dict_get_str (dict, "internal-password", &password);
|
||||
ret = dict_get_strn (dict, "internal-password",
|
||||
SLEN ("internal-password"), &password);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2474,8 +2508,10 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
*/
|
||||
if (priv->op_version >= GD_OP_VERSION_3_6_0) {
|
||||
brick_mount_dir = NULL;
|
||||
snprintf (key, sizeof(key), "brick%d.mount_dir", i);
|
||||
ret = dict_get_str (dict, key, &brick_mount_dir);
|
||||
ret = snprintf (key, sizeof(key),
|
||||
"brick%d.mount_dir", i);
|
||||
ret = dict_get_strn (dict, key, ret,
|
||||
&brick_mount_dir);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED,
|
||||
@ -2530,8 +2566,9 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "transport.address-family",
|
||||
&address_family_str);
|
||||
ret = dict_get_strn (dict, "transport.address-family",
|
||||
SLEN ("transport.address-family"),
|
||||
&address_family_str);
|
||||
|
||||
if (!ret) {
|
||||
ret = dict_set_dynstr_with_alloc(volinfo->dict,
|
||||
@ -2644,7 +2681,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)
|
||||
int ret = 0;
|
||||
int32_t brick_count = 0;
|
||||
char *brick_mount_dir = NULL;
|
||||
char key[PATH_MAX] = "";
|
||||
char key[64] = "";
|
||||
char *volname = NULL;
|
||||
int flags = 0;
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
@ -2692,9 +2729,10 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)
|
||||
continue;
|
||||
if (strlen(brickinfo->mount_dir) < 1) {
|
||||
brick_mount_dir = NULL;
|
||||
snprintf (key, sizeof(key), "brick%d.mount_dir",
|
||||
brick_count);
|
||||
ret = dict_get_str (dict, key,
|
||||
ret = snprintf (key, sizeof (key),
|
||||
"brick%d.mount_dir",
|
||||
brick_count);
|
||||
ret = dict_get_strn (dict, key, ret,
|
||||
&brick_mount_dir);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
@ -2867,7 +2905,7 @@ glusterd_op_delete_volume (dict_t *dict)
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (this->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
|
||||
@ -3175,7 +3213,7 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
char **xl_opts = NULL;
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
|
||||
ret = dict_get_str (dict, "volname", &volname);
|
||||
ret = dict_get_strn (dict, "volname", SLEN ("volname"), &volname);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get volume name");
|
||||
@ -3183,28 +3221,28 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
}
|
||||
gf_msg_debug ("glusterd", 0, "Performing clearlocks on volume %s", volname);
|
||||
|
||||
ret = dict_get_str (dict, "path", &path);
|
||||
ret = dict_get_strn (dict, "path", SLEN ("path"), &path);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get path");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "kind", &kind);
|
||||
ret = dict_get_strn (dict, "kind", SLEN ("kind"), &kind);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get kind");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "type", &type);
|
||||
ret = dict_get_strn (dict, "type", SLEN ("type"), &type);
|
||||
if (ret) {
|
||||
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
||||
GD_MSG_DICT_GET_FAILED, "Failed to get type");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_str (dict, "opts", &opts);
|
||||
ret = dict_get_strn (dict, "opts", SLEN ("opts"), &opts);
|
||||
if (ret)
|
||||
ret = 0;
|
||||
|
||||
@ -3273,7 +3311,8 @@ glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
||||
}
|
||||
|
||||
free_ptr = gf_strdup(result);
|
||||
if (dict_set_dynstr (rsp_dict, "lk-summary", free_ptr)) {
|
||||
if (dict_set_dynstrn (rsp_dict, "lk-summary", SLEN ("lk-summary"),
|
||||
free_ptr)) {
|
||||
GF_FREE (free_ptr);
|
||||
snprintf (msg, sizeof (msg), "Failed to set clear-locks "
|
||||
"result");
|
||||
|
Loading…
x
Reference in New Issue
Block a user