Blob Blame History Raw
From 5c81d813c8b1f494d31d54c1ab09a3f0153ebfd4 Mon Sep 17 00:00:00 2001
From: Amar Tumballi <amarts@redhat.com>
Date: Sat, 9 Feb 2019 13:13:47 +0530
Subject: [PATCH 567/584] inode: create inode outside locked region

Only linking of inode to the table, and inserting it in
a list needs to be in locked region.

Backport of:
> Upstream-patch: https://review.gluster.org/#/c/glusterfs/+/22183/
> Updates: bz#1670031
> Change-Id: I6ea7e956b80cf2765c2233d761909c4bf9c7253c
> Signed-off-by: Amar Tumballi <amarts@redhat.com>

BUG: 1927640
Change-Id: I6ea7e956b80cf2765c2233d761909c4bf9c7253c
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244961
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 libglusterfs/src/inode.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 98f8ea6..46db04f 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -620,7 +620,7 @@ out:
 }
 
 static inode_t *
-__inode_create(inode_table_t *table)
+inode_create(inode_table_t *table)
 {
     inode_t *newi = NULL;
 
@@ -647,11 +647,7 @@ __inode_create(inode_table_t *table)
         goto out;
     }
 
-    list_add(&newi->list, &table->lru);
-    table->lru_size++;
-
 out:
-
     return newi;
 }
 
@@ -668,14 +664,16 @@ inode_new(inode_table_t *table)
         return NULL;
     }
 
-    pthread_mutex_lock(&table->lock);
-    {
-        inode = __inode_create(table);
-        if (inode != NULL) {
+    inode = inode_create(table);
+    if (inode) {
+        pthread_mutex_lock(&table->lock);
+        {
+            list_add(&inode->list, &table->lru);
+            table->lru_size++;
             __inode_ref(inode, false);
         }
+        pthread_mutex_unlock(&table->lock);
     }
-    pthread_mutex_unlock(&table->lock);
 
     return inode;
 }
@@ -1613,7 +1611,10 @@ __inode_table_init_root(inode_table_t *table)
     if (!table)
         return;
 
-    root = __inode_create(table);
+    root = inode_create(table);
+
+    list_add(&root->list, &table->lru);
+    table->lru_size++;
 
     iatt.ia_gfid[15] = 1;
     iatt.ia_ino = 1;
-- 
1.8.3.1