c460ee
From 5c81d813c8b1f494d31d54c1ab09a3f0153ebfd4 Mon Sep 17 00:00:00 2001
c460ee
From: Amar Tumballi <amarts@redhat.com>
c460ee
Date: Sat, 9 Feb 2019 13:13:47 +0530
c460ee
Subject: [PATCH 567/584] inode: create inode outside locked region
c460ee
c460ee
Only linking of inode to the table, and inserting it in
c460ee
a list needs to be in locked region.
c460ee
c460ee
Backport of:
c460ee
> Upstream-patch: https://review.gluster.org/#/c/glusterfs/+/22183/
c460ee
> Updates: bz#1670031
c460ee
> Change-Id: I6ea7e956b80cf2765c2233d761909c4bf9c7253c
c460ee
> Signed-off-by: Amar Tumballi <amarts@redhat.com>
c460ee
c460ee
BUG: 1927640
c460ee
Change-Id: I6ea7e956b80cf2765c2233d761909c4bf9c7253c
c460ee
Signed-off-by: Amar Tumballi <amarts@redhat.com>
c460ee
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244961
c460ee
Tested-by: RHGS Build Bot <nigelb@redhat.com>
c460ee
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
c460ee
---
c460ee
 libglusterfs/src/inode.c | 23 ++++++++++++-----------
c460ee
 1 file changed, 12 insertions(+), 11 deletions(-)
c460ee
c460ee
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
c460ee
index 98f8ea6..46db04f 100644
c460ee
--- a/libglusterfs/src/inode.c
c460ee
+++ b/libglusterfs/src/inode.c
c460ee
@@ -620,7 +620,7 @@ out:
c460ee
 }
c460ee
 
c460ee
 static inode_t *
c460ee
-__inode_create(inode_table_t *table)
c460ee
+inode_create(inode_table_t *table)
c460ee
 {
c460ee
     inode_t *newi = NULL;
c460ee
 
c460ee
@@ -647,11 +647,7 @@ __inode_create(inode_table_t *table)
c460ee
         goto out;
c460ee
     }
c460ee
 
c460ee
-    list_add(&newi->list, &table->lru);
c460ee
-    table->lru_size++;
c460ee
-
c460ee
 out:
c460ee
-
c460ee
     return newi;
c460ee
 }
c460ee
 
c460ee
@@ -668,14 +664,16 @@ inode_new(inode_table_t *table)
c460ee
         return NULL;
c460ee
     }
c460ee
 
c460ee
-    pthread_mutex_lock(&table->lock);
c460ee
-    {
c460ee
-        inode = __inode_create(table);
c460ee
-        if (inode != NULL) {
c460ee
+    inode = inode_create(table);
c460ee
+    if (inode) {
c460ee
+        pthread_mutex_lock(&table->lock);
c460ee
+        {
c460ee
+            list_add(&inode->list, &table->lru);
c460ee
+            table->lru_size++;
c460ee
             __inode_ref(inode, false);
c460ee
         }
c460ee
+        pthread_mutex_unlock(&table->lock);
c460ee
     }
c460ee
-    pthread_mutex_unlock(&table->lock);
c460ee
 
c460ee
     return inode;
c460ee
 }
c460ee
@@ -1613,7 +1611,10 @@ __inode_table_init_root(inode_table_t *table)
c460ee
     if (!table)
c460ee
         return;
c460ee
 
c460ee
-    root = __inode_create(table);
c460ee
+    root = inode_create(table);
c460ee
+
c460ee
+    list_add(&root->list, &table->lru);
c460ee
+    table->lru_size++;
c460ee
 
c460ee
     iatt.ia_gfid[15] = 1;
c460ee
     iatt.ia_ino = 1;
c460ee
-- 
c460ee
1.8.3.1
c460ee