summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht')
-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 4b69aa07100..8ebcab04451 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 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 <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 becc8d9c8e9..6a4daa65ead 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;