summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2016-09-26 14:54:27 +0530
committerNiels de Vos <ndevos@redhat.com>2016-10-20 07:07:05 -0700
commit401aec64b1aec4215651e9d04f264a83433dd06c (patch)
treefe6263e78fe6355f8018bb30c7cddfcde1a437f9
parenta0a2e8ebd0b243dbf4d5dceb24b82e8632373040 (diff)
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) BUG: 1379710 Change-Id: I143532a8a14febc8c4aad7a18b1d9166529b30cc Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/15604 Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r--api/src/glfs-fops.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 338bd2f..0fbcde3 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -552,7 +552,6 @@ invalid_fs:
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_creat, 3.4.0);
-
off_t
pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
{
@@ -870,6 +869,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);
@@ -1185,6 +1187,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);
@@ -1369,6 +1374,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);
@@ -1620,6 +1628,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);
@@ -2476,6 +2487,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);
@@ -2561,6 +2575,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);