From 9a198ccd65c067e5269cbdfef0b8fab7073bc212 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. Backport of http://review.gluster.org/12969 > 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 Signed-off-by: Joseph Fernandes Change-Id: I4d745076b3258a64584778ba88dd665ddd907d27 BUG: 1293348 Reviewed-on: http://review.gluster.org/13046 Tested-by: NetBSD Build System Tested-by: Gluster Build System 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 239ac26fe24..ce607011dae 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -548,6 +548,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), @@ -607,9 +609,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; @@ -884,6 +883,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) @@ -929,9 +931,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