190130
From 40519185067d891f06818c574301ea1af4b36479 Mon Sep 17 00:00:00 2001
190130
From: Pranith Kumar K <pkarampu@redhat.com>
190130
Date: Wed, 17 Jun 2020 10:45:19 +0530
190130
Subject: [PATCH 476/478] mount/fuse: use cookies to get fuse-interrupt-record
190130
 instead of xdata
190130
190130
Problem:
190130
On executing tests/features/flock_interrupt.t the following error log
190130
appears
190130
[2020-06-16 11:51:54.631072 +0000] E
190130
[fuse-bridge.c:4791:fuse_setlk_interrupt_handler_cbk] 0-glusterfs-fuse:
190130
interrupt record not found
190130
190130
This happens because fuse-interrupt-record is never sent on the wire by
190130
getxattr fop and there is no guarantee that in the cbk it will be
190130
available in case of failures.
190130
190130
Fix:
190130
wind getxattr fop with fuse-interrupt-record as cookie and recover it
190130
in the cbk
190130
190130
Upstream:
190130
> Reviewed-on: https://review.gluster.org/24588
190130
> Fixes: #1310
190130
> Change-Id: I4cfff154321a449114fc26e9440db0f08e5c7daa
190130
> Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
190130
190130
BUG: 1821743
190130
Change-Id: If9576801654d4d743bd66ae90ca259c4d34746a7
190130
Signed-off-by: Csaba Henk <csaba@redhat.com>
190130
Reviewed-on: https://code.engineering.redhat.com/gerrit/216159
190130
Tested-by: RHGS Build Bot <nigelb@redhat.com>
190130
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
190130
---
190130
 tests/features/flock_interrupt.t     |  1 -
190130
 xlators/mount/fuse/src/fuse-bridge.c | 28 +++++++---------------------
190130
 2 files changed, 7 insertions(+), 22 deletions(-)
190130
190130
diff --git a/tests/features/flock_interrupt.t b/tests/features/flock_interrupt.t
190130
index 964a4bc..b8717e3 100644
190130
--- a/tests/features/flock_interrupt.t
190130
+++ b/tests/features/flock_interrupt.t
190130
@@ -28,6 +28,5 @@ flock $M0/testfile sleep 6 & { sleep 0.3; flock -w 2 $M0/testfile true; echo ok
190130
 EXPECT_WITHIN 4 ok cat got_lock;
190130
 
190130
 ## Finish up
190130
-sleep 7;
190130
 rm -f got_lock;
190130
 cleanup;
190130
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
190130
index f61fa39..1bddac2 100644
190130
--- a/xlators/mount/fuse/src/fuse-bridge.c
190130
+++ b/xlators/mount/fuse/src/fuse-bridge.c
190130
@@ -4768,16 +4768,8 @@ fuse_setlk_interrupt_handler_cbk(call_frame_t *frame, void *cookie,
190130
                                  int32_t op_errno, dict_t *dict, dict_t *xdata)
190130
 {
190130
     fuse_interrupt_state_t intstat = INTERRUPT_NONE;
190130
-    fuse_interrupt_record_t *fir;
190130
+    fuse_interrupt_record_t *fir = cookie;
190130
     fuse_state_t *state = NULL;
190130
-    int ret = 0;
190130
-
190130
-    ret = dict_get_bin(xdata, "fuse-interrupt-record", (void **)&fir;;
190130
-    if (ret < 0) {
190130
-        gf_log("glusterfs-fuse", GF_LOG_ERROR, "interrupt record not found");
190130
-
190130
-        goto out;
190130
-    }
190130
 
190130
     intstat = op_ret >= 0 ? INTERRUPT_HANDLED : INTERRUPT_SQUELCHED;
190130
 
190130
@@ -4789,7 +4781,6 @@ fuse_setlk_interrupt_handler_cbk(call_frame_t *frame, void *cookie,
190130
         GF_FREE(state);
190130
     }
190130
 
190130
-out:
190130
     STACK_DESTROY(frame->root);
190130
 
190130
     return 0;
190130
@@ -4827,9 +4818,10 @@ fuse_setlk_interrupt_handler(xlator_t *this, fuse_interrupt_record_t *fir)
190130
     frame->op = GF_FOP_GETXATTR;
190130
     state->name = xattr_name;
190130
 
190130
-    STACK_WIND(frame, fuse_setlk_interrupt_handler_cbk, state->active_subvol,
190130
-               state->active_subvol->fops->fgetxattr, state->fd, xattr_name,
190130
-               state->xdata);
190130
+    STACK_WIND_COOKIE(frame, fuse_setlk_interrupt_handler_cbk, fir,
190130
+                      state->active_subvol,
190130
+                      state->active_subvol->fops->fgetxattr, state->fd,
190130
+                      xattr_name, state->xdata);
190130
 
190130
     return;
190130
 
190130
@@ -4852,15 +4844,9 @@ fuse_setlk_resume(fuse_state_t *state)
190130
     fir = fuse_interrupt_record_new(state->finh, fuse_setlk_interrupt_handler);
190130
     state_clone = gf_memdup(state, sizeof(*state));
190130
     if (state_clone) {
190130
-        /*
190130
-         * Calling this allocator with fir casted to (char *) seems like
190130
-         * an abuse of this API, but in fact the API is stupid to assume
190130
-         * a (char *) argument (in the funcion it's casted to (void *)
190130
-         * anyway).
190130
-         */
190130
-        state_clone->xdata = dict_for_key_value(
190130
-            "fuse-interrupt-record", (char *)fir, sizeof(*fir), _gf_true);
190130
+        state_clone->xdata = dict_new();
190130
     }
190130
+
190130
     if (!fir || !state_clone || !state_clone->xdata) {
190130
         if (fir) {
190130
             GF_FREE(fir);
190130
-- 
190130
1.8.3.1
190130