233933
From e41b4a45f9f5c07ffa38582d0bb4517f6a66eaa3 Mon Sep 17 00:00:00 2001
233933
From: Soumya Koduri <skoduri@redhat.com>
233933
Date: Fri, 7 Jun 2019 19:33:07 +0530
233933
Subject: [PATCH 199/221] upcall: Avoid sending notifications for invalid
233933
 inodes
233933
233933
For nameless LOOKUPs, server creates a new inode which shall
233933
remain invalid until the fop is successfully processed post
233933
which it is linked to the inode table.
233933
233933
But incase if there is an already linked inode for that entry,
233933
it discards that newly created inode which results in upcall
233933
notification. This may result in client being bombarded with
233933
unnecessary upcalls affecting performance if the data set is huge.
233933
233933
This issue can be avoided by looking up and storing the upcall
233933
context in the original linked inode (if exists), thus saving up on
233933
those extra callbacks.
233933
233933
This is backport of below upstream fix -
233933
mainline: https://review.gluster.org/22840
233933
release-6: https://review.gluster.org/22873
233933
233933
Change-Id: I044a1737819bb40d1a049d2f53c0566e746d2a17
233933
fixes: bz#1717784
233933
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/173507
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
233933
---
233933
 xlators/features/upcall/src/upcall-internal.c | 19 ++++++++++++++++++-
233933
 1 file changed, 18 insertions(+), 1 deletion(-)
233933
233933
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
233933
index 46cf6f8..7998dd2 100644
233933
--- a/xlators/features/upcall/src/upcall-internal.c
233933
+++ b/xlators/features/upcall/src/upcall-internal.c
233933
@@ -520,6 +520,7 @@ upcall_cache_invalidate(call_frame_t *frame, xlator_t *this, client_t *client,
233933
     upcall_client_t *tmp = NULL;
233933
     upcall_inode_ctx_t *up_inode_ctx = NULL;
233933
     gf_boolean_t found = _gf_false;
233933
+    inode_t *linked_inode = NULL;
233933
 
233933
     if (!is_upcall_enabled(this))
233933
         return;
233933
@@ -532,7 +533,20 @@ upcall_cache_invalidate(call_frame_t *frame, xlator_t *this, client_t *client,
233933
         return;
233933
     }
233933
 
233933
-    if (inode)
233933
+    /* For nameless LOOKUPs, inode created shall always be
233933
+     * invalid. Hence check if there is any already linked inode.
233933
+     * If yes, update the inode_ctx of that valid inode
233933
+     */
233933
+    if (inode && (inode->ia_type == IA_INVAL) && stbuf) {
233933
+        linked_inode = inode_find(inode->table, stbuf->ia_gfid);
233933
+        if (linked_inode) {
233933
+            gf_log("upcall", GF_LOG_DEBUG,
233933
+                   "upcall_inode_ctx_get of linked inode (%p)", inode);
233933
+            up_inode_ctx = upcall_inode_ctx_get(linked_inode, this);
233933
+        }
233933
+    }
233933
+
233933
+    if (inode && !up_inode_ctx)
233933
         up_inode_ctx = upcall_inode_ctx_get(inode, this);
233933
 
233933
     if (!up_inode_ctx) {
233933
@@ -600,6 +614,9 @@ upcall_cache_invalidate(call_frame_t *frame, xlator_t *this, client_t *client,
233933
     }
233933
     pthread_mutex_unlock(&up_inode_ctx->client_list_lock);
233933
 out:
233933
+    /* release the ref from inode_find */
233933
+    if (linked_inode)
233933
+        inode_unref(linked_inode);
233933
     return;
233933
 }
233933
 
233933
-- 
233933
1.8.3.1
233933