summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2017-09-12 22:07:10 +0530
committerAmar Tumballi <amarts@redhat.com>2017-11-03 07:26:41 +0000
commitcf62283467d7dd30b89b80717f1fbc24670cb44b (patch)
treefe71cde3eb20befab776af44b298333668e79172
parent9424a9fcc9f670766b7557230648e57123edd600 (diff)
Add framework for global xlator in graph
Updates #303 Change-Id: Id0b9050c93ea87532dc80b4fda650c5663d285bd Signed-off-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--libglusterfs/src/globals.c29
-rw-r--r--libglusterfs/src/globals.h3
-rw-r--r--libglusterfs/src/xlator.c20
3 files changed, 50 insertions, 2 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index 0ac1ab9b65b..a43b80aa060 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -137,6 +137,29 @@ static struct xlator_cbks global_cbks = {
.fdctxsize = NULL,
};
+/* This is required to get through the check in graph.c */
+static struct xlator_fops global_fops = {
+};
+
+static int
+global_xl_reconfigure (xlator_t *this, dict_t *options)
+{
+ dict_dump_to_log (options);
+ return 0;
+}
+
+static int
+global_xl_init (xlator_t *this)
+{
+ return 0;
+}
+
+static void
+global_xl_fini (xlator_t *this)
+{
+ return;
+}
+
int
glusterfs_this_init ()
{
@@ -151,8 +174,12 @@ glusterfs_this_init ()
}
global_xlator.name = "glusterfs";
- global_xlator.type = "global";
+ global_xlator.type = GF_GLOBAL_XLATOR_NAME;
global_xlator.cbks = &global_cbks;
+ global_xlator.fops = &global_fops;
+ global_xlator.reconfigure = global_xl_reconfigure;
+ global_xlator.init = global_xl_init;
+ global_xlator.fini = global_xl_fini;
INIT_LIST_HEAD (&global_xlator.volume_options);
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
index 033e0186310..bf73f2e6671 100644
--- a/libglusterfs/src/globals.h
+++ b/libglusterfs/src/globals.h
@@ -14,6 +14,7 @@
#define GF_DEFAULT_BASE_PORT 24007
#define GF_DEFAULT_VOLFILE_TRANSPORT "tcp"
+#define GF_GLOBAL_XLATOR_NAME "global"
#define GD_OP_VERSION_KEY "operating-version"
#define GD_MIN_OP_VERSION_KEY "minimum-operating-version"
#define GD_MAX_OP_VERSION_KEY "maximum-operating-version"
@@ -106,6 +107,8 @@ xlator_t **__glusterfs_this_location (void);
xlator_t *glusterfs_this_get (void);
int glusterfs_this_set (xlator_t *);
+extern xlator_t global_xlator;
+
/* syncopctx */
void *syncopctx_getctx (void);
int syncopctx_setctx (void *ctx);
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index de97dff6dfe..fdc2be144a6 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -305,10 +305,28 @@ xlator_set_type (xlator_t *xl, const char *type)
{
int ret = 0;
+ /* Handle 'global' translator differently */
+ if (!strncmp (GF_GLOBAL_XLATOR_NAME, type,
+ strlen (GF_GLOBAL_XLATOR_NAME))) {
+ /* set the required values from Global xlator */
+ xl->type = gf_strdup (GF_GLOBAL_XLATOR_NAME);
+ xl->cbks = global_xlator.cbks;
+ xl->fops = global_xlator.fops;
+ xl->init = global_xlator.init;
+ xl->fini = global_xlator.fini;
+ xl->reconfigure = global_xlator.reconfigure;
+
+ INIT_LIST_HEAD (&xl->volume_options);
+
+ fill_defaults(xl);
+
+ goto out;
+ }
+
ret = xlator_set_type_virtual (xl, type);
if (!ret)
ret = xlator_dynload (xl);
-
+out:
return ret;
}