cead9d
From d79660ccc65f163e0d9cf91cc13a199bec04d5f1 Mon Sep 17 00:00:00 2001
cead9d
From: Xavi Hernandez Juan <xhernandez@redhat.com>
cead9d
Date: Wed, 20 May 2020 12:55:43 +0000
cead9d
Subject: [PATCH 378/379] Revert "open-behind: fix missing fd reference"
cead9d
cead9d
This reverts commit 30cbdf8c06145a0c290da42ecc0a7eae928200b7.
cead9d
cead9d
The patch is not complete because there have been some crash reports
cead9d
upstream recently after the patch was released. A new patch that should
cead9d
cover all corner cases is under review (), but it's a big change and it
cead9d
could be risky to backport it without enough testing.
cead9d
cead9d
Since there exists a workaround to avoid the problem (disable
cead9d
open-behind), for now we revert the patch.
cead9d
cead9d
Change-Id: I9cfc55623c33758cf5530b18f03c0d795b0f650b
cead9d
BUG: 1830713
cead9d
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
cead9d
Reviewed-on: https://code.engineering.redhat.com/gerrit/200952
cead9d
Tested-by: RHGS Build Bot <nigelb@redhat.com>
cead9d
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
cead9d
---
cead9d
 xlators/performance/open-behind/src/open-behind.c | 27 +++++++++--------------
cead9d
 1 file changed, 11 insertions(+), 16 deletions(-)
cead9d
cead9d
diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c
cead9d
index 14ebc12..268c717 100644
cead9d
--- a/xlators/performance/open-behind/src/open-behind.c
cead9d
+++ b/xlators/performance/open-behind/src/open-behind.c
cead9d
@@ -206,13 +206,8 @@ ob_fd_free(ob_fd_t *ob_fd)
cead9d
     if (ob_fd->xdata)
cead9d
         dict_unref(ob_fd->xdata);
cead9d
 
cead9d
-    if (ob_fd->open_frame) {
cead9d
-        /* If we sill have a frame it means that background open has never
cead9d
-         * been triggered. We need to release the pending reference. */
cead9d
-        fd_unref(ob_fd->fd);
cead9d
-
cead9d
+    if (ob_fd->open_frame)
cead9d
         STACK_DESTROY(ob_fd->open_frame->root);
cead9d
-    }
cead9d
 
cead9d
     GF_FREE(ob_fd);
cead9d
 }
cead9d
@@ -302,7 +297,6 @@ ob_wake_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
cead9d
             call_resume(stub);
cead9d
     }
cead9d
 
cead9d
-    /* The background open is completed. We can release the 'fd' reference. */
cead9d
     fd_unref(fd);
cead9d
 
cead9d
     STACK_DESTROY(frame->root);
cead9d
@@ -337,9 +331,7 @@ ob_fd_wake(xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
cead9d
     }
cead9d
 
cead9d
     if (frame) {
cead9d
-        /* We don't need to take a reference here. We already have a reference
cead9d
-         * while the open is pending. */
cead9d
-        frame->local = fd;
cead9d
+        frame->local = fd_ref(fd);
cead9d
 
cead9d
         STACK_WIND(frame, ob_wake_cbk, FIRST_CHILD(this),
cead9d
                    FIRST_CHILD(this)->fops->open, &ob_fd->loc, ob_fd->flags, fd,
cead9d
@@ -353,12 +345,15 @@ void
cead9d
 ob_inode_wake(xlator_t *this, struct list_head *ob_fds)
cead9d
 {
cead9d
     ob_fd_t *ob_fd = NULL, *tmp = NULL;
cead9d
+    fd_t *fd = NULL;
cead9d
 
cead9d
     if (!list_empty(ob_fds)) {
cead9d
         list_for_each_entry_safe(ob_fd, tmp, ob_fds, ob_fds_on_inode)
cead9d
         {
cead9d
             ob_fd_wake(this, ob_fd->fd, ob_fd);
cead9d
+            fd = ob_fd->fd;
cead9d
             ob_fd_free(ob_fd);
cead9d
+            fd_unref(fd);
cead9d
         }
cead9d
     }
cead9d
 }
cead9d
@@ -370,7 +365,7 @@ ob_fd_copy(ob_fd_t *src, ob_fd_t *dst)
cead9d
     if (!src || !dst)
cead9d
         goto out;
cead9d
 
cead9d
-    dst->fd = src->fd;
cead9d
+    dst->fd = __fd_ref(src->fd);
cead9d
     dst->loc.inode = inode_ref(src->loc.inode);
cead9d
     gf_uuid_copy(dst->loc.gfid, src->loc.gfid);
cead9d
     dst->flags = src->flags;
cead9d
@@ -514,6 +509,7 @@ ob_open_behind(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
cead9d
 
cead9d
     ob_fd->ob_inode = ob_inode;
cead9d
 
cead9d
+    /* don't do fd_ref, it'll cause leaks */
cead9d
     ob_fd->fd = fd;
cead9d
 
cead9d
     ob_fd->open_frame = copy_frame(frame);
cead9d
@@ -543,16 +539,15 @@ ob_open_behind(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
cead9d
     }
cead9d
     UNLOCK(&fd->inode->lock);
cead9d
 
cead9d
-    /* We take a reference while the background open is pending or being
cead9d
-     * processed. If we finally wind the request in the foreground, then
cead9d
-     * ob_fd_free() will take care of this additional reference. */
cead9d
-    fd_ref(fd);
cead9d
-
cead9d
     if (!open_in_progress && !unlinked) {
cead9d
+        fd_ref(fd);
cead9d
+
cead9d
         STACK_UNWIND_STRICT(open, frame, 0, 0, fd, xdata);
cead9d
 
cead9d
         if (!conf->lazy_open)
cead9d
             ob_fd_wake(this, fd, NULL);
cead9d
+
cead9d
+        fd_unref(fd);
cead9d
     } else {
cead9d
         ob_fd_free(ob_fd);
cead9d
         STACK_WIND(frame, default_open_cbk, FIRST_CHILD(this),
cead9d
-- 
cead9d
1.8.3.1
cead9d