summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
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/afr
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/afr')
-rw-r--r--xlators/cluster/afr/src/Makefile.am7
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c74
-rw-r--r--xlators/cluster/afr/src/afr.h10
3 files changed, 85 insertions, 6 deletions
diff --git a/xlators/cluster/afr/src/Makefile.am b/xlators/cluster/afr/src/Makefile.am
index 4e4b4c75260..e192b599bf4 100644
--- a/xlators/cluster/afr/src/Makefile.am
+++ b/xlators/cluster/afr/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = afr.la pump.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/cluster
-afr_common_source = afr-dir-read.c afr-dir-write.c afr-inode-read.c afr-inode-write.c afr-open.c afr-transaction.c afr-self-heal-data.c afr-self-heal-common.c afr-self-heal-metadata.c afr-self-heal-entry.c afr-self-heal-algorithm.c afr-lk-common.c
+afr_common_source = afr-dir-read.c afr-dir-write.c afr-inode-read.c afr-inode-write.c afr-open.c afr-transaction.c afr-self-heal-data.c afr-self-heal-common.c afr-self-heal-metadata.c afr-self-heal-entry.c afr-self-heal-algorithm.c afr-lk-common.c $(top_builddir)/xlators/lib/src/libxlator.c
afr_la_LDFLAGS = -module -avoidversion
afr_la_SOURCES = $(afr_common_source) afr.c
@@ -11,10 +11,11 @@ pump_la_LDFLAGS = -module -avoidversion
pump_la_SOURCES = $(afr_common_source) pump.c
pump_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
-noinst_HEADERS = afr.h afr-transaction.h afr-inode-write.h afr-inode-read.h afr-dir-read.h afr-dir-write.h afr-self-heal.h afr-self-heal-common.h afr-self-heal-algorithm.h pump.h afr-mem-types.h afr-common.c
+noinst_HEADERS = afr.h afr-transaction.h afr-inode-write.h afr-inode-read.h afr-dir-read.h afr-dir-write.h afr-self-heal.h afr-self-heal-common.h afr-self-heal-algorithm.h pump.h afr-mem-types.h afr-common.c $(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 -I$(top_srcdir)/contrib/md5 -shared -nostartfiles $(GF_CFLAGS)
+ -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/contrib/md5 -shared -nostartfiles $(GF_CFLAGS) \
+ -I$(top_srcdir)/xlators/lib/src
CLEANFILES =
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 3998607672a..ce6a6a363ed 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -657,6 +657,15 @@ out:
}
int32_t
+afr_getxattr_unwind (void *arg, call_frame_t *frame,
+ int op_ret, int op_errno, dict_t *dict)
+
+{
+ AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict);
+ return 0;
+}
+
+int32_t
afr_getxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, const char *name)
{
@@ -664,8 +673,11 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
xlator_t ** children = NULL;
int call_child = 0;
afr_local_t * local = NULL;
+ xlator_list_t * trav = NULL;
+ xlator_t ** sub_volumes= NULL;
int read_child = -1;
+ int i = 0;
int32_t op_ret = -1;
int32_t op_errno = 0;
@@ -683,6 +695,11 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
ALLOC_OR_GOTO (local, afr_local_t, out);
frame->local = local;
+ loc_copy (&local->loc, loc);
+ if (name)
+ local->cont.getxattr.name = gf_strdup (name);
+
+
if (name) {
if (!strncmp (name, AFR_XATTR_PREFIX,
strlen (AFR_XATTR_PREFIX))) {
@@ -690,6 +707,60 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
op_errno = ENODATA;
goto out;
}
+ if ((strcmp (GF_XATTR_MARKER_KEY, name) == 0)
+ && (-1 == frame->root->pid)) {
+
+ local->marker.call_count = priv->child_count;
+
+ sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *));
+ for (i = 0, trav = this->children; trav ;
+ trav = trav->next, i++) {
+
+ *(sub_volumes + i) = trav->xlator;
+ }
+
+ if (cluster_getmarkerattr (frame, this, loc, name,
+ local, afr_getxattr_unwind,
+ sub_volumes,
+ priv->child_count,
+ MARKER_UUID_TYPE,
+ priv->vol_uuid)) {
+
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ return 0;
+ }
+
+ if (*priv->vol_uuid) {
+ if ((match_uuid_local (name, priv->vol_uuid) == 0)
+ && (-1 == frame->root->pid)) {
+
+ local->marker.call_count = priv->child_count;
+
+ sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *));
+ for (i = 0, trav = this->children; trav ;
+ trav = trav->next, i++) {
+
+ *(sub_volumes + i) = trav->xlator;
+
+ }
+
+ if (cluster_getmarkerattr (frame, this, loc,
+ name, local,
+ afr_getxattr_unwind,
+ sub_volumes,
+ priv->child_count,
+ MARKER_XTIME_TYPE,
+ priv->vol_uuid)) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ return 0;
+ }
+ }
}
@@ -712,9 +783,6 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
local->cont.getxattr.last_tried = call_child;
}
- loc_copy (&local->loc, loc);
- if (name)
- local->cont.getxattr.name = gf_strdup (name);
STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
(void *) (long) call_child,
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index a7359f26963..b0e434142a3 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -30,6 +30,8 @@
#include "compat-errno.h"
#include "afr-mem-types.h"
+#include "libxlator.h"
+
#define AFR_XATTR_PREFIX "trusted.afr"
struct _pump_private;
@@ -89,6 +91,8 @@ typedef struct _afr_private {
pthread_mutex_t mutex;
struct list_head saved_fds; /* list of fds on which locks have succeeded */
gf_boolean_t optimistic_change_log;
+
+ char vol_uuid[UUID_SIZE + 1];
} afr_private_t;
typedef struct {
@@ -616,6 +620,8 @@ typedef struct _afr_local {
} transaction;
afr_self_heal_t self_heal;
+
+ struct marker_str marker;
} afr_local_t;
@@ -927,4 +933,8 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
return 0;
}
+int32_t
+afr_marker_getxattr (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv );
+
#endif /* __AFR_H__ */