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