50dc83
From 416dfc70ef87400e1ddfd70e5b6e512d330b54a6 Mon Sep 17 00:00:00 2001
50dc83
From: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
50dc83
Date: Tue, 2 Apr 2019 23:25:11 +0530
50dc83
Subject: [PATCH 43/52] inode: don't dump the whole table to CLI
50dc83
50dc83
dumping the whole inode table detail to screen doesn't solve any
50dc83
purpose. We should be getting only toplevel details on CLI, and
50dc83
then if one wants to debug further, then they need to get to
50dc83
'statedump' to get full details.
50dc83
50dc83
Patch on upstream master: https://review.gluster.org/#/c/glusterfs/+/22347/
50dc83
50dc83
BUG: 1578703
50dc83
Change-Id: Ie7e7f5a67c1606e3c18ce21ee6df6c7e4550c211
50dc83
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/166768
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
50dc83
---
50dc83
 cli/src/cli-rpc-ops.c    | 23 ++++++++++++++++++++++-
50dc83
 libglusterfs/src/inode.c | 13 +++++++++++++
50dc83
 2 files changed, 35 insertions(+), 1 deletion(-)
50dc83
50dc83
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
50dc83
index 78043cd..12e7fcc 100644
50dc83
--- a/cli/src/cli-rpc-ops.c
50dc83
+++ b/cli/src/cli-rpc-ops.c
50dc83
@@ -7606,15 +7606,24 @@ cli_print_volume_status_itables(dict_t *dict, char *prefix)
50dc83
     uint32_t active_size = 0;
50dc83
     uint32_t lru_size = 0;
50dc83
     uint32_t purge_size = 0;
50dc83
+    uint32_t lru_limit = 0;
50dc83
     int i = 0;
50dc83
 
50dc83
     GF_ASSERT(dict);
50dc83
     GF_ASSERT(prefix);
50dc83
 
50dc83
+    snprintf(key, sizeof(key), "%s.lru_limit", prefix);
50dc83
+    ret = dict_get_uint32(dict, key, &lru_limit);
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+    cli_out("LRU limit     : %u", lru_limit);
50dc83
+
50dc83
     snprintf(key, sizeof(key), "%s.active_size", prefix);
50dc83
     ret = dict_get_uint32(dict, key, &active_size);
50dc83
     if (ret)
50dc83
         goto out;
50dc83
+
50dc83
+#ifdef DEBUG
50dc83
     if (active_size != 0) {
50dc83
         cli_out("Active inodes:");
50dc83
         cli_out("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref", "IA type");
50dc83
@@ -7626,10 +7635,16 @@ cli_print_volume_status_itables(dict_t *dict, char *prefix)
50dc83
     }
50dc83
     cli_out(" ");
50dc83
 
50dc83
+#else
50dc83
+    cli_out("Active Inodes : %u", active_size);
50dc83
+
50dc83
+#endif
50dc83
     snprintf(key, sizeof(key), "%s.lru_size", prefix);
50dc83
     ret = dict_get_uint32(dict, key, &lru_size);
50dc83
     if (ret)
50dc83
         goto out;
50dc83
+
50dc83
+#ifdef DEBUG
50dc83
     if (lru_size != 0) {
50dc83
         cli_out("LRU inodes:");
50dc83
         cli_out("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref", "IA type");
50dc83
@@ -7640,11 +7655,15 @@ cli_print_volume_status_itables(dict_t *dict, char *prefix)
50dc83
         cli_print_volume_status_inode_entry(dict, key);
50dc83
     }
50dc83
     cli_out(" ");
50dc83
+#else
50dc83
+    cli_out("LRU Inodes    : %u", lru_size);
50dc83
+#endif
50dc83
 
50dc83
     snprintf(key, sizeof(key), "%s.purge_size", prefix);
50dc83
     ret = dict_get_uint32(dict, key, &purge_size);
50dc83
     if (ret)
50dc83
         goto out;
50dc83
+#ifdef DEBUG
50dc83
     if (purge_size != 0) {
50dc83
         cli_out("Purged inodes:");
50dc83
         cli_out("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref", "IA type");
50dc83
@@ -7654,7 +7673,9 @@ cli_print_volume_status_itables(dict_t *dict, char *prefix)
50dc83
         snprintf(key, sizeof(key), "%s.purge%d", prefix, i);
50dc83
         cli_print_volume_status_inode_entry(dict, key);
50dc83
     }
50dc83
-
50dc83
+#else
50dc83
+    cli_out("Purge Inodes  : %u", purge_size);
50dc83
+#endif
50dc83
 out:
50dc83
     return;
50dc83
 }
50dc83
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
50dc83
index 87f74e0..96ddea5 100644
50dc83
--- a/libglusterfs/src/inode.c
50dc83
+++ b/libglusterfs/src/inode.c
50dc83
@@ -2598,6 +2598,11 @@ inode_table_dump_to_dict(inode_table_t *itable, char *prefix, dict_t *dict)
50dc83
     if (ret)
50dc83
         return;
50dc83
 
50dc83
+    snprintf(key, sizeof(key), "%s.itable.lru_limit", prefix);
50dc83
+    ret = dict_set_uint32(dict, key, itable->lru_limit);
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
     snprintf(key, sizeof(key), "%s.itable.active_size", prefix);
50dc83
     ret = dict_set_uint32(dict, key, itable->active_size);
50dc83
     if (ret)
50dc83
@@ -2613,6 +2618,13 @@ inode_table_dump_to_dict(inode_table_t *itable, char *prefix, dict_t *dict)
50dc83
     if (ret)
50dc83
         goto out;
50dc83
 
50dc83
+#ifdef DEBUG
50dc83
+    /* Dumping inode details in dictionary and sending it to CLI is not
50dc83
+       required as when a developer (or support team) asks for this command
50dc83
+       output, they just want to get top level detail of inode table.
50dc83
+       If one wants to debug, let them take statedump and debug, this
50dc83
+       wouldn't be available in CLI during production setup.
50dc83
+    */
50dc83
     list_for_each_entry(inode, &itable->active, list)
50dc83
     {
50dc83
         snprintf(key, sizeof(key), "%s.itable.active%d", prefix, count++);
50dc83
@@ -2632,6 +2644,7 @@ inode_table_dump_to_dict(inode_table_t *itable, char *prefix, dict_t *dict)
50dc83
         snprintf(key, sizeof(key), "%s.itable.purge%d", prefix, count++);
50dc83
         inode_dump_to_dict(inode, key, dict);
50dc83
     }
50dc83
+#endif
50dc83
 
50dc83
 out:
50dc83
     pthread_mutex_unlock(&itable->lock);
50dc83
-- 
50dc83
1.8.3.1
50dc83