c460ee
From 2640ee56201d320b838909f95608abe07e3ff9b0 Mon Sep 17 00:00:00 2001
c460ee
From: mohit84 <moagrawa@redhat.com>
c460ee
Date: Tue, 24 Nov 2020 15:29:58 +0530
c460ee
Subject: [PATCH 568/584] core: tcmu-runner process continuous growing logs
c460ee
 lru_size showing -1
c460ee
c460ee
* core: tcmu-runner process continuous growing logs lru_size showing -1
c460ee
c460ee
At the time of calling inode_table_prune it checks if current lru_size
c460ee
is greater than lru_limit but lru_list is empty it throws a log message
c460ee
"Empty inode lru list found but with (%d) lru_size".As per code reading
c460ee
it seems lru_size is out of sync with the actual number of inodes in
c460ee
lru_list. Due to throwing continuous error messages entire disk is
c460ee
getting full and the user has to restart the tcmu-runner process to use
c460ee
the volumes.The log message was introduce by a patch
c460ee
https://review.gluster.org/#/c/glusterfs/+/15087/.
c460ee
c460ee
Solution: Introduce a flag in_lru_list to take decision about inode is
c460ee
          being part of lru_list or not.
c460ee
c460ee
Backport of:
c460ee
> Upstream-patch: https://github.com/gluster/glusterfs/pull/1776
c460ee
> Fixes: #1775
c460ee
> Change-Id: I4b836bebf4b5db65fbf88ff41c6c88f4a7ac55c1
c460ee
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
c460ee
c460ee
BUG: 1927640
c460ee
Change-Id: I4b836bebf4b5db65fbf88ff41c6c88f4a7ac55c1
c460ee
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
c460ee
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244962
c460ee
Tested-by: RHGS Build Bot <nigelb@redhat.com>
c460ee
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
c460ee
---
c460ee
 libglusterfs/src/glusterfs/inode.h |  1 +
c460ee
 libglusterfs/src/inode.c           | 14 ++++++++++++++
c460ee
 2 files changed, 15 insertions(+)
c460ee
c460ee
diff --git a/libglusterfs/src/glusterfs/inode.h b/libglusterfs/src/glusterfs/inode.h
c460ee
index 62c093d..17d0340 100644
c460ee
--- a/libglusterfs/src/glusterfs/inode.h
c460ee
+++ b/libglusterfs/src/glusterfs/inode.h
c460ee
@@ -110,6 +110,7 @@ struct _inode {
c460ee
     struct _inode_ctx *_ctx; /* replacement for dict_t *(inode->ctx) */
c460ee
     bool in_invalidate_list; /* Set if inode is in table invalidate list */
c460ee
     bool invalidate_sent;    /* Set it if invalidator_fn is called for inode */
c460ee
+    bool in_lru_list;        /* Set if inode is in table lru list */
c460ee
 };
c460ee
 
c460ee
 #define UUID0_STR "00000000-0000-0000-0000-000000000000"
c460ee
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
c460ee
index 46db04f..8e91197 100644
c460ee
--- a/libglusterfs/src/inode.c
c460ee
+++ b/libglusterfs/src/inode.c
c460ee
@@ -417,8 +417,10 @@ __inode_passivate(inode_t *inode)
c460ee
     dentry_t *dentry = NULL;
c460ee
     dentry_t *t = NULL;
c460ee
 
c460ee
+    GF_ASSERT(!inode->in_lru_list);
c460ee
     list_move_tail(&inode->list, &inode->table->lru);
c460ee
     inode->table->lru_size++;
c460ee
+    inode->in_lru_list = _gf_true;
c460ee
 
c460ee
     list_for_each_entry_safe(dentry, t, &inode->dentry_list, inode_list)
c460ee
     {
c460ee
@@ -531,7 +533,10 @@ __inode_ref(inode_t *inode, bool is_invalidate)
c460ee
             inode->in_invalidate_list = false;
c460ee
             inode->table->invalidate_size--;
c460ee
         } else {
c460ee
+            GF_ASSERT(inode->table->lru_size > 0);
c460ee
+            GF_ASSERT(inode->in_lru_list);
c460ee
             inode->table->lru_size--;
c460ee
+            inode->in_lru_list = _gf_false;
c460ee
         }
c460ee
         if (is_invalidate) {
c460ee
             inode->in_invalidate_list = true;
c460ee
@@ -670,6 +675,8 @@ inode_new(inode_table_t *table)
c460ee
         {
c460ee
             list_add(&inode->list, &table->lru);
c460ee
             table->lru_size++;
c460ee
+            GF_ASSERT(!inode->in_lru_list);
c460ee
+            inode->in_lru_list = _gf_true;
c460ee
             __inode_ref(inode, false);
c460ee
         }
c460ee
         pthread_mutex_unlock(&table->lock);
c460ee
@@ -1533,6 +1540,7 @@ inode_table_prune(inode_table_t *table)
c460ee
         lru_size = table->lru_size;
c460ee
         while (lru_size > (table->lru_limit)) {
c460ee
             if (list_empty(&table->lru)) {
c460ee
+                GF_ASSERT(0);
c460ee
                 gf_msg_callingfn(THIS->name, GF_LOG_WARNING, 0,
c460ee
                                  LG_MSG_INVALID_INODE_LIST,
c460ee
                                  "Empty inode lru list found"
c460ee
@@ -1543,6 +1551,7 @@ inode_table_prune(inode_table_t *table)
c460ee
 
c460ee
             lru_size--;
c460ee
             entry = list_entry(table->lru.next, inode_t, list);
c460ee
+            GF_ASSERT(entry->in_lru_list);
c460ee
             /* The logic of invalidation is required only if invalidator_fn
c460ee
                is present */
c460ee
             if (table->invalidator_fn) {
c460ee
@@ -1560,6 +1569,7 @@ inode_table_prune(inode_table_t *table)
c460ee
             }
c460ee
 
c460ee
             table->lru_size--;
c460ee
+            entry->in_lru_list = _gf_false;
c460ee
             __inode_retire(entry);
c460ee
             ret++;
c460ee
         }
c460ee
@@ -1615,6 +1625,7 @@ __inode_table_init_root(inode_table_t *table)
c460ee
 
c460ee
     list_add(&root->list, &table->lru);
c460ee
     table->lru_size++;
c460ee
+    root->in_lru_list = _gf_true;
c460ee
 
c460ee
     iatt.ia_gfid[15] = 1;
c460ee
     iatt.ia_ino = 1;
c460ee
@@ -1873,8 +1884,11 @@ inode_table_destroy(inode_table_t *inode_table)
c460ee
         while (!list_empty(&inode_table->lru)) {
c460ee
             trav = list_first_entry(&inode_table->lru, inode_t, list);
c460ee
             inode_forget_atomic(trav, 0);
c460ee
+            GF_ASSERT(inode_table->lru_size > 0);
c460ee
+            GF_ASSERT(trav->in_lru_list);
c460ee
             __inode_retire(trav);
c460ee
             inode_table->lru_size--;
c460ee
+            trav->in_lru_list = _gf_false;
c460ee
         }
c460ee
 
c460ee
         /* Same logic for invalidate list */
c460ee
-- 
c460ee
1.8.3.1
c460ee