diff options
author | Mohit Agrawal <moagrawa@redhat.com> | 2018-02-10 12:25:15 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-02-27 07:11:15 +0000 |
commit | 7c3cc485054e4ede1efb358552135b432fb7047a (patch) | |
tree | 5657500860f795b7c895bce14069545d8ba463e2 /xlators/features | |
parent | 430bff7dc330eec9447423e95f2cae49744a79c3 (diff) |
glusterfsd: Memleak in glusterfsd process while brick mux is on
Problem: At the time of stopping the volume while brick multiplex is
enabled memory is not cleanup from all server side xlators.
Solution: To cleanup memory for all server side xlators call fini
in glusterfs_handle_terminate after send GF_EVENT_CLEANUP
notification to top xlator.
BUG: 1544090
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Note: Run all test-cases in separate build (https://review.gluster.org/19574)
with same patch after enable brick mux forcefully, all test cases are
passed.
Change-Id: Ia10dc7f2605aa50f2b90b3fe4eb380ba9299e2fc
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 22 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-ev-handle.c | 8 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc-common.c | 4 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 12 | ||||
-rw-r--r-- | xlators/features/changetimerecorder/src/changetimerecorder.c | 15 | ||||
-rw-r--r-- | xlators/features/index/src/index.c | 21 | ||||
-rw-r--r-- | xlators/features/leases/src/leases.c | 15 | ||||
-rw-r--r-- | xlators/features/marker/src/marker.c | 69 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.c | 23 | ||||
-rw-r--r-- | xlators/features/shard/src/shard.c | 3 | ||||
-rw-r--r-- | xlators/features/trash/src/trash.c | 15 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall.c | 18 |
12 files changed, 143 insertions, 82 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 76a4c3f6962..830357070d6 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -229,18 +229,6 @@ notify (xlator_t *this, int event, void *data, ...) if (!priv) return 0; - switch (event) { - case GF_EVENT_CLEANUP: - if (priv->signth) { - (void) gf_thread_cleanup_xint (priv->signth); - priv->signth = 0; - } - if (priv->container.thread) { - (void) gf_thread_cleanup_xint (priv->container.thread); - priv->container.thread = 0; - } - break; - } default_notify (this, event, data); return 0; } @@ -263,6 +251,7 @@ fini (xlator_t *this) "Could not cancel sign serializer thread"); goto out; } + priv->signth = 0; while (!list_empty (&priv->squeue)) { sigstub = list_first_entry (&priv->squeue, @@ -284,12 +273,19 @@ fini (xlator_t *this) goto out; } + priv->container.thread = 0; + while (!list_empty (&priv->container.bad_queue)) { stub = list_first_entry (&priv->container.bad_queue, call_stub_t, list); list_del_init (&stub->list); call_stub_destroy (stub); - }; + } + + if (priv->local_pool) { + mem_pool_destroy (priv->local_pool); + priv->local_pool = NULL; + } pthread_mutex_destroy (&priv->container.bad_lock); pthread_cond_destroy (&priv->container.bad_cond); diff --git a/xlators/features/changelog/src/changelog-ev-handle.c b/xlators/features/changelog/src/changelog-ev-handle.c index a7f485b019f..b5681944567 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.c +++ b/xlators/features/changelog/src/changelog-ev-handle.c @@ -163,12 +163,14 @@ changelog_rpc_notify (struct rpc_clnt *rpc, */ rpc_clnt_unref (crpc->rpc); - selection = &priv->ev_selection; + if (priv) + selection = &priv->ev_selection; LOCK (&crpc->lock); { - changelog_deselect_event (this, selection, - crpc->filter); + if (selection) + changelog_deselect_event (this, selection, + crpc->filter); changelog_set_disconnect_flag (crpc, _gf_true); } UNLOCK (&crpc->lock); diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c index 7bd5b688fa5..1745f218b08 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.c +++ b/xlators/features/changelog/src/changelog-rpc-common.c @@ -275,6 +275,10 @@ changelog_rpc_server_destroy (xlator_t *this, rpcsvc_t *rpc, char *sockfile, (void) rpcsvc_unregister_notify (rpc, fn, this); sys_unlink (sockfile); + if (rpc->rxpool) { + mem_pool_destroy (rpc->rxpool); + rpc->rxpool = NULL; + } GF_FREE (rpc); } diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index 10a149232c2..a92e7a1828f 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -2111,14 +2111,6 @@ notify (xlator_t *this, int event, void *data, ...) if (!priv) goto out; - if (event == GF_EVENT_CLEANUP) { - /* terminate helper threads */ - changelog_cleanup_helper_threads (this, priv); - - /* terminate RPC server/threads */ - changelog_cleanup_rpc_threads (this, priv); - } - if (event == GF_EVENT_TRANSLATOR_OP) { dict = data; @@ -2912,6 +2904,9 @@ fini (xlator_t *this) /* cleanup barrier related objects */ changelog_barrier_pthread_destroy (priv); + /* cleanup helper threads */ + changelog_cleanup_helper_threads (this, priv); + /* cleanup allocated options */ changelog_freeup_options (this, priv); @@ -2922,6 +2917,7 @@ fini (xlator_t *this) } this->private = NULL; + this->local_pool = NULL; return; } diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c index e97e3ad6cfa..40bfcf4a32a 100644 --- a/xlators/features/changetimerecorder/src/changetimerecorder.c +++ b/xlators/features/changetimerecorder/src/changetimerecorder.c @@ -19,7 +19,6 @@ #include "tier-ctr-interface.h" /*******************************inode forget***********************************/ - int ctr_forget (xlator_t *this, inode_t *inode) { @@ -2306,15 +2305,6 @@ notify (xlator_t *this, int event, void *data, ...) if (!priv) goto out; - if (event == GF_EVENT_CLEANUP) { - if (fini_db (priv->_db_conn)) { - gf_msg (this->name, GF_LOG_WARNING, 0, - CTR_MSG_CLOSE_DB_CONN_FAILED, "Failed closing " - "db connection"); - } - if (priv->_db_conn) - priv->_db_conn = NULL; - } ret = default_notify (this, event, data); out: @@ -2355,6 +2345,10 @@ fini (xlator_t *this) CTR_MSG_CLOSE_DB_CONN_FAILED, "Failed closing " "db connection"); } + + if (priv->_db_conn) + priv->_db_conn = NULL; + GF_FREE (priv->ctr_db_path); if (pthread_mutex_destroy (&priv->compact_lock)) { gf_msg (this->name, GF_LOG_WARNING, 0, @@ -2364,6 +2358,7 @@ fini (xlator_t *this) } GF_FREE (priv); mem_pool_destroy (this->local_pool); + this->local_pool = NULL; return; } diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index ed89c02ae74..5e723e5e4c6 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -2460,6 +2460,13 @@ fini (xlator_t *this) priv = this->private; if (!priv) goto out; + + priv->down = _gf_true; + pthread_cond_broadcast (&priv->cond); + if (priv->thread) { + gf_thread_cleanup_xint (priv->thread); + priv->thread = 0; + } this->private = NULL; LOCK_DESTROY (&priv->lock); pthread_cond_destroy (&priv->cond); @@ -2471,8 +2478,11 @@ fini (xlator_t *this) if (priv->complete_watchlist) dict_unref (priv->complete_watchlist); GF_FREE (priv); - mem_pool_destroy (this->local_pool); - this->local_pool = NULL; + + if (this->local_pool) { + mem_pool_destroy (this->local_pool); + this->local_pool = NULL; + } out: return; } @@ -2542,13 +2552,6 @@ notify (xlator_t *this, int event, void *data, ...) if (!priv) return 0; - switch (event) { - case GF_EVENT_CLEANUP: - priv->down = _gf_true; - pthread_cond_broadcast (&priv->cond); - break; - } - ret = default_notify (this, event, data); return ret; } diff --git a/xlators/features/leases/src/leases.c b/xlators/features/leases/src/leases.c index d4fdbfb7ea1..ebee682a685 100644 --- a/xlators/features/leases/src/leases.c +++ b/xlators/features/leases/src/leases.c @@ -1041,14 +1041,17 @@ fini (xlator_t *this) priv->fini = _gf_true; pthread_cond_broadcast (&priv->cond); - pthread_join (priv->recall_thr, NULL); - - priv->inited_recall_thr = _gf_false; + if (priv->recall_thr) { + gf_thread_cleanup_xint (priv->recall_thr); + priv->recall_thr = 0; + priv->inited_recall_thr = _gf_false; + } GF_FREE (priv); - - glusterfs_ctx_tw_put (this->ctx); - + if (this->ctx->tw) { + glusterfs_ctx_tw_put (this->ctx); + this->ctx->tw = NULL; + } return 0; } diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index cb8f8356259..36cfb34f069 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -3193,9 +3193,9 @@ mem_acct_init (xlator_t *this) int32_t init_xtime_priv (xlator_t *this, dict_t *options) { - data_t *data = NULL; int32_t ret = -1; marker_conf_t *priv = NULL; + char *tmp_opt = NULL; GF_VALIDATE_OR_GOTO ("marker", this, out); GF_VALIDATE_OR_GOTO (this->name, options, out); @@ -3203,29 +3203,11 @@ init_xtime_priv (xlator_t *this, dict_t *options) priv = this->private; - if((data = dict_get (options, VOLUME_UUID)) != NULL) { - priv->volume_uuid = data->data; + ret = dict_get_str (options, "volume-uuid", &tmp_opt); - ret = gf_uuid_parse (priv->volume_uuid, priv->volume_uuid_bin); - if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "invalid volume uuid %s", priv->volume_uuid); - goto out; - } - - ret = gf_asprintf (& (priv->marker_xattr), "%s.%s.%s", - MARKER_XATTR_PREFIX, priv->volume_uuid, - XTIME); - - if (ret == -1){ - priv->marker_xattr = NULL; - goto out; - } - - gf_log (this->name, GF_LOG_DEBUG, - "volume-uuid = %s", priv->volume_uuid); - } else { + if (ret) { priv->volume_uuid = NULL; + tmp_opt = ""; gf_log (this->name, GF_LOG_ERROR, "please specify the volume-uuid" @@ -3233,16 +3215,32 @@ init_xtime_priv (xlator_t *this, dict_t *options) return -1; } + gf_asprintf (&priv->volume_uuid, "%s", tmp_opt); - if ((data = dict_get (options, TIMESTAMP_FILE)) != NULL) { - priv->timestamp_file = data->data; + ret = gf_uuid_parse (priv->volume_uuid, priv->volume_uuid_bin); - gf_log (this->name, GF_LOG_DEBUG, - "the timestamp-file is = %s", - priv->timestamp_file); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, + "invalid volume uuid %s", priv->volume_uuid); + goto out; + } - } else { + ret = gf_asprintf (&(priv->marker_xattr), "%s.%s.%s", + MARKER_XATTR_PREFIX, priv->volume_uuid, + XTIME); + + if (ret == -1) { + priv->marker_xattr = NULL; + goto out; + } + + gf_log (this->name, GF_LOG_DEBUG, + "volume-uuid = %s", priv->volume_uuid); + + ret = dict_get_str (options, "timestamp-file", &tmp_opt); + if (ret) { priv->timestamp_file = NULL; + tmp_opt = ""; gf_log (this->name, GF_LOG_ERROR, "please specify the timestamp-file" @@ -3251,6 +3249,15 @@ init_xtime_priv (xlator_t *this, dict_t *options) goto out; } + ret = gf_asprintf (&priv->timestamp_file, "%s", tmp_opt); + if (ret == -1) { + priv->timestamp_file = NULL; + goto out; + } + + gf_log (this->name, GF_LOG_DEBUG, + "the timestamp-file is = %s", priv->timestamp_file); + ret = 0; out: return ret; @@ -3292,6 +3299,12 @@ marker_priv_cleanup (xlator_t *this) LOCK_DESTROY (&priv->lock); GF_FREE (priv); + + if (this->local_pool) { + mem_pool_destroy (this->local_pool); + this->local_pool = NULL; + } + out: return; } diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index e8335e63c1c..c731748402c 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -5194,6 +5194,8 @@ quota_priv_dump (xlator_t *this) GF_ASSERT (this); priv = this->private; + if (!priv) + goto out; gf_proc_dump_add_section ("xlators.features.quota.priv", this->name); @@ -5219,6 +5221,27 @@ out: void fini (xlator_t *this) { + quota_priv_t *priv = NULL; + rpc_clnt_t *rpc = NULL; + int i = 0, cnt = 0; + + priv = this->private; + if (!priv) + return; + rpc = priv->rpc_clnt; + priv->rpc_clnt = NULL; + this->private = NULL; + if (rpc) { + cnt = GF_ATOMIC_GET (rpc->refcount); + for (i = 0; i < cnt; i++) + rpc_clnt_unref (rpc); + } + LOCK_DESTROY (&priv->lock); + GF_FREE (priv); + if (this->local_pool) { + mem_pool_destroy (this->local_pool); + this->local_pool = NULL; + } return; } diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index f5275a3fb58..03504ab2743 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -5047,6 +5047,9 @@ shard_forget (xlator_t *this, inode_t *inode) shard_priv_t *priv = NULL; priv = this->private; + if (!priv) + return 0; + inode_ctx_del (inode, this, &ctx_uint); if (!ctx_uint) return 0; diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index cfdcc6ff5fc..e8f8b7bf051 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -33,7 +33,6 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *preoldparent, struct iatt *postoldparent, struct iatt *prenewparent, struct iatt *postnewparent, dict_t *xdata); - /* Common routines used in this translator */ /** @@ -2431,6 +2430,7 @@ notify (xlator_t *this, int event, void *data, ...) ret = create_internalop_directory (this); } + out: ret = default_notify (this, event, data); if (ret) @@ -2612,10 +2612,11 @@ void fini (xlator_t *this) { trash_private_t *priv = NULL; + inode_table_t *inode_table = NULL; GF_VALIDATE_OR_GOTO ("trash", this, out); priv = this->private; - + inode_table = priv->trash_itable; if (priv) { if (priv->newtrash_dir) GF_FREE (priv->newtrash_dir); @@ -2625,9 +2626,17 @@ fini (xlator_t *this) GF_FREE (priv->brick_path); if (priv->eliminate) wipe_eliminate_path (&priv->eliminate); + if (inode_table) { + inode_table_destroy (inode_table); + priv->trash_itable = NULL; + } GF_FREE (priv); } - mem_pool_destroy (this->local_pool); + + if (this->local_pool) { + mem_pool_destroy (this->local_pool); + this->local_pool = NULL; + } this->private = NULL; out: return; diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c index b9b4bc9d725..7e1185a417f 100644 --- a/xlators/features/upcall/src/upcall.c +++ b/xlators/features/upcall/src/upcall.c @@ -2446,8 +2446,11 @@ fini (xlator_t *this) priv->fini = 1; - if (priv->reaper_init_done) - pthread_join (priv->reaper_thr, NULL); + if (priv->reaper_thr) { + gf_thread_cleanup_xint (priv->reaper_thr); + priv->reaper_thr = 0; + priv->reaper_init_done = _gf_false; + } dict_unref (priv->xattrs); LOCK_DESTROY (&priv->inode_ctx_lk); @@ -2457,13 +2460,24 @@ fini (xlator_t *this) * before calling xlator_fini */ GF_FREE (priv); + if (this->local_pool) { + mem_pool_destroy (this->local_pool); + this->local_pool = NULL; + } + return 0; } int upcall_forget (xlator_t *this, inode_t *inode) { + upcall_private_t *priv = this->private; + + if (!priv) + goto out; + upcall_cleanup_inode_ctx (this, inode); +out: return 0; } |