Blob Blame History Raw
From 16490747ddee6f2233665856ffc8108ccfc78f99 Mon Sep 17 00:00:00 2001
From: Soumya Koduri <skoduri@redhat.com>
Date: Mon, 26 Sep 2016 14:54:27 +0530
Subject: [PATCH 095/141] gfapi: Fix few fd ref leaks

From the code inspection, have observed that there are fd ref
leaks for few fd-based gfapi fops. 'glfs_resolve_fd' returns
a fd (either existing or migrated) with an extra ref taken.
This needs to be unref'ed at the end of the operation.

Mainline reference:
> Change-Id: Id63394e3e7deafb0c8b06444f2ae847248b126db
> BUG: 1379285
> Signed-off-by: Soumya Koduri <skoduri@redhat.com>
> Reviewed-on: http://review.gluster.org/15573
> Reviewed-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit d27cffab670858d7812bbb458a0833303d009b3b)

upstream release-3.8 reference:
> Change-Id: I0919abbddb618d08aaf77b2ce1173eec18b382f1
> BUG: 1379708
> Signed-off-by: Soumya Koduri <skoduri@redhat.com>
> Reviewed-on: http://review.gluster.org/15585
> Reviewed-by: Niels de Vos <ndevos@redhat.com>

BUG: 1379924
Change-Id: I3953a3cfa9b220e95bc07c6816a410030147e0ef
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/86107
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 api/src/glfs-fops.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 9c31502..bbbf61d 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -601,6 +601,9 @@ glfs_seek (struct glfs_fd *glfd, off_t offset, int whence)
                 glfd->offset = off;
 
 done:
+        if (fd)
+                fd_unref (fd);
+
         glfs_subvol_done (glfd->fs, subvol);
 
 out:
@@ -931,6 +934,9 @@ pub_glfs_preadv_async (struct glfs_fd *glfd, const struct iovec *iovec,
 			   offset, flags, NULL);
 
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
@@ -1246,6 +1252,9 @@ pub_glfs_pwritev_async (struct glfs_fd *glfd, const struct iovec *iovec,
 
         ret = 0;
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
@@ -1430,6 +1439,9 @@ glfs_fsync_async_common (struct glfs_fd *glfd, glfs_io_cbk fn, void *data,
                            subvol->fops->fsync, fd, dataonly, NULL);
 
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
@@ -1681,6 +1693,9 @@ pub_glfs_ftruncate_async (struct glfs_fd *glfd, off_t offset, glfs_io_cbk fn,
         ret = 0;
 
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
@@ -2537,6 +2552,9 @@ pub_glfs_discard_async (struct glfs_fd *glfd, off_t offset, size_t len,
 
         ret = 0;
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
@@ -2622,6 +2640,9 @@ pub_glfs_zerofill_async (struct glfs_fd *glfd, off_t offset, off_t len,
                            subvol->fops->zerofill, fd, offset, len, NULL);
         ret = 0;
 out:
+        if (fd)
+                fd_unref (fd);
+
         if (ret) {
                 if (glfd)
                         GF_REF_PUT (glfd);
-- 
1.7.1