summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/stripe
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/stripe
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/stripe')
-rw-r--r--xlators/cluster/stripe/src/Makefile.am7
-rw-r--r--xlators/cluster/stripe/src/stripe.c108
-rw-r--r--xlators/cluster/stripe/src/stripe.h5
3 files changed, 117 insertions, 3 deletions
diff --git a/xlators/cluster/stripe/src/Makefile.am b/xlators/cluster/stripe/src/Makefile.am
index 6d4fae4d2..0db3c9eeb 100644
--- a/xlators/cluster/stripe/src/Makefile.am
+++ b/xlators/cluster/stripe/src/Makefile.am
@@ -4,13 +4,14 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/cluster
stripe_la_LDFLAGS = -module -avoidversion
-stripe_la_SOURCES = stripe.c
+stripe_la_SOURCES = stripe.c $(top_builddir)/xlators/lib/src/libxlator.c
stripe_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
-noinst_HEADERS = stripe.h stripe-mem-types.h
+noinst_HEADERS = stripe.h stripe-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 =
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index 639fbfd8b..cc34a8468 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -34,6 +34,7 @@
*/
#include "stripe.h"
+#include "libxlator.h"
void
stripe_local_wipe (stripe_local_t *local)
@@ -3896,6 +3897,7 @@ init (xlator_t *this)
priv->nodes_down = priv->child_count;
this->private = priv;
+
ret = 0;
out:
if (ret) {
@@ -3942,6 +3944,110 @@ out:
return;
}
+int32_t
+stripe_getxattr_unwind (void *getxattr, call_frame_t *frame,
+ int op_ret, int op_errno, dict_t *dict)
+
+{
+ STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict);
+ return 0;
+}
+
+int32_t
+stripe_getxattr (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, const char *name)
+{
+ stripe_local_t *local = NULL;
+ xlator_list_t *trav = NULL;
+ stripe_private_t *priv = NULL;
+ int32_t op_errno = EINVAL;
+ int i = 0;
+ xlator_t **sub_volumes;
+
+ VALIDATE_OR_GOTO (frame, err);
+ VALIDATE_OR_GOTO (this, err);
+ VALIDATE_OR_GOTO (loc, err);
+ VALIDATE_OR_GOTO (loc->path, err);
+ VALIDATE_OR_GOTO (loc->inode, err);
+
+ priv = this->private;
+ trav = this->children;
+
+ /* Initialization */
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
+ if (!local) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+ local->op_ret = -1;
+ frame->local = local;
+ loc_copy (&local->loc, loc);
+
+
+ if (name && (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, stripe_getxattr_unwind,
+ sub_volumes, priv->child_count,
+ MARKER_UUID_TYPE, priv->vol_uuid)) {
+ op_errno = EINVAL;
+ goto err;
+ }
+
+ 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, stripe_getxattr_unwind,
+ sub_volumes,
+ priv->child_count,
+ MARKER_XTIME_TYPE,
+ priv->vol_uuid)) {
+ op_errno = EINVAL;
+ goto err;
+ }
+ return 0;
+ }
+ }
+
+
+ STACK_WIND (frame, default_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, loc, name);
+
+ return 0;
+
+err:
+ STACK_UNWIND_STRICT (getxattr, frame, -1, op_errno, NULL);
+ return 0;
+}
+
+
struct xlator_fops fops = {
.stat = stripe_stat,
@@ -3967,6 +4073,8 @@ struct xlator_fops fops = {
.fsetattr = stripe_fsetattr,
.lookup = stripe_lookup,
.mknod = stripe_mknod,
+
+ .getxattr = stripe_getxattr,
};
struct xlator_cbks cbks = {
diff --git a/xlators/cluster/stripe/src/stripe.h b/xlators/cluster/stripe/src/stripe.h
index 6199c0061..86555144f 100644
--- a/xlators/cluster/stripe/src/stripe.h
+++ b/xlators/cluster/stripe/src/stripe.h
@@ -33,6 +33,7 @@
#include "compat.h"
#include "compat-errno.h"
#include "stripe-mem-types.h"
+#include "libxlator.h"
#include <fnmatch.h>
#include <signal.h>
@@ -84,6 +85,7 @@ struct stripe_private {
int8_t child_count;
int8_t *state; /* Current state of child node */
gf_boolean_t xattr_supported; /* default yes */
+ char vol_uuid[UUID_SIZE + 1];
};
/**
@@ -163,6 +165,8 @@ struct stripe_local {
/* For File I/O fops */
dict_t *dict;
+ struct marker_str marker;
+
/* General usage */
off_t offset;
off_t stripe_size;
@@ -180,4 +184,5 @@ struct stripe_local {
typedef struct stripe_local stripe_local_t;
typedef struct stripe_private stripe_private_t;
+
#endif /* _STRIPE_H_ */