summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 23efa8d57b3..d6e34f92036 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -1329,6 +1329,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
off_t offset = 0;
struct iatt iatt = {0,};
int readdirp_errno = 0;
+ inode_t *linked_inode = NULL, *inode = NULL;
ret = syncop_lookup (this, loc, NULL, &iatt, NULL, NULL);
if (ret) {
@@ -1396,6 +1397,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
continue;
loc_wipe (&entry_loc);
+
ret =dht_build_child_loc (this, &entry_loc, loc,
entry->d_name);
if (ret) {
@@ -1411,9 +1413,23 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
continue;
}
- entry_loc.inode->ia_type = entry->d_stat.ia_type;
uuid_copy (entry_loc.gfid, entry->d_stat.ia_gfid);
+
+ /*In case the gfid stored in the inode by inode_link
+ * and the gfid obtained in the lookup differs, then
+ * client3_3_lookup_cbk will return ESTALE and proper
+ * error will be captured
+ */
+
+ linked_inode = inode_link (entry_loc.inode, loc->inode,
+ entry->d_name,
+ &entry->d_stat);
+
+ inode = entry_loc.inode;
+ entry_loc.inode = linked_inode;
+ inode_unref (inode);
+
if (uuid_is_null (loc->gfid)) {
gf_log (this->name, GF_LOG_ERROR, "%s/%s"
"gfid not present", loc->path,