d2787b
From 36dddf59a02d91d3db5b124be626ab6bc235ed5a Mon Sep 17 00:00:00 2001
d2787b
From: Xavi Hernandez <xhernandez@redhat.com>
d2787b
Date: Wed, 19 Aug 2020 23:27:38 +0200
d2787b
Subject: [PATCH 524/526] open-behind: fix call_frame leak
d2787b
d2787b
When an open was delayed, a copy of the frame was created because the
d2787b
current frame was used to unwind the "fake" open. When the open was
d2787b
actually sent, the frame was correctly destroyed. However if the file
d2787b
was closed before needing to send the open, the frame was not destroyed.
d2787b
d2787b
This patch correctly destroys the frame in all cases.
d2787b
d2787b
Upstream patch:
d2787b
> Upstream-patch-link: https://review.gluster.org/#/c/glusterfs/+/24892
d2787b
> Change-Id: I8c00fc7f15545c240e8151305d9e4cf06d653926
d2787b
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
d2787b
> Fixes: #1440
d2787b
d2787b
BUG: 1830713
d2787b
Change-Id: I8c00fc7f15545c240e8151305d9e4cf06d653926
d2787b
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/224488
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/performance/open-behind/src/open-behind.c | 14 ++++++++++----
d2787b
 1 file changed, 10 insertions(+), 4 deletions(-)
d2787b
d2787b
diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c
d2787b
index e43fe73..1ab635e 100644
d2787b
--- a/xlators/performance/open-behind/src/open-behind.c
d2787b
+++ b/xlators/performance/open-behind/src/open-behind.c
d2787b
@@ -333,6 +333,14 @@ ob_stub_dispatch(xlator_t *xl, ob_inode_t *ob_inode, fd_t *fd,
d2787b
     return 0;
d2787b
 }
d2787b
 
d2787b
+static void
d2787b
+ob_open_destroy(call_stub_t *stub, fd_t *fd)
d2787b
+{
d2787b
+    STACK_DESTROY(stub->frame->root);
d2787b
+    call_stub_destroy(stub);
d2787b
+    fd_unref(fd);
d2787b
+}
d2787b
+
d2787b
 static int32_t
d2787b
 ob_open_dispatch(xlator_t *xl, ob_inode_t *ob_inode, fd_t *fd,
d2787b
                  call_stub_t *stub)
d2787b
@@ -355,8 +363,7 @@ ob_open_dispatch(xlator_t *xl, ob_inode_t *ob_inode, fd_t *fd,
d2787b
 
d2787b
     if (stub != NULL) {
d2787b
         if (closed) {
d2787b
-            call_stub_destroy(stub);
d2787b
-            fd_unref(fd);
d2787b
+            ob_open_destroy(stub, fd);
d2787b
         } else {
d2787b
             call_resume(stub);
d2787b
         }
d2787b
@@ -776,8 +783,7 @@ ob_fdclose(xlator_t *this, fd_t *fd)
d2787b
     UNLOCK(&fd->inode->lock);
d2787b
 
d2787b
     if (stub != NULL) {
d2787b
-        call_stub_destroy(stub);
d2787b
-        fd_unref(fd);
d2787b
+        ob_open_destroy(stub, fd);
d2787b
     }
d2787b
 
d2787b
     ob_resume_pending(&list);
d2787b
-- 
d2787b
1.8.3.1
d2787b