summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-07-08 05:45:58 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-08 05:24:54 -0700
commit6779d91ea8ee8bb8f337213b0be2d31e4fd62619 (patch)
treef9aa24c0e0217a93639b781023164b84c026c1cc /libglusterfs
parentf605883c4fe99428c560a18a1051693f7aadf84e (diff)
fix fuse volume creation from volfile
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/graph.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 2609b7625..af962107d 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -194,6 +194,61 @@ err:
int
+glusterfs_set_master (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
+{
+ xlator_t *trav = NULL;
+ xlator_list_t *chp = NULL, **chpp = NULL;
+
+ for (trav = graph->first; trav; trav = trav->next) {
+ if (strcmp (trav->type, "mount/fuse") != 0)
+ continue;
+
+ if (ctx->master) {
+ gf_log ("graph", GF_LOG_ERROR,
+ "there can be at most one fuse volume");
+
+ return -1;
+ }
+
+ if (!trav->children || trav->children->next) {
+ gf_log ("graph", GF_LOG_ERROR,
+ "fuse volume not configured with exactly one "
+ "child");
+ return -1;
+ }
+
+ if (xlator_has_parent (trav)) {
+ gf_log ("graph", GF_LOG_ERROR,
+ "fuse volume cannot have parents");
+
+ return -1;
+ }
+
+ ctx->master = trav;
+ if (trav == graph->top)
+ graph->top = trav->children->xlator;
+ for (chpp = &trav->children->xlator->parents;
+ *chpp;
+ chpp = &(*chpp)->next) {
+ if ((*chpp)->xlator == trav) {
+ chp = *chpp;
+ *chpp = chp->next;
+ GF_FREE (chp);
+ if (!*chpp)
+ break;
+ }
+ }
+ if (trav == graph->first)
+ graph->first = trav->next;
+ if (trav->prev)
+ trav->prev->next = trav->next;
+ }
+
+ return 0;
+}
+
+
+int
glusterfs_graph_readonly (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
{
int ret = 0;
@@ -383,6 +438,11 @@ glusterfs_graph_settop (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
for (trav = graph->first; trav; trav = trav->next) {
if (strcmp (trav->name, volume_name) == 0) {
+ if (strcmp (trav->type, "mount/fuse") == 0) {
+ gf_log ("graph", GF_LOG_ERROR,
+ "fuse volume cannot be set as top");
+ break;
+ }
graph->top = trav;
return 0;
}
@@ -428,6 +488,11 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
if (ret)
return -1;
+ /* XXX: take fuse from volfile */
+ ret = glusterfs_set_master (graph, ctx);
+ if (ret)
+ return -1;
+
/* XXX: RO VOLUME */
ret = glusterfs_graph_readonly (graph, ctx);
if (ret)