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