From 3c04a91f5245708d0a148bf01cfdac1d0d59c797 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sun, 24 Apr 2016 06:31:14 +0530 Subject: statedump: Prevent (null) typestr to be printed Problem: After the commits: 7e44c783ad731856956929f6614bbe045c26ea3a - lock: use spinlock only on multicore systems a6aecae2cd8171b8538bfe5d2800bdd157380b85 - nfs: fix lock variable type we see a lot of "[global.glusterfs - usage-type (null) memusage]" in statedump because lock status is not all-zeros after init, and the memcmp to check that a datatype is never allocated is invalid. Fix: Changed if a datatype is allocated or not check based on total_allocs. Also removed setting typestr to NULL on gf_free even when num_allocs is 0. Because even that is leading to 'null' memusage string to be printed in statedump. BUG: 1329870 Change-Id: If2b01a557cbdc787625db32e276e06cee3ac46ee Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/14054 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- libglusterfs/src/mem-pool.c | 4 ---- libglusterfs/src/statedump.c | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 9a1320993d3..9533a733959 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -318,10 +318,6 @@ __gf_free (void *free_ptr) { mem_acct->rec[header->type].size -= header->size; mem_acct->rec[header->type].num_allocs--; - /* If all the instaces 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 caf228a8b01..d4e7dbb3836 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -223,7 +223,6 @@ static void gf_proc_dump_xlator_mem_info (xlator_t *xl) { int i = 0; - struct mem_acct rec = {0,}; if (!xl) return; @@ -235,8 +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 (!(memcmp (&xl->mem_acct->rec[i], &rec, - sizeof (struct mem_acct)))) + if (xl->mem_acct->rec[i].total_allocs == 0) continue; gf_proc_dump_add_section ("%s.%s - usage-type %s memusage", -- cgit