From 387f4d385e1d2c29af54c4f87eef7a07acfcfdf9 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 28 Sep 2010 05:37:02 +0000 Subject: more proper error returns in case of graph topology validation Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971 --- glusterfsd/src/glusterfsd-mgmt.c | 12 +++--------- libglusterfs/src/graph.c | 5 +---- libglusterfs/src/xlator.c | 9 ++++----- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 341d2267a..96d2c6681 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -252,13 +252,11 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) oldvolfile_graph = glusterfs_graph_construct (oldvolfile_fp); if (!oldvolfile_graph) { - ret = -1; goto out; } newvolfile_graph = glusterfs_graph_construct (newvolfile_fp); if (!oldvolfile_graph) { - ret = -1; goto out; } @@ -267,7 +265,6 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, "Graph topology not equal"); - ret = 0; goto out; } @@ -280,7 +277,6 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) if (!ctx) { gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, "glusterfs_ctx_get() returned NULL"); - ret = -1; goto out; } @@ -289,12 +285,10 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) if (!oldvolfile_graph) { gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, "glsuterfs_ctx->active is NULL"); - ret = -1; goto out; } - - + /* */ ret = glusterfs_graph_reconfigure (oldvolfile_graph, newvolfile_graph); if (ret) { @@ -303,6 +297,7 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) "graph"); } + ret = 0; out: return ret; } @@ -360,11 +355,10 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, /* Check if only options have changed. No need to reload the volfile if topology hasn't changed. */ - ret = glusterfs_volfile_reconfigure (tmpfp); if (!ret) { gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, - "No need to re-load volfile"); + "No need to re-load volfile, reconfigure done"); goto out; } diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index c44fa44ad..0c63c194d 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -501,7 +501,6 @@ glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph, { xlator_t *old_xl = NULL; xlator_t *new_xl = NULL; - int ret = 0; GF_ASSERT (oldgraph); GF_ASSERT (newgraph); @@ -509,9 +508,7 @@ glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph, old_xl = oldgraph->first; new_xl = newgraph->first; - ret = xlator_tree_reconfigure (old_xl, new_xl); - - return ret; + return xlator_tree_reconfigure (old_xl, new_xl); } int diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index ef0808d5d..a09dd2e1e 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -916,7 +916,7 @@ xlator_fini_rec (xlator_t *xl) } } -static void +static int xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) { xlator_list_t *trav1 = NULL; @@ -924,7 +924,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) if (old_xl == NULL || new_xl == NULL) { gf_log ("xlator", GF_LOG_DEBUG, "invalid argument"); - return; + return -1; } trav1 = old_xl->children; @@ -944,6 +944,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) else gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found"); + return 0; } int @@ -1023,9 +1024,7 @@ xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl) old_top = old_xl; new_top = new_xl; - xlator_reconfigure_rec (old_top, new_top); - - return 0; + return xlator_reconfigure_rec (old_top, new_top); } -- cgit