diff options
author | Anand Avati <avati@gluster.com> | 2011-07-22 03:45:34 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-25 09:22:30 -0700 |
commit | d35e17152720a074c15f54f5c3b8a400e456b19e (patch) | |
tree | a7b88862299bad06cc962e6beb078d90cf04a3aa | |
parent | 65cc08d80d5db6a6854249cc04bece0a9554adfb (diff) |
cluster/dht: dht_rename() - handle GFID situations
In the pre-GFID era, the linkfile of the destination file could be reused
the linkfile for the renamed file when dst_cached == src_cached.
This patch handles this situation and reverts the previous (wrong) fix.
Change-Id: Iba57b5eb91cf8b1fb40e74f6399cdf99b8b00410
BUG: 2464
Reviewed-on: http://review.gluster.com/90
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
-rw-r--r-- | xlators/cluster/dht/src/dht-rename.c | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c index dd1354269bb..8110387d58b 100644 --- a/xlators/cluster/dht/src/dht-rename.c +++ b/xlators/cluster/dht/src/dht-rename.c @@ -614,6 +614,41 @@ cleanup: int +dht_rename_unlink_links_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct iatt *preparent, struct iatt *postparent) +{ + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + + + local = frame->local; + prev = cookie; + + if (op_ret == -1) { + gf_log (this->name, GF_LOG_DEBUG, + "unlink of %s on %s failed (%s)", + local->loc2.path, prev->this->name, + strerror (op_errno)); + local->op_ret = -1; + local->op_errno = op_errno; + } + + if (local->op_ret == -1) + goto cleanup; + + dht_do_rename (frame); + + return 0; + +cleanup: + dht_rename_cleanup (frame); + + return 0; +} + + +int dht_rename_create_links (call_frame_t *frame) { dht_local_t *local = NULL; @@ -633,8 +668,20 @@ dht_rename_create_links (call_frame_t *frame) dst_hashed = local->dst_hashed; dst_cached = local->dst_cached; - if (src_cached == dst_cached) - goto nolinks; + + if (src_cached == dst_cached) { + if (dst_hashed == dst_cached) + goto nolinks; + + gf_log (this->name, GF_LOG_TRACE, + "unlinking dst linkfile %s @ %s", + local->loc2.path, dst_hashed->name); + + STACK_WIND (frame, dht_rename_unlink_links_cbk, + dst_hashed, dst_hashed->fops->unlink, + &local->loc2); + return 0; + } if (dst_hashed != src_hashed && dst_hashed != src_cached) call_cnt++; @@ -649,18 +696,18 @@ dht_rename_create_links (call_frame_t *frame) "linkfile %s @ %s => %s", local->loc.path, dst_hashed->name, src_cached->name); memcpy (local->gfid, local->loc.inode->gfid, 16); - dht_linkfile_recreate (frame, dht_rename_links_cbk, - src_cached, dst_hashed, &local->loc); - } - - if (src_cached != dst_hashed) { - gf_log (this->name, GF_LOG_TRACE, - "link %s => %s (%s)", local->loc.path, - local->loc2.path, src_cached->name); - STACK_WIND (frame, dht_rename_links_cbk, - src_cached, src_cached->fops->link, - &local->loc, &local->loc2); - } + dht_linkfile_create (frame, dht_rename_links_cbk, + src_cached, dst_hashed, &local->loc); + } + + if (src_cached != dst_hashed) { + gf_log (this->name, GF_LOG_TRACE, + "link %s => %s (%s)", local->loc.path, + local->loc2.path, src_cached->name); + STACK_WIND (frame, dht_rename_links_cbk, + src_cached, src_cached->fops->link, + &local->loc, &local->loc2); + } nolinks: if (!call_cnt) { |