From 5c9c2555911d8d7131e3c0d918f6ee9c0b3b612f Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Fri, 15 Apr 2011 09:15:23 +0000 Subject: mgmt/glusterd: does not allow disabling of indexing (xtime marking), if a gsync session is active. Signed-off-by: Kaushik BV Signed-off-by: Anand Avati BUG: 2559 (provide two options in CLI for gluster volume gsync indexing ) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2559 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 4 +- xlators/mgmt/glusterd/src/glusterd-op-sm.h | 2 + xlators/mgmt/glusterd/src/glusterd-volgen.c | 62 ++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 578b39363..64eb688ef 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -110,8 +110,6 @@ typedef struct glusterd_quota_child_info { static int glusterd_restart_brick_servers (glusterd_volinfo_t *); -static int -glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag); char* @@ -2351,7 +2349,7 @@ out: return ret; } -static int +int glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag) { diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h index 52e36ed3a..d550b108c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -306,4 +306,6 @@ gsync_status (char *master, char *slave, int *status); int glusterd_gsync_get_param_file (char *prmfile, const char *ext, char *master, char *slave, char *gl_workdir); +int +glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 1cea50bda..d5c5d5bdb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -35,6 +35,7 @@ #include "glusterd-mem-types.h" #include "cli1.h" #include "glusterd-volgen.h" +#include "glusterd-op-sm.h" /* dispatch table for VOLUME SET @@ -155,6 +156,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = { {VKEY_PERF_STAT_PREFETCH, "performance/stat-prefetch", "!perf", "on", NO_DOC, 0}, {VKEY_MARKER_XTIME, "features/marker", "xtime", "off", NO_DOC, OPT_FLAG_FORCE}, + {VKEY_MARKER_XTIME, "features/marker", "!xtime", "off", NO_DOC, OPT_FLAG_FORCE}, {"nfs.enable-ino32", "nfs/server", "nfs.enable-ino32", NULL, GLOBAL_DOC, 0}, {"nfs.mem-factor", "nfs/server", "nfs.mem-factor", NULL, GLOBAL_DOC, 0}, @@ -1168,13 +1170,69 @@ loglevel_option_handler (glusterfs_graph_t *graph, return basic_option_handler (graph, &vme2, NULL); } +static int +server_check_marker_off (struct volopt_map_entry *vme, + glusterd_volinfo_t *volinfo) +{ + gf_boolean_t bool = _gf_false; + int ret = 0; + + GF_ASSERT (volinfo); + GF_ASSERT (vme); + + if (strcmp (vme->option, "!xtime") != 0) + return 0; + + ret = gf_string2boolean (vme->value, &bool); + if (ret || bool) + goto out; + + ret = glusterd_volinfo_get_boolean (volinfo, VKEY_MARKER_XTIME); + if (ret < 0) { + gf_log ("", GF_LOG_WARNING, "failed to get the marker status"); + ret = -1; + goto out; + } + + if (ret) { + bool = _gf_false; + ret = glusterd_check_gsync_running (volinfo, &bool); + + if (bool) { + gf_log ("", GF_LOG_WARNING, "Gsync sessions active" + "for the volume %s, cannot disable marker " + ,volinfo->volname); + ret = -1; + goto out; + } + + if (ret) { + gf_log ("", GF_LOG_WARNING, "Unable to get the status" + " of active gsync session"); + goto out; + } + } + + ret = 0; + out: + gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + return ret; + +} + static int server_spec_option_handler (glusterfs_graph_t *graph, struct volopt_map_entry *vme, void *param) { - int ret = 0; + int ret = 0; + glusterd_volinfo_t *volinfo = NULL; + + volinfo = param; ret = server_auth_option_handler (graph, vme, NULL); + if (!ret) + ret = server_check_marker_off (vme, volinfo); + if (!ret) ret = loglevel_option_handler (graph, vme, "brick"); @@ -1272,7 +1330,7 @@ server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, if (ret) return -1; - ret = volgen_graph_set_options_generic (graph, set_dict, NULL, + ret = volgen_graph_set_options_generic (graph, set_dict, volinfo, &server_spec_option_handler); return ret; -- cgit