summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-rename.c
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-08-03 14:00:03 +0530
committerAnand Avati <avati@gluster.com>2011-08-03 21:57:38 -0700
commit14bc17013d2962b311868d866484bbdb26665225 (patch)
tree063441e00e024ac70948976e0a2ae3f891dcac46 /xlators/cluster/dht/src/dht-rename.c
parente680bc9c6bbae1254637052cff5abf4a5a57a166 (diff)
DHT rename: Recreate linkfile after unlink
This is done, so that there is no gfid mismatch. Unlink the older linkfile if it exists, and recreate it with the correct gfid. Also removed unused rename related code. BUG: 2522 Change-Id: Ic1c5f7ff66090e9147d75530b6ab3f9ef123f4ae Reviewed-on: http://review.gluster.com/143 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-rename.c')
-rw-r--r--xlators/cluster/dht/src/dht-rename.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
index f8ba8578f7c..180c85f9ab0 100644
--- a/xlators/cluster/dht/src/dht-rename.c
+++ b/xlators/cluster/dht/src/dht-rename.c
@@ -433,6 +433,30 @@ nolinks:
int
+dht_rename_links_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent)
+{
+ call_frame_t *prev = NULL;
+ dht_local_t *local = NULL;
+
+ prev = cookie;
+ local = frame->local;
+
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "link/file %s on %s failed (%s)",
+ local->loc.path, prev->this->name, strerror (op_errno));
+ }
+
+ DHT_STACK_DESTROY (frame);
+
+ return 0;
+}
+
+
+int
dht_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
struct iatt *preoldparent, struct iatt *postoldparent,
@@ -445,6 +469,8 @@ dht_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
xlator_t *dst_hashed = NULL;
xlator_t *dst_cached = NULL;
xlator_t *rename_subvol = NULL;
+ call_frame_t *link_frame = NULL;
+ dht_local_t *link_local = NULL;
local = frame->local;
prev = cookie;
@@ -463,6 +489,29 @@ dht_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto cleanup;
}
+ if ((src_cached == dst_cached) && (dst_hashed != dst_cached)) {
+ link_frame = copy_frame (frame);
+ if (!link_frame) {
+ goto err;
+ }
+
+ link_local = dht_local_init (link_frame);
+ if (!link_local) {
+ goto err;
+ }
+
+ loc_copy (&link_local->loc, &local->loc2);
+ if (link_local->loc.inode)
+ inode_unref (link_local->loc.inode);
+ link_local->loc.inode = inode_ref (local->loc.inode);
+ uuid_copy (link_local->gfid, local->loc.inode->gfid);
+ link_frame->local = link_local;
+
+ dht_linkfile_create (link_frame, dht_rename_links_create_cbk,
+ src_cached, dst_hashed, &link_local->loc);
+ }
+
+err:
dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
dht_iatt_merge (this, &local->preoldparent, preoldparent, prev->this);
dht_iatt_merge (this, &local->postoldparent, postoldparent, prev->this);
@@ -639,7 +688,7 @@ dht_rename_unlink_links_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
prev = cookie;
- if (op_ret == -1) {
+ if ((op_ret == -1) && (op_errno != ENOENT)) {
gf_log (this->name, GF_LOG_DEBUG,
"unlink of %s on %s failed (%s)",
local->loc2.path, prev->this->name,