summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-rebalance.c
diff options
context:
space:
mode:
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 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;