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