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