diff options
-rw-r--r-- | libglusterfs/src/dict.c | 2 | ||||
-rw-r--r-- | libglusterfs/src/mem-types.h | 150 | ||||
-rw-r--r-- | libglusterfs/src/scheduler.c | 16 | ||||
-rw-r--r-- | libglusterfs/src/timer.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 9 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 1 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 49 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 7 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mem-types.h | 70 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 69 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 25 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.h | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 11 |
16 files changed, 280 insertions, 148 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 34a0c6860..f2528aeeb 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -269,6 +269,8 @@ _dict_set (dict_t *this, "@pair->key - NULL returned by CALLOC"); FREE (pair); + if (key_free) + GF_FREE (key); return -1; } diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h index e8c8427e8..ace869d70 100644 --- a/libglusterfs/src/mem-types.h +++ b/libglusterfs/src/mem-types.h @@ -22,80 +22,80 @@ enum gf_common_mem_types_ { - gf_common_mt_call_stub_t = 0, - gf_common_mt_dnscache6, - gf_common_mt_data_pair_t, - gf_common_mt_data_t, - gf_common_mt_dict_t, - gf_common_mt_event_pool, - gf_common_mt_reg, - gf_common_mt_pollfd, - gf_common_mt_epoll_event, - gf_common_mt_fdentry_t, - gf_common_mt_fdtable_t, - gf_common_mt_fd_t, - gf_common_mt_fd_ctx, - gf_common_mt_gf_dirent_t, - gf_common_mt_glusterfs_ctx_t, - gf_common_mt_dentry_t, - gf_common_mt_inode_t, - gf_common_mt_inode_ctx, - gf_common_mt_list_head, - gf_common_mt_inode_table_t, - gf_common_mt_xlator_t, - gf_common_mt_xlator_list_t, - gf_common_mt_log_msg, - gf_common_mt_client_log, - gf_common_mt_volume_opt_list_t, - gf_common_mt_gf_hdr_common_t, - gf_common_mt_call_frame_t, - gf_common_mt_call_stack_t, - gf_common_mt_gf_timer_t, - gf_common_mt_gf_timer_registry_t, - gf_common_mt_transport, - gf_common_mt_transport_msg, - gf_common_mt_auth_handle_t, - gf_common_mt_iobuf, - gf_common_mt_iobuf_arena, - gf_common_mt_iobref, - gf_common_mt_iobuf_pool, - gf_common_mt_iovec, - gf_common_mt_memdup, - gf_common_mt_asprintf, - gf_common_mt_strdup, - gf_common_mt_socket_private_t, - gf_common_mt_ioq, - gf_common_mt_transport_t, - gf_common_mt_socket_local_t, - gf_common_mt_char, - gf_common_mt_rbthash_table_t, - gf_common_mt_rbthash_bucket, - gf_common_mt_mem_pool, - gf_common_mt_long, - gf_common_mt_rpcsvc_auth_list, - gf_common_mt_rpcsvc_t, - gf_common_mt_rpcsvc_conn_t, - gf_common_mt_rpcsvc_program_t, - gf_common_mt_rpcsvc_listener_t, - gf_common_mt_rpcsvc_wrapper_t, - gf_common_mt_rpcsvc_stage_t, - gf_common_mt_rpcclnt_t, - gf_common_mt_rpcclnt_savedframe_t, - gf_common_mt_rpc_trans_t, - gf_common_mt_rpc_trans_pollin_t, - gf_common_mt_rpc_trans_handover_t, - gf_common_mt_rpc_trans_reqinfo_t, - gf_common_mt_rpc_trans_rsp_t, - gf_common_mt_glusterfs_graph_t, - gf_common_mt_rdma_private_t, - gf_common_mt_rdma_ioq_t, - gf_common_mt_rpc_transport_t, - gf_common_mt_rdma_local_t, - gf_common_mt_rdma_post_t, - gf_common_mt_qpent, - gf_common_mt_rdma_device_t, - gf_common_mt_rdma_context_t, - gf_common_mt_sge, - gf_common_mt_end + gf_common_mt_call_stub_t = 0, + gf_common_mt_dnscache6 = 1, + gf_common_mt_data_pair_t = 2, + gf_common_mt_data_t = 3, + gf_common_mt_dict_t = 4, + gf_common_mt_event_pool = 5, + gf_common_mt_reg = 6, + gf_common_mt_pollfd = 7, + gf_common_mt_epoll_event = 8, + gf_common_mt_fdentry_t = 9, + gf_common_mt_fdtable_t = 10, + gf_common_mt_fd_t = 11, + gf_common_mt_fd_ctx = 12, + gf_common_mt_gf_dirent_t = 13, + gf_common_mt_glusterfs_ctx_t = 14, + gf_common_mt_dentry_t = 15, + gf_common_mt_inode_t = 16, + gf_common_mt_inode_ctx = 17, + gf_common_mt_list_head = 18, + gf_common_mt_inode_table_t = 19, + gf_common_mt_xlator_t = 20, + gf_common_mt_xlator_list_t = 21, + gf_common_mt_log_msg = 22, + gf_common_mt_client_log = 23, + gf_common_mt_volume_opt_list_t = 24, + gf_common_mt_gf_hdr_common_t = 25, + gf_common_mt_call_frame_t = 26, + gf_common_mt_call_stack_t = 27, + gf_common_mt_gf_timer_t = 28, + gf_common_mt_gf_timer_registry_t= 29, + gf_common_mt_transport = 30, + gf_common_mt_transport_msg = 31, + gf_common_mt_auth_handle_t = 32, + gf_common_mt_iobuf = 33, + gf_common_mt_iobuf_arena = 34, + gf_common_mt_iobref = 35, + gf_common_mt_iobuf_pool = 36, + gf_common_mt_iovec = 37, + gf_common_mt_memdup = 38, + gf_common_mt_asprintf = 39, + gf_common_mt_strdup = 40, + gf_common_mt_socket_private_t = 41, + gf_common_mt_ioq = 42, + gf_common_mt_transport_t = 43, + gf_common_mt_socket_local_t = 44, + gf_common_mt_char = 45, + gf_common_mt_rbthash_table_t = 46, + gf_common_mt_rbthash_bucket = 47, + gf_common_mt_mem_pool = 48, + gf_common_mt_long = 49, + gf_common_mt_rpcsvc_auth_list = 50, + gf_common_mt_rpcsvc_t = 51, + gf_common_mt_rpcsvc_conn_t = 52, + gf_common_mt_rpcsvc_program_t = 53, + gf_common_mt_rpcsvc_listener_t = 54, + gf_common_mt_rpcsvc_wrapper_t = 55, + gf_common_mt_rpcsvc_stage_t = 56, + gf_common_mt_rpcclnt_t = 57, + gf_common_mt_rpcclnt_savedframe_t = 58, + gf_common_mt_rpc_trans_t = 59, + gf_common_mt_rpc_trans_pollin_t = 60, + gf_common_mt_rpc_trans_handover_t = 61, + gf_common_mt_rpc_trans_reqinfo_t= 62, + gf_common_mt_rpc_trans_rsp_t = 63, + gf_common_mt_glusterfs_graph_t = 64, + gf_common_mt_rdma_private_t = 65, + gf_common_mt_rdma_ioq_t = 66, + gf_common_mt_rpc_transport_t = 67, + gf_common_mt_rdma_local_t = 68, + gf_common_mt_rdma_post_t = 69, + gf_common_mt_qpent = 70, + gf_common_mt_rdma_device_t = 71, + gf_common_mt_rdma_context_t = 72, + gf_common_mt_sge = 73, + gf_common_mt_end = 74 }; #endif diff --git a/libglusterfs/src/scheduler.c b/libglusterfs/src/scheduler.c index 94131676e..3fcaef73b 100644 --- a/libglusterfs/src/scheduler.c +++ b/libglusterfs/src/scheduler.c @@ -54,16 +54,18 @@ get_scheduler (xlator_t *xl, const char *name) handle = dlopen (sched_file, RTLD_LAZY); if (!handle) { - gf_log ("scheduler", GF_LOG_ERROR, - "dlopen(%s): %s", sched_file, dlerror ()); - return NULL; + gf_log ("scheduler", GF_LOG_ERROR, + "dlopen(%s): %s", sched_file, dlerror ()); + GF_FREE(sched_file); + return NULL; } tmp_sched = dlsym (handle, "sched"); if (!tmp_sched) { - gf_log ("scheduler", GF_LOG_ERROR, - "dlsym(sched) on %s", dlerror ()); - return NULL; + gf_log ("scheduler", GF_LOG_ERROR, + "dlsym(sched) on %s", dlerror ()); + GF_FREE(sched_file); + return NULL; } vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), @@ -78,10 +80,12 @@ get_scheduler (xlator_t *xl, const char *name) == -1) { gf_log ("scheduler", GF_LOG_ERROR, "volume option validation failed"); + GF_FREE(sched_file); return NULL; } } GF_FREE(sched_file); + GF_FREE (vol_opt); return tmp_sched; } diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c index 433eeb7df..0ef1190c3 100644 --- a/libglusterfs/src/timer.c +++ b/libglusterfs/src/timer.c @@ -118,6 +118,7 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx, reg = gf_timer_registry_init (ctx); if (!reg) { gf_log ("timer", GF_LOG_ERROR, "!reg"); + GF_FREE (event); return 0; } diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index fd7db3e03..2074c143c 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -700,6 +700,7 @@ xlator_set_type (xlator_t *xl, handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL); if (!handle) { gf_log ("xlator", GF_LOG_DEBUG, "%s", dlerror ()); + GF_FREE (name); return -1; } xl->dlhandle = handle; @@ -707,24 +708,28 @@ xlator_set_type (xlator_t *xl, if (!(xl->fops = dlsym (handle, "fops"))) { gf_log ("xlator", GF_LOG_DEBUG, "dlsym(fops) on %s", dlerror ()); + GF_FREE (name); return -1; } if (!(xl->cbks = dlsym (handle, "cbks"))) { gf_log ("xlator", GF_LOG_DEBUG, "dlsym(cbks) on %s", dlerror ()); + GF_FREE (name); return -1; } if (!(xl->init = dlsym (handle, "init"))) { gf_log ("xlator", GF_LOG_DEBUG, "dlsym(init) on %s", dlerror ()); + GF_FREE (name); return -1; } if (!(xl->fini = dlsym (handle, "fini"))) { gf_log ("xlator", GF_LOG_DEBUG, "dlsym(fini) on %s", dlerror ()); + GF_FREE (name); return -1; } @@ -749,8 +754,10 @@ xlator_set_type (xlator_t *xl, vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), gf_common_mt_volume_opt_list_t); - if (!vol_opt) + if (!vol_opt) { + GF_FREE (name); return -1; + } if (!(vol_opt->given_opt = dlsym (handle, "options"))) { dlerror (); diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index adbc0fe1e..184d614a4 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -958,6 +958,7 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) pthread_mutex_init (&trans->lock, NULL); trans->xl = THIS; return_trans = trans; + GF_FREE (vol_opt); return return_trans; fail: diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index f76a34e3f..5da6705a6 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -497,6 +497,7 @@ rpcsvc_volume_allowed (dict_t *options, char *volname) if (ret) gf_log ("rpcsvc", GF_LOG_DEBUG, "failed to get the string %s", srchstr); + GF_FREE (srchstr); } out: return addrstr; @@ -643,6 +644,8 @@ rpcsvc_conn_privport_check (rpcsvc_t *svc, char *volname, " allowed"); err: + if (srchstr) + GF_FREE (srchstr); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 42acfcc14..28812538f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -612,6 +612,8 @@ glusterd_handle_cli_list_friends (rpcsvc_request_t *req) ret = glusterd_list_friends (req, dict, cli_req.flags); out: + if (dict) + dict_unref (dict); return ret; } @@ -993,6 +995,8 @@ glusterd_handle_cli_get_volume (rpcsvc_request_t *req) ret = glusterd_get_volumes (req, dict, cli_req.flags); out: + if (dict) + dict_unref (dict); return ret; } @@ -1002,23 +1006,24 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) int32_t ret = -1; gf1_cli_create_vol_req cli_req = {0,}; dict_t *dict = NULL; - glusterd_brickinfo_t *brickinfo = NULL; - char *brick = NULL; - char *bricks = NULL; - char *volname = NULL; - int brick_count = 0; - char *tmpptr = NULL; - int i = 0; - glusterd_peerinfo_t *peerinfo = NULL; - char *brick_list = NULL; - void *cli_rsp = NULL; - char err_str[1048]; - gf1_cli_create_vol_rsp rsp = {0,}; + glusterd_brickinfo_t *brickinfo = NULL; + char *brick = NULL; + char *bricks = NULL; + char *volname = NULL; + int brick_count = 0; + char *tmpptr = NULL; + int i = 0; + glusterd_peerinfo_t *peerinfo = NULL; + char *brick_list = NULL; + void *cli_rsp = NULL; + char err_str[1048]; + gf1_cli_create_vol_rsp rsp = {0,}; glusterd_conf_t *priv = NULL; int err_ret = 0; glusterd_brickinfo_t *tmpbrkinfo = NULL; glusterd_volinfo_t *volinfo = NULL; xlator_t *this = NULL; + char *free_ptr = NULL; GF_ASSERT (req); this = THIS; @@ -1077,8 +1082,10 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) goto out; } - if (bricks) + if (bricks) { brick_list = gf_strdup (bricks); + free_ptr = brick_list; + } gf_cmd_log ("Volume create", "volname: %s type:%s count:%d bricks:%s", cli_req.volname, ((cli_req.type == 0)? "DEFAULT": @@ -1148,8 +1155,11 @@ out: " failed"); ret = 0; //Client response sent, prevent second response } + gf_cmd_log ("Volume create", "on volname:%s %s", volname, ((ret || err_ret) != 0) ? "FAILED": "SUCCESS"); + if (free_ptr) + GF_FREE(free_ptr); return ret; } @@ -2001,6 +2011,8 @@ out: uuid_copy (rsp.uuid, priv->uuid); ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gd_xdr_serialize_mgmt_friend_update_rsp); + if (dict) + dict_unref (dict); return ret; } @@ -2153,8 +2165,9 @@ glusterd_friend_add (const char *hoststr, int port, out: gf_log ("glusterd", GF_LOG_NORMAL, "connect returned %d", ret); + if (rpc_cfg.remote_host) + GF_FREE (rpc_cfg.remote_host); return ret; - } @@ -2299,6 +2312,8 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int por ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gd_xdr_serialize_mgmt_friend_rsp); + if (rsp.hostname) + GF_FREE (rsp.hostname); gf_log ("glusterd", GF_LOG_NORMAL, "Responded to %s (%d), ret: %d", hostname, port, ret); return ret; @@ -2686,13 +2701,15 @@ out: if (ret) { if (friends) - dict_destroy (friends); + dict_unref (friends); } rsp.op_ret = ret; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gf_xdr_serialize_cli_peer_list_rsp); + if (rsp.friends.friends_val) + GF_FREE (rsp.friends.friends_val); return ret; } @@ -2753,7 +2770,7 @@ out: gf_xdr_serialize_cli_peer_list_rsp); if (volumes) - dict_destroy (volumes); + dict_unref (volumes); if (rsp.volumes.volumes_val) GF_FREE (rsp.volumes.volumes_val); diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 95fe96e04..1ea1fcef0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -47,11 +47,13 @@ build_volfile_path (const char *volname, char *path, glusterd_conf_t *priv = NULL; char *vol = NULL; char *dup_volname = NULL; + char *free_ptr = NULL; char *tmp = NULL; glusterd_volinfo_t *volinfo = NULL; priv = THIS->private; dup_volname = gf_strdup (volname); + free_ptr = dup_volname; ret = glusterd_volinfo_find (dup_volname, &volinfo); if (ret) { @@ -81,9 +83,8 @@ build_volfile_path (const char *volname, char *path, ret = 1; out: - if (dup_volname) - GF_FREE (dup_volname); - + if (free_ptr) + GF_FREE (free_ptr); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h index 5db1e0d79..8b99e9e4c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h +++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h @@ -24,41 +24,41 @@ #include "mem-types.h" enum gf_gld_mem_types_ { - gf_gld_mt_dir_entry_t = gf_common_mt_end + 1, - gf_gld_mt_volfile_ctx, - gf_gld_mt_glusterd_state_t, - gf_gld_mt_glusterd_conf_t, - gf_gld_mt_locker, - gf_gld_mt_string, - gf_gld_mt_lock_table, - gf_gld_mt_char, - gf_gld_mt_glusterd_connection_t, - gf_gld_mt_resolve_comp, - gf_gld_mt_peerinfo_t, - gf_gld_mt_friend_sm_event_t, - gf_gld_mt_friend_req_ctx_t, - gf_gld_mt_friend_update_ctx_t, - gf_gld_mt_op_sm_event_t, - gf_gld_mt_op_lock_ctx_t, - gf_gld_mt_op_stage_ctx_t, - gf_gld_mt_op_commit_ctx_t, - gf_gld_mt_mop_stage_req_t, - gf_gld_mt_probe_ctx_t, - gf_gld_mt_create_volume_ctx_t, - gf_gld_mt_start_volume_ctx_t, - gf_gld_mt_stop_volume_ctx_t, - gf_gld_mt_delete_volume_ctx_t, - gf_gld_mt_glusterd_volinfo_t, - gf_gld_mt_glusterd_brickinfo_t, - gf_gld_mt_peer_hostname_t, - gf_gld_mt_ifreq, - gf_gld_mt_store_handle_t, - gf_gld_mt_store_iter_t, - gf_gld_mt_defrag_info, - gf_gld_mt_log_filename_ctx_t, - gf_gld_mt_log_locate_ctx_t, - gf_gld_mt_log_rotate_ctx_t, - gf_gld_mt_end + gf_gld_mt_dir_entry_t = gf_common_mt_end + 1, + gf_gld_mt_volfile_ctx = gf_common_mt_end + 2, + gf_gld_mt_glusterd_state_t = gf_common_mt_end + 3, + gf_gld_mt_glusterd_conf_t = gf_common_mt_end + 4, + gf_gld_mt_locker = gf_common_mt_end + 5, + gf_gld_mt_string = gf_common_mt_end + 6, + gf_gld_mt_lock_table = gf_common_mt_end + 7, + gf_gld_mt_char = gf_common_mt_end + 8, + gf_gld_mt_glusterd_connection_t = gf_common_mt_end + 9, + gf_gld_mt_resolve_comp = gf_common_mt_end + 10, + gf_gld_mt_peerinfo_t = gf_common_mt_end + 11, + gf_gld_mt_friend_sm_event_t = gf_common_mt_end + 12, + gf_gld_mt_friend_req_ctx_t = gf_common_mt_end + 13, + gf_gld_mt_friend_update_ctx_t = gf_common_mt_end + 14, + gf_gld_mt_op_sm_event_t = gf_common_mt_end + 15, + gf_gld_mt_op_lock_ctx_t = gf_common_mt_end + 16, + gf_gld_mt_op_stage_ctx_t = gf_common_mt_end + 17, + gf_gld_mt_op_commit_ctx_t = gf_common_mt_end + 18, + gf_gld_mt_mop_stage_req_t = gf_common_mt_end + 19, + gf_gld_mt_probe_ctx_t = gf_common_mt_end + 20, + gf_gld_mt_create_volume_ctx_t = gf_common_mt_end + 21, + gf_gld_mt_start_volume_ctx_t = gf_common_mt_end + 22, + gf_gld_mt_stop_volume_ctx_t = gf_common_mt_end + 23, + gf_gld_mt_delete_volume_ctx_t = gf_common_mt_end + 24, + gf_gld_mt_glusterd_volinfo_t = gf_common_mt_end + 25, + gf_gld_mt_glusterd_brickinfo_t = gf_common_mt_end + 26, + gf_gld_mt_peer_hostname_t = gf_common_mt_end + 27, + gf_gld_mt_ifreq = gf_common_mt_end + 28, + gf_gld_mt_store_handle_t = gf_common_mt_end + 29, + gf_gld_mt_store_iter_t = gf_common_mt_end + 30, + gf_gld_mt_defrag_info = gf_common_mt_end + 31, + gf_gld_mt_log_filename_ctx_t = gf_common_mt_end + 32, + gf_gld_mt_log_locate_ctx_t = gf_common_mt_end + 33, + gf_gld_mt_log_rotate_ctx_t = gf_common_mt_end + 34, + gf_gld_mt_end = gf_common_mt_end + 35 }; #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index c78c19fde..57b88a72f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -374,7 +374,7 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req) ret = glusterd_brickinfo_from_brick (brick, &brick_info); if (ret) goto out; - snprintf (cmd_str, 1024, "%s", brick_info->path); + snprintf (cmd_str, 1024, "%s", brick_info->path); ret = glusterd_resolve_brick (brick_info); if (ret) { gf_log ("glusterd", GF_LOG_ERROR, @@ -392,8 +392,11 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req) } brick_list = tmpptr; } + glusterd_brickinfo_delete (brick_info); } out: + if (dict) + dict_unref (dict); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -585,6 +588,7 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req) char *bricks = NULL; char *brick_list = NULL; char *saveptr = NULL; + char *free_ptr = NULL; char *brick = NULL; glusterd_brickinfo_t *brickinfo = NULL; glusterd_volinfo_t *volinfo = NULL; @@ -629,8 +633,10 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req) goto out; } - if (bricks) + if (bricks) { brick_list = gf_strdup (bricks); + free_ptr = brick_list; + } if (count) brick = strtok_r (brick_list+1, " \n", &saveptr); @@ -659,11 +665,16 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req) goto out; } + glusterd_brickinfo_delete (brickinfo); brick = strtok_r (NULL, " \n", &saveptr); i++; } out: + if (dict) + dict_unref (dict); + if (free_ptr) + GF_FREE (free_ptr); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -751,6 +762,8 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req) ret = 0; out: + if (dict) + dict_unref (dict); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -791,6 +804,8 @@ glusterd_op_stage_log_filename (gd1_mgmt_stage_op_req *req) } out: + if (dict) + dict_unref (dict); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -896,6 +911,7 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req) int32_t i = 1; char *bricks = NULL; char *brick_list = NULL; + char *free_ptr = NULL; char *saveptr = NULL; int32_t sub_count = 0; @@ -976,8 +992,10 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req) volinfo->sub_count = sub_count; - if (bricks) + if (bricks) { brick_list = gf_strdup (bricks); + free_ptr = brick_list; + } if (count) brick = strtok_r (brick_list+1, " \n", &saveptr); @@ -1006,6 +1024,12 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req) goto out; out: + if (dict) + dict_unref (dict); + + if (free_ptr) + GF_FREE(free_ptr); + return ret; } @@ -1024,6 +1048,8 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) int32_t i = 1; char *bricks = NULL; char *brick_list = NULL; + char *free_ptr1 = NULL; + char *free_ptr2 = NULL; char *saveptr = NULL; gf_boolean_t glfs_started = _gf_false; int32_t mybrick = 0; @@ -1076,8 +1102,10 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) goto out; } - if (bricks) + if (bricks) { brick_list = gf_strdup (bricks); + free_ptr1 = brick_list; + } if (count) brick = strtok_r (brick_list+1, " \n", &saveptr); @@ -1093,6 +1121,7 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) } brick_list = gf_strdup (bricks); + free_ptr2 = brick_list; i = 1; if (count) @@ -1149,6 +1178,12 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) out: + if (dict) + dict_unref (dict); + if (free_ptr1) + GF_FREE (free_ptr1); + if (free_ptr2) + GF_FREE (free_ptr2); return ret; } @@ -1984,6 +2019,8 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req) goto out; out: + if (dict) + dict_unref (dict); return ret; } @@ -2053,7 +2090,11 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req) gf_log ("", GF_LOG_ERROR, "Unable to get %s", key); goto out; } + if (dup_brick) + GF_FREE (dup_brick); dup_brick = gf_strdup (brick); + if (!dup_brick) + goto out; ret = glusterd_brickinfo_get (dup_brick, volinfo, &brickinfo); if (ret) @@ -2107,6 +2148,10 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req) out: + if (dict) + dict_unref (dict); + if (dup_brick) + GF_FREE (dup_brick); return ret; } @@ -3451,7 +3496,21 @@ glusterd_op_clear_ctx (glusterd_op_t op) opinfo.op_ctx[op] = NULL; if (ctx && glusterd_op_get_ctx_free(op)) { - GF_FREE(ctx); + switch (op) { + case GD_OP_CREATE_VOLUME: + case GD_OP_STOP_VOLUME: + case GD_OP_ADD_BRICK: + case GD_OP_REMOVE_BRICK: + case GD_OP_REPLACE_BRICK: + dict_unref (ctx); + break; + case GD_OP_DELETE_VOLUME: + case GD_OP_START_VOLUME: + GF_FREE (ctx); + break; + default: + break; + } } return 0; diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index c12a11a8f..3eaa8ffef 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -153,7 +153,7 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx) out: if (dict) - dict_destroy (dict); + dict_unref (dict); gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 22bb1a611..122cb7320 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -192,6 +192,8 @@ glusterd_store_delete_brick (glusterd_volinfo_t *volinfo, } out: + if (brickinfo->shandle) + glusterd_store_handle_destroy (brickinfo->shandle); gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; } @@ -397,6 +399,8 @@ stat_failed: out: + if (volinfo->shandle) + glusterd_store_handle_destroy (volinfo->shandle); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -413,6 +417,7 @@ glusterd_store_retrieve_value (glusterd_store_handle_t *handle, char *iter_key = NULL; char *iter_val = NULL; char *str = NULL; + char *free_str = NULL; GF_ASSERT (handle); @@ -430,9 +435,15 @@ glusterd_store_retrieve_value (glusterd_store_handle_t *handle, ret = fscanf (handle->read, "%s", scan_str); while (ret != EOF) { + if (free_str) { + GF_FREE (free_str); + free_str = NULL; + } str = gf_strdup (scan_str); if (!str) goto out; + else + free_str = str; iter_key = strtok (str, "="); gf_log ("", GF_LOG_DEBUG, "key %s read", iter_key); @@ -456,6 +467,9 @@ out: handle->read = NULL; } + if (free_str) + GF_FREE (free_str); + return ret; } @@ -674,6 +688,8 @@ glusterd_retrieve_uuid () uuid_parse (uuid_str, priv->uuid); out: + if (uuid_str) + GF_FREE (uuid_str); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; } @@ -730,6 +746,7 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter, int32_t ret = -1; char scan_str[4096] = {0,}; char *str = NULL; + char *free_str = NULL; char *iter_key = NULL; char *iter_val = NULL; @@ -746,6 +763,8 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter, str = gf_strdup (scan_str); if (!str) goto out; + else + free_str = str; iter_key = strtok (str, "="); gf_log ("", GF_LOG_DEBUG, "key %s read", iter_key); @@ -761,8 +780,8 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter, ret = 0; out: - if (str) - GF_FREE (str); + if (free_str) + GF_FREE (free_str); gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; @@ -1103,6 +1122,8 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo) ret = unlink (filepath); out: + if (peerinfo->shandle) + glusterd_store_handle_destroy(peerinfo->shandle); gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index 29caa899f..9d63fb403 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -102,6 +102,10 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo); int32_t glusterd_store_delete_brick (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); + +int32_t +glusterd_store_handle_destroy (glusterd_store_handle_t *handle); + int32_t glusterd_restore (); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 1866a9904..0861d0219 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -661,6 +661,7 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo, char *hostname = NULL; char *path = NULL; char *dup_brick = NULL; + char *free_ptr = NULL; glusterd_brickinfo_t *tmp = NULL; GF_ASSERT (brick); @@ -675,6 +676,8 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo, "Out of memory"); ret = -1; goto out; + } else { + free_ptr = dup_brick; } hostname = strtok (dup_brick, ":"); @@ -701,8 +704,8 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo, *brickinfo = tmp; out: - if (dup_brick) - GF_FREE (dup_brick); + if (free_ptr) + GF_FREE (free_ptr); gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -1189,7 +1192,7 @@ glusterd_build_volume_dict (dict_t **vols) out: gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); if (ret) - dict_destroy (dict); + dict_unref (dict); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index ad3eb5cc3..3f7db7e5b 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -624,6 +624,8 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this, this, glusterd3_1_probe_cbk); out: + if (req.hostname) + GF_FREE (req.hostname); gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); return ret; } @@ -680,7 +682,10 @@ out: GF_FREE (req.vols.vols_val); if (vols) - dict_destroy (vols); + dict_unref (vols); + + if (req.hostname) + GF_FREE (req.hostname); gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -805,6 +810,10 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, } out: + if (friends) + dict_unref (friends); + if (req.friends.friends_val) + GF_FREE (req.friends.friends_val); gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); return ret; } |