summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-09-18 03:31:56 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-18 07:02:03 -0700
commit5c297be9612f76dad6f970092fb6762b4ee4844a (patch)
treef65290e7f12e8d6913f3f3b8d3ffa8dc4cd06618 /libglusterfs
parentfaa817ea9cb119c7f65fce24f03a172fa4b4ada1 (diff)
Glusterd: gluster volume set <volume> <option> <value>
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/glusterfs.h2
-rw-r--r--libglusterfs/src/graph.c18
-rw-r--r--libglusterfs/src/xlator.c52
-rw-r--r--libglusterfs/src/xlator.h2
4 files changed, 74 insertions, 0 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 1d0369c4d..669bbfaeb 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -310,4 +310,6 @@ int glusterfs_graph_destroy (glusterfs_graph_t *graph);
int glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx);
glusterfs_graph_t *glusterfs_graph_construct (FILE *fp);
glusterfs_graph_t *glusterfs_graph_new ();
+int glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
+ glusterfs_graph_t *newgraph);
#endif /* _GLUSTERFS_H */
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 4adb04a39..c44fa44ad 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -495,6 +495,24 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
return 0;
}
+int
+glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
+ glusterfs_graph_t *newgraph)
+{
+ xlator_t *old_xl = NULL;
+ xlator_t *new_xl = NULL;
+ int ret = 0;
+
+ GF_ASSERT (oldgraph);
+ GF_ASSERT (newgraph);
+
+ old_xl = oldgraph->first;
+ new_xl = newgraph->first;
+
+ ret = xlator_tree_reconfigure (old_xl, new_xl);
+
+ return ret;
+}
int
glusterfs_graph_destroy (glusterfs_graph_t *graph)
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 2074c143c..393088019 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -749,6 +749,12 @@ xlator_set_type (xlator_t *xl,
dlerror ());
}
+ if (!(xl->reconfigure = dlsym (handle, "reconfigure"))) {
+ gf_log ("xlator", GF_LOG_ERROR,
+ "dlsym(reconfigure) on %s -- neglecting",
+ dlerror());
+ }
+
INIT_LIST_HEAD (&xl->volume_options);
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
@@ -910,6 +916,35 @@ xlator_fini_rec (xlator_t *xl)
}
}
+static void
+xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
+{
+ xlator_list_t *trav1 = NULL;
+ xlator_list_t *trav2 = NULL;
+
+ if (old_xl == NULL || new_xl == NULL) {
+ gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ return;
+ }
+
+ trav1 = old_xl->children;
+ trav2 = new_xl->children;
+
+ while (trav1 && trav2) {
+ xlator_reconfigure_rec (trav1->xlator, trav2->xlator);
+
+ gf_log (trav1->xlator->name, GF_LOG_DEBUG, "reconfigured");
+
+ trav1 = trav1->next;
+ trav2 = trav2->next;
+ }
+
+ if (old_xl->reconfigure)
+ old_xl->reconfigure (old_xl, new_xl->options);
+ else
+ gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found");
+
+}
int
xlator_notify (xlator_t *xl, int event, void *data, ...)
@@ -976,6 +1011,23 @@ xlator_tree_fini (xlator_t *xl)
xlator_fini_rec (top);
}
+int
+xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl)
+{
+ xlator_t *new_top = NULL;
+ xlator_t *old_top = NULL;
+
+ GF_ASSERT (old_xl);
+ GF_ASSERT (new_xl);
+
+ old_top = old_xl;
+ new_top = new_xl;
+
+ xlator_reconfigure_rec (old_top, new_top);
+
+ return 0;
+}
+
int
xlator_tree_free (xlator_t *tree)
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 2aa9b372b..84ad990d4 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -806,6 +806,7 @@ struct _xlator {
void (*fini) (xlator_t *this);
int32_t (*init) (xlator_t *this);
+ int32_t (*reconfigure) (xlator_t *this, dict_t *options);
int32_t (*mem_acct_init) (xlator_t *this);
event_notify_fn_t notify;
@@ -854,6 +855,7 @@ int loc_copy (loc_t *dst, loc_t *src);
#define loc_dup(src, dst) loc_copy(dst, src)
void loc_wipe (loc_t *loc);
int xlator_mem_acct_init (xlator_t *xl, int num_types);
+int xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl);
#define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"