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