diff options
author | N Balachandran <nbalacha@redhat.com> | 2016-01-08 10:36:37 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2016-01-10 21:19:30 -0800 |
commit | 36fcaf275952202ce3f1e621d3b3a34d58054c99 (patch) | |
tree | 440bcc65fb1219ea382fec012b58b68bb1dfcf02 | |
parent | 9e7cd9456532caa7b255978b4b435418c04e0db9 (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.
Change-Id: I56c5aff7fa3827887e67936b8aa1ecbd1a08a9e9
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>
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 17 |
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 ced907e7937..3fbf091f337 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -516,7 +516,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; } } @@ -560,8 +560,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), @@ -572,7 +571,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) { @@ -583,7 +581,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; } @@ -594,7 +591,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; } @@ -624,7 +620,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); @@ -895,6 +899,7 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc, } fd_bind (fd); + if (src_fd) *src_fd = fd; |