summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.c
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-01-27 05:23:30 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-01-27 03:16:51 -0800
commit73bce15b61755509de23d32646135254d369a2f6 (patch)
tree921b92f6d3e549b1e6dd68bc886cc727caec5429 /xlators/cluster/dht/src/dht-common.c
parent11dd59b788334fe2de1653ae85395986ba531606 (diff)
adding libxlator, to ensure proper client side aggregation of marks by clustering translators
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2310 (georeplication) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2310
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r--xlators/cluster/dht/src/dht-common.c71
1 files changed, 65 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index e20472646..cca09927c 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 <sys/time.h>
#include <libgen.h>
+
/* 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);