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