From 73bce15b61755509de23d32646135254d369a2f6 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Thu, 27 Jan 2011 05:23:30 +0000 Subject: adding libxlator, to ensure proper client side aggregation of marks by clustering translators Signed-off-by: Kaushik BV Signed-off-by: Csaba Henk Signed-off-by: Anand V. Avati BUG: 2310 (georeplication) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2310 --- xlators/cluster/dht/src/dht-common.c | 71 +++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'xlators/cluster/dht/src/dht-common.c') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index e20472646ee..cca09927cd3 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -27,12 +27,14 @@ #include "glusterfs.h" #include "xlator.h" +#include "libxlator.h" #include "dht-common.h" #include "defaults.h" #include #include + /* TODO: - use volumename in xattr instead of "dht" - use NS locks @@ -1834,6 +1836,14 @@ out: return 0; } +int32_t +dht_getxattr_unwind (void *getxattr, call_frame_t *frame, + int op_ret, int op_errno, dict_t *dict) +{ + DHT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict); + return 0; +} + int dht_getxattr (call_frame_t *frame, xlator_t *this, @@ -1845,6 +1855,7 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, dht_conf_t *conf = NULL; dht_local_t *local = NULL; dht_layout_t *layout = NULL; + xlator_t **sub_volumes = NULL; int op_errno = -1; int ret = 0; int flag = 0; @@ -1867,6 +1878,14 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, goto err; } + local = dht_local_init (frame); + if (!local) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, + "Out of memory"); + goto err; + } + if (key && (strcmp (key, GF_XATTR_PATHINFO_KEY) == 0)) { hashed_subvol = dht_subvol_get_hashed (this, loc); cached_subvol = dht_subvol_get_cached (this, loc->inode); @@ -1959,12 +1978,52 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, goto err; } - local = dht_local_init (frame); - if (!local) { - op_errno = ENOMEM; - gf_log (this->name, GF_LOG_ERROR, - "Out of memory"); - goto err; + if (key && (!strcmp (GF_XATTR_MARKER_KEY, key)) + && (-1 == frame->root->pid)) { + + if (loc->inode-> ia_type == IA_IFDIR) { + cnt = layout->cnt; + } else { + cnt = 1; + } + sub_volumes = alloca ( cnt * sizeof (xlator_t *)); + for (i = 0; i < cnt; i++) + *(sub_volumes + i) = layout->list[i].xlator; + + if (cluster_getmarkerattr (frame, this, loc, key, + local, dht_getxattr_unwind, + sub_volumes, cnt, + MARKER_UUID_TYPE, conf->vol_uuid)) { + op_errno = EINVAL; + goto err; + } + + return 0; + } + + if (key && *conf->vol_uuid) { + if ((match_uuid_local (key, conf->vol_uuid) == 0) && + (-1 == frame->root->pid)) { + if (loc->inode-> ia_type == IA_IFDIR) { + cnt = layout->cnt; + } else { + cnt = 1; + } + sub_volumes = alloca ( cnt * sizeof (xlator_t *)); + for (i = 0; i < cnt; i++) + sub_volumes[i] = layout->list[i].xlator; + + if (cluster_getmarkerattr (frame, this, loc, key, + local, dht_getxattr_unwind, + sub_volumes, cnt, + MARKER_XTIME_TYPE, + conf->vol_uuid)) { + op_errno = EINVAL; + goto err; + } + + return 0; + } } ret = loc_dup (loc, &local->loc); -- cgit