From 9691ea1b203c82386ececc3c5ea9adad39304d7b Mon Sep 17 00:00:00 2001 From: Joseph Fernandes Date: Tue, 15 Dec 2015 13:32:29 +0530 Subject: tier/dht : Properly free file descriptors during data migration While tier migration, free src and dst fd's when create of destination or open of source fails. Change-Id: I62978a669c6c9fbab5fed9df2716b9b2ba00ddf1 BUG: 1291566 Signed-off-by: Joseph Fernandes Reviewed-on: http://review.gluster.org/12969 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: N Balachandran Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- xlators/cluster/dht/src/dht-rebalance.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 78cccc02c48..08dbae0547a 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -545,6 +545,8 @@ __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), @@ -604,9 +606,6 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc "chown failed for %s on %s (%s)", loc->path, to->name, strerror (-ret)); - if (dst_fd) - *dst_fd = fd; - /* success */ ret = 0; @@ -881,6 +880,9 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc, } fd_bind (fd); + if (src_fd) + *src_fd = fd; + ret = -1; dict = dict_new (); if (!dict) @@ -926,9 +928,6 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc, goto out; } - if (src_fd) - *src_fd = fd; - /* success */ ret = 0; out: -- cgit