summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-common.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-10-21 14:45:08 +0530
committerVijay Bellur <vijay@gluster.com>2011-10-28 05:01:11 -0700
commit2712393ba21dbfdc7b3443ed019d35ab60628b2a (patch)
tree46d409b5af6f8dd7d0e58041a120a44393fb79c9 /xlators/cluster/afr/src/afr-common.c
parentae78820311fc95047195735b1519fa4d626de208 (diff)
cluster/afr: Take gfid-req from xattr_req only if inode->gfid is null
Change-Id: Iddf5b59d3534c517dcd3c0d7b819e3768f6e915a BUG: 3747 Reviewed-on: http://review.gluster.com/637 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-common.c')
-rw-r--r--xlators/cluster/afr/src/afr-common.c93
1 files changed, 64 insertions, 29 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index acefa697f8a..114812c6339 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -94,6 +94,60 @@ afr_xattr_req_prepare (xlator_t *this, dict_t *xattr_req, const char *path)
}
int
+afr_lookup_xattr_req_prepare (afr_local_t *local, xlator_t *this,
+ dict_t *xattr_req, loc_t *loc, void **gfid_req)
+{
+ int ret = -ENOMEM;
+
+ GF_ASSERT (gfid_req);
+
+ *gfid_req = NULL;
+ local->xattr_req = dict_new ();
+ if (!local->xattr_req)
+ goto out;
+ if (xattr_req)
+ dict_copy (xattr_req, local->xattr_req);
+
+ afr_xattr_req_prepare (this, local->xattr_req, loc->path);
+ ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_INODELK_COUNT, 0);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: Unable to set dict value for %s",
+ loc->path, GLUSTERFS_INODELK_COUNT);
+ }
+ ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_ENTRYLK_COUNT, 0);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: Unable to set dict value for %s",
+ loc->path, GLUSTERFS_ENTRYLK_COUNT);
+ }
+
+ ret = dict_get_ptr (local->xattr_req, "gfid-req", gfid_req);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "%s: failed to get the gfid from dict", loc->path);
+ *gfid_req = NULL;
+ } else {
+ if (loc->parent != NULL)
+ dict_del (local->xattr_req, "gfid-req");
+ }
+ ret = 0;
+out:
+ return ret;
+}
+
+void
+afr_lookup_save_gfid (uuid_t dst, void* new, inode_t *inode)
+{
+ if (inode && !uuid_is_null (inode->gfid)) {
+ uuid_copy (dst, inode->gfid);
+ } else {
+ GF_ASSERT (new && !uuid_is_null (new));
+ uuid_copy (dst, new);
+ }
+}
+
+int
afr_errno_count (int32_t *children, int *child_errno,
unsigned int child_count, int32_t op_errno)
{
@@ -1946,7 +2000,6 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
local->call_count = afr_up_children_count (local->child_up,
priv->child_count);
call_count = local->call_count;
-
if (local->call_count == 0) {
ret = -1;
op_errno = ENOTCONN;
@@ -1956,35 +2009,17 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
/* By default assume ENOTCONN. On success it will be set to 0. */
local->op_errno = ENOTCONN;
- if (xattr_req == NULL)
- local->xattr_req = dict_new ();
- else
- local->xattr_req = dict_ref (xattr_req);
-
- afr_xattr_req_prepare (this, local->xattr_req, loc->path);
- ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_INODELK_COUNT, 0);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: Unable to set dict value for %s",
- loc->path, GLUSTERFS_INODELK_COUNT);
- }
- ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_ENTRYLK_COUNT, 0);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: Unable to set dict value for %s",
- loc->path, GLUSTERFS_ENTRYLK_COUNT);
- }
-
- ret = dict_get_ptr (local->xattr_req, "gfid-req", &gfid_req);
+ local->call_count = afr_up_children_count (local->child_up,
+ priv->child_count);
+ ret = afr_lookup_xattr_req_prepare (local, this, xattr_req, loc,
+ &gfid_req);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
- "failed to get the gfid from dict");
- } else {
- uuid_copy (local->cont.lookup.gfid_req, gfid_req);
- if (local->loc.parent)
- dict_del (local->xattr_req, "gfid-req");
+ local->op_errno = -ret;
+ goto out;
}
-
+ afr_lookup_save_gfid (local->cont.lookup.gfid_req, gfid_req,
+ loc->inode);
+ local->fop = GF_FOP_LOOKUP;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
STACK_WIND_COOKIE (frame, afr_lookup_cbk,
@@ -1999,7 +2034,7 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
ret = 0;
out:
- if (ret == -1)
+ if (ret)
AFR_STACK_UNWIND (lookup, frame, -1, op_errno,
NULL, NULL, NULL, NULL);