Blob Blame History Raw
From 2640ee56201d320b838909f95608abe07e3ff9b0 Mon Sep 17 00:00:00 2001
From: mohit84 <moagrawa@redhat.com>
Date: Tue, 24 Nov 2020 15:29:58 +0530
Subject: [PATCH 568/584] core: tcmu-runner process continuous growing logs
 lru_size showing -1

* core: tcmu-runner process continuous growing logs lru_size showing -1

At the time of calling inode_table_prune it checks if current lru_size
is greater than lru_limit but lru_list is empty it throws a log message
"Empty inode lru list found but with (%d) lru_size".As per code reading
it seems lru_size is out of sync with the actual number of inodes in
lru_list. Due to throwing continuous error messages entire disk is
getting full and the user has to restart the tcmu-runner process to use
the volumes.The log message was introduce by a patch
https://review.gluster.org/#/c/glusterfs/+/15087/.

Solution: Introduce a flag in_lru_list to take decision about inode is
          being part of lru_list or not.

Backport of:
> Upstream-patch: https://github.com/gluster/glusterfs/pull/1776
> Fixes: #1775
> Change-Id: I4b836bebf4b5db65fbf88ff41c6c88f4a7ac55c1
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

BUG: 1927640
Change-Id: I4b836bebf4b5db65fbf88ff41c6c88f4a7ac55c1
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244962
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 libglusterfs/src/glusterfs/inode.h |  1 +
 libglusterfs/src/inode.c           | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/libglusterfs/src/glusterfs/inode.h b/libglusterfs/src/glusterfs/inode.h
index 62c093d..17d0340 100644
--- a/libglusterfs/src/glusterfs/inode.h
+++ b/libglusterfs/src/glusterfs/inode.h
@@ -110,6 +110,7 @@ struct _inode {
     struct _inode_ctx *_ctx; /* replacement for dict_t *(inode->ctx) */
     bool in_invalidate_list; /* Set if inode is in table invalidate list */
     bool invalidate_sent;    /* Set it if invalidator_fn is called for inode */
+    bool in_lru_list;        /* Set if inode is in table lru list */
 };
 
 #define UUID0_STR "00000000-0000-0000-0000-000000000000"
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 46db04f..8e91197 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -417,8 +417,10 @@ __inode_passivate(inode_t *inode)
     dentry_t *dentry = NULL;
     dentry_t *t = NULL;
 
+    GF_ASSERT(!inode->in_lru_list);
     list_move_tail(&inode->list, &inode->table->lru);
     inode->table->lru_size++;
+    inode->in_lru_list = _gf_true;
 
     list_for_each_entry_safe(dentry, t, &inode->dentry_list, inode_list)
     {
@@ -531,7 +533,10 @@ __inode_ref(inode_t *inode, bool is_invalidate)
             inode->in_invalidate_list = false;
             inode->table->invalidate_size--;
         } else {
+            GF_ASSERT(inode->table->lru_size > 0);
+            GF_ASSERT(inode->in_lru_list);
             inode->table->lru_size--;
+            inode->in_lru_list = _gf_false;
         }
         if (is_invalidate) {
             inode->in_invalidate_list = true;
@@ -670,6 +675,8 @@ inode_new(inode_table_t *table)
         {
             list_add(&inode->list, &table->lru);
             table->lru_size++;
+            GF_ASSERT(!inode->in_lru_list);
+            inode->in_lru_list = _gf_true;
             __inode_ref(inode, false);
         }
         pthread_mutex_unlock(&table->lock);
@@ -1533,6 +1540,7 @@ inode_table_prune(inode_table_t *table)
         lru_size = table->lru_size;
         while (lru_size > (table->lru_limit)) {
             if (list_empty(&table->lru)) {
+                GF_ASSERT(0);
                 gf_msg_callingfn(THIS->name, GF_LOG_WARNING, 0,
                                  LG_MSG_INVALID_INODE_LIST,
                                  "Empty inode lru list found"
@@ -1543,6 +1551,7 @@ inode_table_prune(inode_table_t *table)
 
             lru_size--;
             entry = list_entry(table->lru.next, inode_t, list);
+            GF_ASSERT(entry->in_lru_list);
             /* The logic of invalidation is required only if invalidator_fn
                is present */
             if (table->invalidator_fn) {
@@ -1560,6 +1569,7 @@ inode_table_prune(inode_table_t *table)
             }
 
             table->lru_size--;
+            entry->in_lru_list = _gf_false;
             __inode_retire(entry);
             ret++;
         }
@@ -1615,6 +1625,7 @@ __inode_table_init_root(inode_table_t *table)
 
     list_add(&root->list, &table->lru);
     table->lru_size++;
+    root->in_lru_list = _gf_true;
 
     iatt.ia_gfid[15] = 1;
     iatt.ia_ino = 1;
@@ -1873,8 +1884,11 @@ inode_table_destroy(inode_table_t *inode_table)
         while (!list_empty(&inode_table->lru)) {
             trav = list_first_entry(&inode_table->lru, inode_t, list);
             inode_forget_atomic(trav, 0);
+            GF_ASSERT(inode_table->lru_size > 0);
+            GF_ASSERT(trav->in_lru_list);
             __inode_retire(trav);
             inode_table->lru_size--;
+            trav->in_lru_list = _gf_false;
         }
 
         /* Same logic for invalidate list */
-- 
1.8.3.1