12a457
From 6cf84c1d0686161737113ae297cb472fab93e27c Mon Sep 17 00:00:00 2001
12a457
From: Pranith Kumar K <pkarampu@redhat.com>
12a457
Date: Sat, 23 Apr 2016 05:30:08 +0530
12a457
Subject: [PATCH 093/104] cluster/afr: Fix inode-leak in data self-heal
12a457
12a457
Thanks to Olia-Kremmyda for finding the bug on github review,
12a457
https://github.com/gluster/glusterfs/commit/b8106d1127f034ffa88b5dd322c23a10e023b9b6
12a457
12a457
 >Change-Id: Ib8640ed0c331a635971d5d12052f0959c24f76a2
12a457
 >BUG: 1329773
12a457
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
12a457
 >Reviewed-on: http://review.gluster.org/14052
12a457
 >Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
 >Reviewed-by: Ravishankar N <ravishankar@redhat.com>
12a457
 >Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
12a457
12a457
BUG: 1330881
12a457
Change-Id: I9c3974cd231bed69e6babfba4d2ec42b3fe584f7
12a457
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73101
12a457
Reviewed-by: Anuradha Talur <atalur@redhat.com>
12a457
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
12a457
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
12a457
Tested-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
12a457
---
12a457
 tests/basic/afr/heal-info.t                  |   10 +++++-----
12a457
 xlators/cluster/afr/src/afr-self-heal-data.c |    2 +-
12a457
 2 files changed, 6 insertions(+), 6 deletions(-)
12a457
12a457
diff --git a/tests/basic/afr/heal-info.t b/tests/basic/afr/heal-info.t
12a457
index b4da50b..46d6500 100644
12a457
--- a/tests/basic/afr/heal-info.t
12a457
+++ b/tests/basic/afr/heal-info.t
12a457
@@ -8,14 +8,14 @@
12a457
 cleanup;
12a457
 
12a457
 function heal_info_to_file {
12a457
-        while [ -f $M0/a.txt ]; do
12a457
+        while [ -f $M0/b.txt ]; do
12a457
                 $CLI volume heal $V0 info | grep -i number | grep -v 0 >> $1
12a457
         done
12a457
 }
12a457
 
12a457
 function write_and_del_file {
12a457
         dd of=$M0/a.txt if=/dev/zero bs=1024k count=100
12a457
-        rm -f $M0/a.txt
12a457
+        rm -f $M0/b.txt
12a457
 }
12a457
 
12a457
 TEST glusterd
12a457
@@ -24,13 +24,13 @@ TEST $CLI volume create $V0 replica 2 $H0:$B0/brick{0,1}
12a457
 TEST $CLI volume set $V0 locking-scheme granular
12a457
 TEST $CLI volume start $V0
12a457
 TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
12a457
-TEST touch $M0/a.txt
12a457
+TEST touch $M0/a.txt $M0/b.txt
12a457
 write_and_del_file &
12a457
 touch $B0/f1 $B0/f2
12a457
 heal_info_to_file $B0/f1 &
12a457
 heal_info_to_file $B0/f2 &
12a457
 wait
12a457
-EXPECT "^0$" echo $(wc -l $B0/f1 | awk '{print $1}')
12a457
-EXPECT "^0$" echo $(wc -l $B0/f2 | awk '{print $1}')
12a457
+EXPECT "^$" cat $B0/f1
12a457
+EXPECT "^$" cat $B0/f2
12a457
 
12a457
 cleanup;
12a457
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
12a457
index 67bb8e6..72f6b2a 100644
12a457
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
12a457
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
12a457
@@ -814,7 +814,6 @@ afr_selfheal_data_open (xlator_t *this, inode_t *inode, fd_t **fd)
12a457
 	ret = syncop_open (this, &loc, O_RDWR|O_LARGEFILE, fd_tmp, NULL, NULL);
12a457
 	if (ret < 0) {
12a457
 		fd_unref (fd_tmp);
12a457
-                loc_wipe (&loc;;
12a457
                 goto out;
12a457
 	} else {
12a457
 		fd_bind (fd_tmp);
12a457
@@ -822,6 +821,7 @@ afr_selfheal_data_open (xlator_t *this, inode_t *inode, fd_t **fd)
12a457
 
12a457
         *fd = fd_tmp;
12a457
 out:
12a457
+        loc_wipe (&loc;;
12a457
 	return ret;
12a457
 }
12a457
 
12a457
-- 
12a457
1.7.1
12a457