summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src
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
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')
-rw-r--r--xlators/cluster/dht/src/Makefile.am10
-rw-r--r--xlators/cluster/dht/src/dht-common.c71
-rw-r--r--xlators/cluster/dht/src/dht-common.h5
3 files changed, 76 insertions, 10 deletions
diff --git a/xlators/cluster/dht/src/Makefile.am b/xlators/cluster/dht/src/Makefile.am
index 4b69aa071..8ebcab044 100644
--- a/xlators/cluster/dht/src/Makefile.am
+++ b/xlators/cluster/dht/src/Makefile.am
@@ -4,7 +4,8 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/cluster
dht_common_source = dht-layout.c dht-helper.c dht-linkfile.c \
- dht-selfheal.c dht-rename.c dht-hashfn.c dht-diskusage.c
+ dht-selfheal.c dht-rename.c dht-hashfn.c dht-diskusage.c \
+ $(top_builddir)/xlators/lib/src/libxlator.c
dht_la_SOURCES = $(dht_common_source) dht.c
@@ -20,10 +21,11 @@ nufa_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
switch_la_LDFLAGS = -module -avoidversion
switch_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
-noinst_HEADERS = dht-common.h dht-common.c dht-mem-types.h
+noinst_HEADERS = dht-common.h dht-common.c dht-mem-types.h $(top_builddir)/xlators/lib/src/libxlator.h
AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
- -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)
+ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS) \
+ -I$(top_srcdir)/xlators/lib/src
CLEANFILES =
@@ -31,4 +33,4 @@ uninstall-local:
rm -f $(DESTDIR)$(xlatordir)/distribute.so
install-data-hook:
- ln -sf dht.so $(DESTDIR)$(xlatordir)/distribute.so \ No newline at end of file
+ ln -sf dht.so $(DESTDIR)$(xlatordir)/distribute.so
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);
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index becc8d9c8..6a4daa65e 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -23,6 +23,7 @@
#endif
#include "dht-mem-types.h"
+#include "libxlator.h"
#ifndef _DHT_H
#define _DHT_H
@@ -128,6 +129,9 @@ struct dht_local {
/* gfid related */
uuid_t gfid;
+
+ /*Marker Related*/
+ struct marker_str marker;
};
typedef struct dht_local dht_local_t;
@@ -160,6 +164,7 @@ struct dht_conf {
void *private; /* Can be used by wrapper xlators over
dht */
gf_boolean_t use_readdirp;
+ char vol_uuid[UUID_SIZE + 1];
};
typedef struct dht_conf dht_conf_t;