|
|
74096c |
From 51090a4b3cb000d601083f12d1875547819fc03f Mon Sep 17 00:00:00 2001
|
|
|
74096c |
From: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
74096c |
Date: Wed, 4 Mar 2020 09:17:26 +0530
|
|
|
74096c |
Subject: [PATCH 447/449] core[brick_mux]: brick crashed when creating and
|
|
|
74096c |
deleting volumes over time
|
|
|
74096c |
|
|
|
74096c |
Problem: In brick_mux environment, while volumes are created/stopped in a loop
|
|
|
74096c |
after running a long time the main brick is crashed.The brick is crashed
|
|
|
74096c |
because the main brick process was not cleaned up memory for all objects
|
|
|
74096c |
at the time of detaching a volume.
|
|
|
74096c |
Below are the objects that are missed at the time of detaching a volume
|
|
|
74096c |
1) xlator object for a brick graph
|
|
|
74096c |
2) local_pool for posix_lock xlator
|
|
|
74096c |
3) rpc object cleanup at quota xlator
|
|
|
74096c |
4) inode leak at brick xlator
|
|
|
74096c |
|
|
|
74096c |
Solution: To avoid the crash resolve all leak at the time of detaching a brick
|
|
|
74096c |
> Change-Id: Ibb6e46c5fba22b9441a88cbaf6b3278823235913
|
|
|
74096c |
> updates: #977
|
|
|
74096c |
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
74096c |
> (Cherry pick from commit e589d8de66d3325da8fbbbe44d1a5bd6335e08ab)
|
|
|
74096c |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/24209/)
|
|
|
74096c |
|
|
|
74096c |
BUG: 1790336
|
|
|
74096c |
Change-Id: Ibb6e46c5fba22b9441a88cbaf6b3278823235913
|
|
|
74096c |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
74096c |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202782
|
|
|
74096c |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
74096c |
Reviewed-by: Xavi Hernandez Juan <xhernandez@redhat.com>
|
|
|
74096c |
---
|
|
|
74096c |
libglusterfs/src/glusterfs/glusterfs.h | 1 +
|
|
|
74096c |
libglusterfs/src/graph.c | 1 +
|
|
|
74096c |
libglusterfs/src/graph.y | 2 +-
|
|
|
74096c |
libglusterfs/src/xlator.c | 29 ++++++++----
|
|
|
74096c |
xlators/features/changelog/src/changelog.c | 1 +
|
|
|
74096c |
xlators/features/locks/src/posix.c | 4 ++
|
|
|
74096c |
xlators/features/quota/src/quota-enforcer-client.c | 14 +++++-
|
|
|
74096c |
xlators/features/quota/src/quota.c | 54 ++++++++++++++++++++--
|
|
|
74096c |
xlators/features/quota/src/quota.h | 3 ++
|
|
|
74096c |
xlators/protocol/server/src/server.c | 12 +++--
|
|
|
74096c |
10 files changed, 103 insertions(+), 18 deletions(-)
|
|
|
74096c |
|
|
|
74096c |
diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
74096c |
index 177a020..584846e 100644
|
|
|
74096c |
--- a/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
74096c |
+++ b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
74096c |
@@ -603,6 +603,7 @@ struct _glusterfs_graph {
|
|
|
74096c |
int used; /* Should be set when fuse gets
|
|
|
74096c |
first CHILD_UP */
|
|
|
74096c |
uint32_t volfile_checksum;
|
|
|
74096c |
+ pthread_mutex_t mutex;
|
|
|
74096c |
};
|
|
|
74096c |
typedef struct _glusterfs_graph glusterfs_graph_t;
|
|
|
74096c |
|
|
|
74096c |
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
|
|
|
74096c |
index bb5e67a..1cd92db 100644
|
|
|
74096c |
--- a/libglusterfs/src/graph.c
|
|
|
74096c |
+++ b/libglusterfs/src/graph.c
|
|
|
74096c |
@@ -1092,6 +1092,7 @@ glusterfs_graph_destroy_residual(glusterfs_graph_t *graph)
|
|
|
74096c |
ret = xlator_tree_free_memacct(graph->first);
|
|
|
74096c |
|
|
|
74096c |
list_del_init(&graph->list);
|
|
|
74096c |
+ pthread_mutex_destroy(&graph->mutex);
|
|
|
74096c |
GF_FREE(graph);
|
|
|
74096c |
|
|
|
74096c |
return ret;
|
|
|
74096c |
diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y
|
|
|
74096c |
index 5b92985..5733515 100644
|
|
|
74096c |
--- a/libglusterfs/src/graph.y
|
|
|
74096c |
+++ b/libglusterfs/src/graph.y
|
|
|
74096c |
@@ -541,7 +541,7 @@ glusterfs_graph_new ()
|
|
|
74096c |
return NULL;
|
|
|
74096c |
|
|
|
74096c |
INIT_LIST_HEAD (&graph->list);
|
|
|
74096c |
-
|
|
|
74096c |
+ pthread_mutex_init(&graph->mutex, NULL);
|
|
|
74096c |
gettimeofday (&graph->dob, NULL);
|
|
|
74096c |
|
|
|
74096c |
return graph;
|
|
|
74096c |
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
|
|
|
74096c |
index 108b96a..36cc32c 100644
|
|
|
74096c |
--- a/libglusterfs/src/xlator.c
|
|
|
74096c |
+++ b/libglusterfs/src/xlator.c
|
|
|
74096c |
@@ -938,6 +938,8 @@ xlator_mem_cleanup(xlator_t *this)
|
|
|
74096c |
xlator_list_t **trav_p = NULL;
|
|
|
74096c |
xlator_t *top = NULL;
|
|
|
74096c |
xlator_t *victim = NULL;
|
|
|
74096c |
+ glusterfs_graph_t *graph = NULL;
|
|
|
74096c |
+ gf_boolean_t graph_cleanup = _gf_false;
|
|
|
74096c |
|
|
|
74096c |
if (this->call_cleanup || !this->ctx)
|
|
|
74096c |
return;
|
|
|
74096c |
@@ -945,6 +947,12 @@ xlator_mem_cleanup(xlator_t *this)
|
|
|
74096c |
this->call_cleanup = 1;
|
|
|
74096c |
ctx = this->ctx;
|
|
|
74096c |
|
|
|
74096c |
+ inode_table = this->itable;
|
|
|
74096c |
+ if (inode_table) {
|
|
|
74096c |
+ inode_table_destroy(inode_table);
|
|
|
74096c |
+ this->itable = NULL;
|
|
|
74096c |
+ }
|
|
|
74096c |
+
|
|
|
74096c |
xlator_call_fini(trav);
|
|
|
74096c |
|
|
|
74096c |
while (prev) {
|
|
|
74096c |
@@ -953,12 +961,6 @@ xlator_mem_cleanup(xlator_t *this)
|
|
|
74096c |
prev = trav;
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
- inode_table = this->itable;
|
|
|
74096c |
- if (inode_table) {
|
|
|
74096c |
- inode_table_destroy(inode_table);
|
|
|
74096c |
- this->itable = NULL;
|
|
|
74096c |
- }
|
|
|
74096c |
-
|
|
|
74096c |
if (this->fini) {
|
|
|
74096c |
this->fini(this);
|
|
|
74096c |
}
|
|
|
74096c |
@@ -968,17 +970,28 @@ xlator_mem_cleanup(xlator_t *this)
|
|
|
74096c |
if (ctx->active) {
|
|
|
74096c |
top = ctx->active->first;
|
|
|
74096c |
LOCK(&ctx->volfile_lock);
|
|
|
74096c |
- /* TODO here we have leak for xlator node in a graph */
|
|
|
74096c |
- /* Need to move only top xlator from a graph */
|
|
|
74096c |
for (trav_p = &top->children; *trav_p; trav_p = &(*trav_p)->next) {
|
|
|
74096c |
victim = (*trav_p)->xlator;
|
|
|
74096c |
if (victim->call_cleanup && !strcmp(victim->name, this->name)) {
|
|
|
74096c |
+ graph_cleanup = _gf_true;
|
|
|
74096c |
(*trav_p) = (*trav_p)->next;
|
|
|
74096c |
break;
|
|
|
74096c |
}
|
|
|
74096c |
}
|
|
|
74096c |
UNLOCK(&ctx->volfile_lock);
|
|
|
74096c |
}
|
|
|
74096c |
+
|
|
|
74096c |
+ if (graph_cleanup) {
|
|
|
74096c |
+ prev = this;
|
|
|
74096c |
+ graph = ctx->active;
|
|
|
74096c |
+ pthread_mutex_lock(&graph->mutex);
|
|
|
74096c |
+ while (prev) {
|
|
|
74096c |
+ trav = prev->next;
|
|
|
74096c |
+ GF_FREE(prev);
|
|
|
74096c |
+ prev = trav;
|
|
|
74096c |
+ }
|
|
|
74096c |
+ pthread_mutex_unlock(&graph->mutex);
|
|
|
74096c |
+ }
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
void
|
|
|
74096c |
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
|
|
|
74096c |
index ff06c09..b54112c 100644
|
|
|
74096c |
--- a/xlators/features/changelog/src/changelog.c
|
|
|
74096c |
+++ b/xlators/features/changelog/src/changelog.c
|
|
|
74096c |
@@ -2872,6 +2872,7 @@ fini(xlator_t *this)
|
|
|
74096c |
if (priv->active || priv->rpc_active) {
|
|
|
74096c |
/* terminate RPC server/threads */
|
|
|
74096c |
changelog_cleanup_rpc(this, priv);
|
|
|
74096c |
+ GF_FREE(priv->ev_dispatcher);
|
|
|
74096c |
}
|
|
|
74096c |
/* call barrier_disable to cancel timer */
|
|
|
74096c |
if (priv->barrier_enabled)
|
|
|
74096c |
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
|
|
|
74096c |
index 9a14c64..50f1265 100644
|
|
|
74096c |
--- a/xlators/features/locks/src/posix.c
|
|
|
74096c |
+++ b/xlators/features/locks/src/posix.c
|
|
|
74096c |
@@ -4102,6 +4102,10 @@ fini(xlator_t *this)
|
|
|
74096c |
if (!priv)
|
|
|
74096c |
return;
|
|
|
74096c |
this->private = NULL;
|
|
|
74096c |
+ if (this->local_pool) {
|
|
|
74096c |
+ mem_pool_destroy(this->local_pool);
|
|
|
74096c |
+ this->local_pool = NULL;
|
|
|
74096c |
+ }
|
|
|
74096c |
GF_FREE(priv->brickname);
|
|
|
74096c |
GF_FREE(priv);
|
|
|
74096c |
|
|
|
74096c |
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
|
|
|
74096c |
index 1a4c2e3..097439d 100644
|
|
|
74096c |
--- a/xlators/features/quota/src/quota-enforcer-client.c
|
|
|
74096c |
+++ b/xlators/features/quota/src/quota-enforcer-client.c
|
|
|
74096c |
@@ -362,16 +362,28 @@ quota_enforcer_notify(struct rpc_clnt *rpc, void *mydata,
|
|
|
74096c |
{
|
|
|
74096c |
xlator_t *this = NULL;
|
|
|
74096c |
int ret = 0;
|
|
|
74096c |
+ quota_priv_t *priv = NULL;
|
|
|
74096c |
|
|
|
74096c |
this = mydata;
|
|
|
74096c |
-
|
|
|
74096c |
+ priv = this->private;
|
|
|
74096c |
switch (event) {
|
|
|
74096c |
case RPC_CLNT_CONNECT: {
|
|
|
74096c |
+ pthread_mutex_lock(&priv->conn_mutex);
|
|
|
74096c |
+ {
|
|
|
74096c |
+ priv->conn_status = _gf_true;
|
|
|
74096c |
+ }
|
|
|
74096c |
+ pthread_mutex_unlock(&priv->conn_mutex);
|
|
|
74096c |
gf_msg_trace(this->name, 0, "got RPC_CLNT_CONNECT");
|
|
|
74096c |
break;
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
case RPC_CLNT_DISCONNECT: {
|
|
|
74096c |
+ pthread_mutex_lock(&priv->conn_mutex);
|
|
|
74096c |
+ {
|
|
|
74096c |
+ priv->conn_status = _gf_false;
|
|
|
74096c |
+ pthread_cond_signal(&priv->conn_cond);
|
|
|
74096c |
+ }
|
|
|
74096c |
+ pthread_mutex_unlock(&priv->conn_mutex);
|
|
|
74096c |
gf_msg_trace(this->name, 0, "got RPC_CLNT_DISCONNECT");
|
|
|
74096c |
break;
|
|
|
74096c |
}
|
|
|
74096c |
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
|
|
|
74096c |
index a0c236d..d1123ce 100644
|
|
|
74096c |
--- a/xlators/features/quota/src/quota.c
|
|
|
74096c |
+++ b/xlators/features/quota/src/quota.c
|
|
|
74096c |
@@ -5014,6 +5014,43 @@ quota_forget(xlator_t *this, inode_t *inode)
|
|
|
74096c |
return 0;
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
+int
|
|
|
74096c |
+notify(xlator_t *this, int event, void *data, ...)
|
|
|
74096c |
+{
|
|
|
74096c |
+ quota_priv_t *priv = NULL;
|
|
|
74096c |
+ int ret = 0;
|
|
|
74096c |
+ rpc_clnt_t *rpc = NULL;
|
|
|
74096c |
+ gf_boolean_t conn_status = _gf_true;
|
|
|
74096c |
+ xlator_t *victim = data;
|
|
|
74096c |
+
|
|
|
74096c |
+ priv = this->private;
|
|
|
74096c |
+ if (!priv || !priv->is_quota_on)
|
|
|
74096c |
+ goto out;
|
|
|
74096c |
+
|
|
|
74096c |
+ if (event == GF_EVENT_PARENT_DOWN) {
|
|
|
74096c |
+ rpc = priv->rpc_clnt;
|
|
|
74096c |
+ if (rpc) {
|
|
|
74096c |
+ rpc_clnt_disable(rpc);
|
|
|
74096c |
+ pthread_mutex_lock(&priv->conn_mutex);
|
|
|
74096c |
+ {
|
|
|
74096c |
+ conn_status = priv->conn_status;
|
|
|
74096c |
+ while (conn_status) {
|
|
|
74096c |
+ (void)pthread_cond_wait(&priv->conn_cond,
|
|
|
74096c |
+ &priv->conn_mutex);
|
|
|
74096c |
+ conn_status = priv->conn_status;
|
|
|
74096c |
+ }
|
|
|
74096c |
+ }
|
|
|
74096c |
+ pthread_mutex_unlock(&priv->conn_mutex);
|
|
|
74096c |
+ gf_log(this->name, GF_LOG_INFO,
|
|
|
74096c |
+ "Notify GF_EVENT_PARENT_DOWN for brick %s", victim->name);
|
|
|
74096c |
+ }
|
|
|
74096c |
+ }
|
|
|
74096c |
+
|
|
|
74096c |
+out:
|
|
|
74096c |
+ ret = default_notify(this, event, data);
|
|
|
74096c |
+ return ret;
|
|
|
74096c |
+}
|
|
|
74096c |
+
|
|
|
74096c |
int32_t
|
|
|
74096c |
init(xlator_t *this)
|
|
|
74096c |
{
|
|
|
74096c |
@@ -5056,6 +5093,10 @@ init(xlator_t *this)
|
|
|
74096c |
goto err;
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
+ pthread_mutex_init(&priv->conn_mutex, NULL);
|
|
|
74096c |
+ pthread_cond_init(&priv->conn_cond, NULL);
|
|
|
74096c |
+ priv->conn_status = _gf_false;
|
|
|
74096c |
+
|
|
|
74096c |
if (priv->is_quota_on) {
|
|
|
74096c |
rpc = quota_enforcer_init(this, this->options);
|
|
|
74096c |
if (rpc == NULL) {
|
|
|
74096c |
@@ -5169,20 +5210,22 @@ fini(xlator_t *this)
|
|
|
74096c |
{
|
|
|
74096c |
quota_priv_t *priv = NULL;
|
|
|
74096c |
rpc_clnt_t *rpc = NULL;
|
|
|
74096c |
- int i = 0, cnt = 0;
|
|
|
74096c |
|
|
|
74096c |
priv = this->private;
|
|
|
74096c |
if (!priv)
|
|
|
74096c |
return;
|
|
|
74096c |
rpc = priv->rpc_clnt;
|
|
|
74096c |
priv->rpc_clnt = NULL;
|
|
|
74096c |
- this->private = NULL;
|
|
|
74096c |
if (rpc) {
|
|
|
74096c |
- cnt = GF_ATOMIC_GET(rpc->refcount);
|
|
|
74096c |
- for (i = 0; i < cnt; i++)
|
|
|
74096c |
- rpc_clnt_unref(rpc);
|
|
|
74096c |
+ rpc_clnt_connection_cleanup(&rpc->conn);
|
|
|
74096c |
+ rpc_clnt_unref(rpc);
|
|
|
74096c |
}
|
|
|
74096c |
+
|
|
|
74096c |
+ this->private = NULL;
|
|
|
74096c |
LOCK_DESTROY(&priv->lock);
|
|
|
74096c |
+ pthread_mutex_destroy(&priv->conn_mutex);
|
|
|
74096c |
+ pthread_cond_destroy(&priv->conn_cond);
|
|
|
74096c |
+
|
|
|
74096c |
GF_FREE(priv);
|
|
|
74096c |
if (this->local_pool) {
|
|
|
74096c |
mem_pool_destroy(this->local_pool);
|
|
|
74096c |
@@ -5314,6 +5357,7 @@ struct volume_options options[] = {
|
|
|
74096c |
xlator_api_t xlator_api = {
|
|
|
74096c |
.init = init,
|
|
|
74096c |
.fini = fini,
|
|
|
74096c |
+ .notify = notify,
|
|
|
74096c |
.reconfigure = reconfigure,
|
|
|
74096c |
.mem_acct_init = mem_acct_init,
|
|
|
74096c |
.op_version = {1}, /* Present from the initial version */
|
|
|
74096c |
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
|
|
|
74096c |
index a5a99ca..e51ffd4 100644
|
|
|
74096c |
--- a/xlators/features/quota/src/quota.h
|
|
|
74096c |
+++ b/xlators/features/quota/src/quota.h
|
|
|
74096c |
@@ -217,6 +217,9 @@ struct quota_priv {
|
|
|
74096c |
char *volume_uuid;
|
|
|
74096c |
uint64_t validation_count;
|
|
|
74096c |
int32_t quotad_conn_status;
|
|
|
74096c |
+ pthread_mutex_t conn_mutex;
|
|
|
74096c |
+ pthread_cond_t conn_cond;
|
|
|
74096c |
+ gf_boolean_t conn_status;
|
|
|
74096c |
};
|
|
|
74096c |
typedef struct quota_priv quota_priv_t;
|
|
|
74096c |
|
|
|
74096c |
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
|
|
|
74096c |
index a5f09fe..54d9c0f 100644
|
|
|
74096c |
--- a/xlators/protocol/server/src/server.c
|
|
|
74096c |
+++ b/xlators/protocol/server/src/server.c
|
|
|
74096c |
@@ -409,7 +409,13 @@ server_call_xlator_mem_cleanup(xlator_t *this, char *victim_name)
|
|
|
74096c |
|
|
|
74096c |
arg = calloc(1, sizeof(*arg));
|
|
|
74096c |
arg->this = this;
|
|
|
74096c |
- arg->victim_name = gf_strdup(victim_name);
|
|
|
74096c |
+ arg->victim_name = strdup(victim_name);
|
|
|
74096c |
+ if (!arg->victim_name) {
|
|
|
74096c |
+ gf_smsg(this->name, GF_LOG_CRITICAL, ENOMEM, LG_MSG_NO_MEMORY,
|
|
|
74096c |
+ "Memory allocation is failed");
|
|
|
74096c |
+ return;
|
|
|
74096c |
+ }
|
|
|
74096c |
+
|
|
|
74096c |
th_ret = gf_thread_create_detached(&th_id, server_graph_janitor_threads,
|
|
|
74096c |
arg, "graphjanitor");
|
|
|
74096c |
if (th_ret) {
|
|
|
74096c |
@@ -417,7 +423,7 @@ server_call_xlator_mem_cleanup(xlator_t *this, char *victim_name)
|
|
|
74096c |
"graph janitor Thread"
|
|
|
74096c |
" creation is failed for brick %s",
|
|
|
74096c |
victim_name);
|
|
|
74096c |
- GF_FREE(arg->victim_name);
|
|
|
74096c |
+ free(arg->victim_name);
|
|
|
74096c |
free(arg);
|
|
|
74096c |
}
|
|
|
74096c |
}
|
|
|
74096c |
@@ -628,7 +634,7 @@ server_graph_janitor_threads(void *data)
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
out:
|
|
|
74096c |
- GF_FREE(arg->victim_name);
|
|
|
74096c |
+ free(arg->victim_name);
|
|
|
74096c |
free(arg);
|
|
|
74096c |
return NULL;
|
|
|
74096c |
}
|
|
|
74096c |
--
|
|
|
74096c |
1.8.3.1
|
|
|
74096c |
|