diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2018-09-03 13:55:01 +0300 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-09-09 01:53:59 +0000 |
commit | 09198e203ece6925791a8a3a6121c5f808e4e873 (patch) | |
tree | 152f83348592c21fa697aeb0fc606e824ab7c993 /xlators/mgmt/glusterd/src/glusterd-replace-brick.c | |
parent | 44e4db05a953a6f231c62225b462470cacb16bd4 (diff) |
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>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-replace-brick.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c index c3c7d7230d7..f2d59b593f1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c @@ -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, |