diff options
Diffstat (limited to 'xlators/cluster/dht/src/dht-rebalance.c')
-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 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; |