summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2016-05-31 16:44:48 +0530
committerNiels de Vos <ndevos@redhat.com>2016-08-07 04:53:48 -0700
commitffc67d3fc64a016e9900bdb8b5fed5866850a1d8 (patch)
treead79af06345f32e958fa4d8e6789537616954d7a
parent2c748b731f233588b97d375ce92a5ae56612d764 (diff)
libglusterfs: fix glusterd statedump crash
Backport of http://review.gluster.org/14987 commit 3c04a91 removed setting typeStr to NULL if num_allocs is set to 0, this has caused this regression. Code has been put back like earlier and to avoid statedump printing all the NULL values check is modified to see skip the records if num_allocs is 0 instead of total_allocs >Reviewed-on: http://review.gluster.org/14987 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> >Smoke: Gluster Build System <jenkins@build.gluster.org> >CentOS-regression: Gluster Build System <jenkins@build.gluster.org> >Reviewed-by: N Balachandran <nbalacha@redhat.com> >Reviewed-by: Prashanth Pai <ppai@redhat.com> >Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Change-Id: Ib8bcc2fba908e88cf52b641c3f6bcba74f5e667c BUG: 1364329 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: http://review.gluster.org/15091 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--libglusterfs/src/mem-pool.c4
-rw-r--r--libglusterfs/src/statedump.c2
-rwxr-xr-xtests/bugs/core/bug-834465.t7
3 files changed, 11 insertions, 2 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 9533a733959..93a1415a75a 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -318,6 +318,10 @@ __gf_free (void *free_ptr)
{
mem_acct->rec[header->type].size -= header->size;
mem_acct->rec[header->type].num_allocs--;
+ /* If all the instances are freed up then ensure typestr is set
+ * to NULL */
+ if (!mem_acct->rec[header->type].num_allocs)
+ mem_acct->rec[header->type].typestr = NULL;
}
UNLOCK (&mem_acct->rec[header->type].lock);
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index d4e7dbb3836..a292857fd10 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -234,7 +234,7 @@ gf_proc_dump_xlator_mem_info (xlator_t *xl)
gf_proc_dump_write ("num_types", "%d", xl->mem_acct->num_types);
for (i = 0; i < xl->mem_acct->num_types; i++) {
- if (xl->mem_acct->rec[i].total_allocs == 0)
+ if (xl->mem_acct->rec[i].num_allocs == 0)
continue;
gf_proc_dump_add_section ("%s.%s - usage-type %s memusage",
diff --git a/tests/bugs/core/bug-834465.t b/tests/bugs/core/bug-834465.t
index e21e95393a6..996248d4116 100755
--- a/tests/bugs/core/bug-834465.t
+++ b/tests/bugs/core/bug-834465.t
@@ -33,8 +33,13 @@ build_tester $(dirname $0)/bug-834465.c
TEST $(dirname $0)/bug-834465 $M0/testfile
sdump2=$(generate_mount_statedump $V0);
+nalloc2=0
+grep -A3 "fuse - usage-type gf_common_mt_fd_lk_ctx_node_t" $sdump2
+if [ $? -eq '0' ]
+then
+ nalloc2=`grep -A3 "fuse - usage-type gf_common_mt_fd_lk_ctx_node_t" $sdump2 | grep -E "^num_allocs" | cut -d '=' -f2`
+fi
-nalloc2=`grep -A3 "fuse - usage-type gf_common_mt_fd_lk_ctx_node_t" $sdump2 | grep -E "^num_allocs" | cut -d '=' -f2`
TEST [ $nalloc1 -eq $nalloc2 ];
TEST rm -rf $MOUNTDIR/*