summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-rebalance.c
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2016-01-11 12:55:03 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-01-24 18:28:22 -0800
commit4e9ef2cc5ca8f5568bfb6328a756f4a824f69639 (patch)
treed8f7348737cd905fb47df3eb832fbde98c5d5a9b /xlators/cluster/dht/src/dht-rebalance.c
parentf3426ccc95133f8b5c946f98867090c636305d6e (diff)
cluster/dht : Rebalance process crashes due to double fd_unref
The dst_fd was being unrefed twice in case the call to __dht_rebalance_create_dst_file failed. > BUG: 1296611 > Signed-off-by: N Balachandran <nbalacha@redhat.com> > Reviewed-on: http://review.gluster.org/13193 > Reviewed-by: Susant Palai <spalai@redhat.com> > Reviewed-by: Raghavendra G <rgowdapp@redhat.com> > Tested-by: Raghavendra G <rgowdapp@redhat.com> (cherry picked from commit 36fcaf275952202ce3f1e621d3b3a34d58054c99) Change-Id: I56c5aff7fa3827887e67936b8aa1ecbd1a08a9e9 BUG: 1297309 Signed-off-by: N Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/13212 Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/cluster/dht/src/dht-rebalance.c')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index a9fceb366f0..3698b340fef 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -519,7 +519,7 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
DHT_MSG_GFID_MISMATCH,
"file %s exists in %s with different gfid",
loc->path, to->name);
- fd_unref (fd);
+ ret = -1;
goto out;
}
}
@@ -563,8 +563,7 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
}
fd_bind (fd);
- if (dst_fd)
- *dst_fd = fd;
+
/*Reason of doing lookup after create again:
*In the create, there is some time-gap between opening fd at the
*server (posix_layer) and binding it in server (incrementing fd count),
@@ -575,7 +574,6 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
*at the backend.
*/
-
ret = syncop_lookup (to, loc, &check_stbuf, NULL, NULL, NULL);
if (!ret) {
@@ -586,7 +584,6 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
"found in lookup after create",
loc->path, to->name);
ret = -1;
- fd_unref (fd);
goto out;
}
@@ -597,7 +594,6 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
DHT_MSG_MIGRATE_FILE_FAILED, "%s: file does not exists"
"on %s (%s)", loc->path, to->name, strerror (-ret));
ret = -1;
- fd_unref (fd);
goto out;
}
@@ -627,7 +623,15 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
/* success */
ret = 0;
+ if (dst_fd)
+ *dst_fd = fd;
+
out:
+ if (ret) {
+ if (fd) {
+ fd_unref (fd);
+ }
+ }
if (dict)
dict_unref (dict);
@@ -898,6 +902,7 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
}
fd_bind (fd);
+
if (src_fd)
*src_fd = fd;