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