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