diff options
author | shishir gowda <sgowda@redhat.com> | 2013-05-22 09:58:15 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-05-31 06:44:11 -0700 |
commit | 3c22cf86ad244f87dafd9b7a9f82331968879c15 (patch) | |
tree | 7ff52cca4258cfa93562c51db3fa1ef085924946 /xlators | |
parent | 599c6b472869cfaf0058e7b169de204450a41948 (diff) |
cluster/dht: Handle linkfile creation with EEXIST error
If linkfile create fails with EEXISTS, then check if the file
is a linkfile for the same file. If not, return the error
Change-Id: Iab42db54422dea69de0049b5196365e65edadd91
BUG: 966858
Signed-off-by: shishir gowda <sgowda@redhat.com>
Reviewed-on: http://review.gluster.org/5060
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-linkfile.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c index 6360c73e3ba..13d791a8ff6 100644 --- a/xlators/cluster/dht/src/dht-linkfile.c +++ b/xlators/cluster/dht/src/dht-linkfile.c @@ -19,6 +19,35 @@ #include "compat.h" #include "dht-common.h" +int +dht_linkfile_lookup_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) +{ + char is_linkfile = 0; + dht_conf_t *conf = NULL; + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + + if (!op_ret) + goto out; + + local = frame->local; + prev = cookie; + conf = this->private; + + is_linkfile = check_is_linkfile (inode, stbuf, xattr, + conf->link_xattr_name); + if (!is_linkfile) + gf_log (this->name, GF_LOG_WARNING, "got non-linkfile %s:%s", + prev->this->name, local->loc.path); +out: + local->linkfile.linkfile_cbk (frame, cookie, this, op_ret, op_errno, + inode, stbuf, postparent, postparent, + xattr); + return 0; +} #define is_equal(a, b) (a == b) int @@ -28,6 +57,11 @@ dht_linkfile_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *postparent, dict_t *xdata) { dht_local_t *local = NULL; + xlator_t *subvol = NULL; + call_frame_t *prev = NULL; + dict_t *xattrs = NULL; + dht_conf_t *conf = NULL; + int ret = -1; local = frame->local; @@ -36,9 +70,34 @@ dht_linkfile_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, FRAME_SU_UNDO (frame, dht_local_t); + if (op_ret && (op_errno == EEXIST)) { + conf = this->private; + prev = cookie; + subvol = prev->this; + if (!subvol) + goto out; + xattrs = dict_new (); + if (!xattrs) + goto out; + ret = dict_set_uint32 (xattrs, conf->link_xattr_name, 256); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to set linkto key"); + goto out; + } + + STACK_WIND (frame, dht_linkfile_lookup_cbk, subvol, + subvol->fops->lookup, &local->loc, xattrs); + if (xattrs) + dict_unref (xattrs); + return 0; + } +out: local->linkfile.linkfile_cbk (frame, cookie, this, op_ret, op_errno, inode, stbuf, preparent, postparent, xdata); + if (xattrs) + dict_unref (xattrs); return 0; } |