From 6779d91ea8ee8bb8f337213b0be2d31e4fd62619 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Thu, 8 Jul 2010 05:45:58 +0000 Subject: fix fuse volume creation from volfile Signed-off-by: Csaba Henk Signed-off-by: Anand V. Avati BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971 --- libglusterfs/src/graph.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'libglusterfs/src/graph.c') diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index 2609b762..af962107 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -193,6 +193,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) { @@ -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) -- cgit