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