diff options
Diffstat (limited to 'xlators/cluster')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 3 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-linkfile.c | 140 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rename.c | 51 |
3 files changed, 50 insertions, 144 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 2fe85d00e5f..3a4e6e57202 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -330,9 +330,6 @@ int dht_rename_links_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_t *inode, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent); -int dht_linkfile_recreate(call_frame_t *frame, fop_mknod_cbk_t linkfile_cbk, - xlator_t *tovol, xlator_t *fromvol, loc_t *loc); - int dht_fix_directory_layout (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk, dht_layout_t *layout); diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c index e936f3119a6..89fc32725ec 100644 --- a/xlators/cluster/dht/src/dht-linkfile.c +++ b/xlators/cluster/dht/src/dht-linkfile.c @@ -189,143 +189,3 @@ dht_linkfile_subvol (xlator_t *this, inode_t *inode, struct iatt *stbuf, out: return subvol; } - -int -dht_recreate_linkfile_unlink_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; - xlator_t *subvol = NULL; - xlator_t *src_cached = NULL; - xlator_t *dst_hashed = NULL; - call_frame_t *prev = NULL; - loc_t *loc = NULL; - - GF_VALIDATE_OR_GOTO ("dht", frame, err); - GF_VALIDATE_OR_GOTO ("dht", this, err); - GF_VALIDATE_OR_GOTO ("dht", frame->local, err); - - local = frame->local; - prev = cookie; - subvol = prev->this; - src_cached = local->src_cached; - dst_hashed = local->dst_hashed; - loc = &local->loc; - - if (!src_cached || !dst_hashed) { - gf_log (this->name, GF_LOG_ERROR, "src_cached or dst_hashed" - "subvol is null"); - local->op_ret = -1; - local->op_errno = EINVAL; - goto out; - } - - if (op_ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "unlinking linkfile %s on %s failed (%s)", - loc->path, subvol->name, strerror (op_errno)); - local->op_ret = op_ret; - local->op_errno = op_errno; - goto out; - } - gf_log (this->name, GF_LOG_DEBUG, "unlink successfull. Proceeding with" - " creation of link file %s", loc->path); - dht_linkfile_create (frame, local->linkfile.linkfile_cbk, - src_cached, dst_hashed, loc); - - return 0; -out: - local->linkfile.linkfile_cbk (frame, NULL, frame->this, -1, EINVAL, - local->loc.inode, NULL, NULL, NULL); -err: - return -1; -} - -int -dht_linkfile_recreate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent) -{ - dht_local_t *local = NULL; - xlator_t *src_cached = NULL; - xlator_t *dst_hashed = NULL; - loc_t *loc = NULL; - - GF_VALIDATE_OR_GOTO ("dht", frame, err); - GF_VALIDATE_OR_GOTO ("dht", this, err); - GF_VALIDATE_OR_GOTO ("dht", frame->local, err); - - local = frame->local; - loc = &local->loc; - - src_cached = local->src_cached; - dst_hashed = local->dst_hashed; - - if (!src_cached || !dst_hashed) { - gf_log (this->name, GF_LOG_ERROR, "src_cached or dst_hashed" - " or hashed_subvol is null"); - local->op_ret = -1; - local->op_errno = EINVAL; - goto out; - } - - /* if link_file exists, remove it, else create it*/ - if (!op_ret) { - if (!check_is_linkfile (inode, stbuf, xattr)) - goto out; - gf_log (this->name, GF_LOG_DEBUG, "link file exists." - " Calling unlink on %s", loc->path); - STACK_WIND (frame, dht_recreate_linkfile_unlink_cbk, - dst_hashed, dst_hashed->fops->unlink, - loc); - - } else if (op_errno == ENOENT) { - gf_log (this->name, GF_LOG_DEBUG, "link file does not exist." - " Proceeding to creation of linkfile %s", loc->path); - dht_linkfile_create (frame, local->linkfile.linkfile_cbk, - src_cached, dst_hashed, loc); - } else { - gf_log (this->name, GF_LOG_ERROR, "returned error %s", - strerror(op_errno)); - local->op_ret = op_ret; - local->op_errno = op_errno; - goto out; - } - - return 0; -out: - local->linkfile.linkfile_cbk (frame, NULL, frame->this, -1, EINVAL, - loc->inode, NULL, NULL, NULL); -err: - return -1; -} - -int -dht_linkfile_recreate (call_frame_t *frame, fop_mknod_cbk_t linkfile_cbk, - xlator_t *tovol, xlator_t *fromvol, loc_t *loc) -{ - dht_local_t *local = NULL; - - GF_VALIDATE_OR_GOTO ("dht", frame, out); - GF_VALIDATE_OR_GOTO ("dht", loc, out); - GF_VALIDATE_OR_GOTO ("dht", tovol, out); - GF_VALIDATE_OR_GOTO ("dht", fromvol, out); - - local = frame->local; - local->linkfile.linkfile_cbk = linkfile_cbk; - local->linkfile.srcvol = tovol; - loc_copy (&local->linkfile.loc, loc); - - STACK_WIND (frame, dht_linkfile_recreate_cbk, - fromvol, fromvol->fops->lookup, loc, NULL); - - return 0; - -out: - linkfile_cbk (frame, NULL, frame->this, -1, EINVAL, loc->inode, NULL, - NULL, NULL); - - return -1; -} diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c index 8110387d58b..8c8c144a606 100644 --- a/xlators/cluster/dht/src/dht-rename.c +++ b/xlators/cluster/dht/src/dht-rename.c @@ -427,6 +427,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, @@ -439,6 +463,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; @@ -457,6 +483,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); @@ -625,7 +674,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, |