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