diff options
author | Mohammed Junaid Ahmed <junaid@gluster.com> | 2011-03-21 07:16:17 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-22 00:52:18 -0700 |
commit | 50ab0ad4ffb5ea844c6fe1f708df65b769c88db1 (patch) | |
tree | 152155aea86844c2831251c6489269adb409539f /xlators/mgmt/glusterd/src | |
parent | 1ef501b5c526a2dec6592cb8693996a81e5834c4 (diff) |
mgmt/glusterd: Glusterfsd not restarted on changes to marker option.
Bricks are not restarted when some marker options are changed and the Marker
translator is included statically in the server volfile.
Signed-off-by: Junaid <junaid@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2529 (Starting Gsync causes ENOTCONN to glusterfs client)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2529
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 106 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 167 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.h | 2 |
3 files changed, 110 insertions, 165 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index f27e260bd..6a4ffea2a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3887,53 +3887,10 @@ out: } int32_t -glusterd_marker_dict_set (glusterd_volinfo_t *volinfo, char *value) +glusterd_marker_create_volfile (glusterd_volinfo_t *volinfo) { int32_t ret = 0; - char *marker_gsync = NULL; - gf_boolean_t flag = _gf_false; - char *quota = NULL; - ret = gf_string2boolean (value, &flag); - if (ret < 0) - goto out; - - if (flag == _gf_true) { - ret = dict_set_dynstr (volinfo->dict, MARKER_VOL_KEY, value); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Setting dict failed"); - goto out; - } - goto create_vol; - } - - ret = glusterd_volinfo_get (volinfo, "features.marker_gsync", &marker_gsync); - if (ret) - return -1; - - ret = glusterd_volinfo_get (volinfo, "features.quota", "a); - if (ret) - return -1; - - ret = gf_string2boolean (marker_gsync, &flag); - if (ret < 0) - goto out; - - if (flag == _gf_false) { - ret = gf_string2boolean (marker_gsync, &flag); - if (ret < 0) - goto out; - - if (flag == _gf_false) { - ret = dict_set_dynstr (volinfo->dict, MARKER_VOL_KEY, value); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Setting dict failed"); - goto out; - } - } - } - -create_vol: ret = glusterd_create_volfiles (volinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to create volfile" @@ -3942,14 +3899,6 @@ create_vol: goto out; } - ret = glusterd_restart_brick_servers (volinfo); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to restart bricks" - " for setting of marker while 'gsync start'"); - ret = -1; - goto out; - } - ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); if (ret) goto out; @@ -3986,7 +3935,7 @@ glusterd_set_marker_gsync (char *master, char *value) if (ret < 0) goto out; - ret = glusterd_marker_dict_set (volinfo, value); + ret = glusterd_marker_create_volfile (volinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "Setting dict failed"); goto out; @@ -4282,7 +4231,7 @@ glusterd_quota_get_limit_value (char *quota_limits, char *path) } char* -_glusterd_quota_glusted_quota_get_limit_usages (glusterd_volinfo_t *volinfo, +_glusterd_quota_get_limit_usages (glusterd_volinfo_t *volinfo, char *path, char **op_errstr) { int32_t ret = 0; @@ -4308,11 +4257,11 @@ _glusterd_quota_glusted_quota_get_limit_usages (glusterd_volinfo_t *volinfo, } int32_t -glusted_quota_get_limit_usages (glusterd_conf_t *priv, - glusterd_volinfo_t *volinfo, - char *volname, - dict_t *dict, - char **op_errstr) +glusterd_quota_get_limit_usages (glusterd_conf_t *priv, + glusterd_volinfo_t *volinfo, + char *volname, + dict_t *dict, + char **op_errstr) { int32_t i = 0; int32_t ret = 0; @@ -4331,7 +4280,7 @@ glusted_quota_get_limit_usages (glusterd_conf_t *priv, goto out; if (count == 0) { - ret_str = _glusterd_quota_glusted_quota_get_limit_usages (volinfo, NULL, op_errstr); + ret_str = _glusterd_quota_get_limit_usages (volinfo, NULL, op_errstr); } else { i = 0; while (count--) { @@ -4341,7 +4290,7 @@ glusted_quota_get_limit_usages (glusterd_conf_t *priv, if (ret < 0) goto out; - ret_str = _glusterd_quota_glusted_quota_get_limit_usages (volinfo, path, op_errstr); + ret_str = _glusterd_quota_get_limit_usages (volinfo, path, op_errstr); } } @@ -4393,10 +4342,6 @@ glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr, goto out; } - ret = glusterd_marker_dict_set (volinfo, status); - if (ret) - goto out; - *crawl = _gf_true; ret = 0; @@ -4437,9 +4382,6 @@ glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr) goto out; } - ret = glusterd_marker_dict_set (volinfo, quota_status); - - ret = 0; out: return ret; } @@ -4613,25 +4555,34 @@ glusterd_op_quota (dict_t *dict, char **op_errstr) if (type == GF_QUOTA_OPTION_TYPE_ENABLE) { ret = glusterd_quota_enable (volinfo, op_errstr, &start_crawl); - goto out; + if (ret < 0) + goto out; + + goto create_vol; } if (type == GF_QUOTA_OPTION_TYPE_DISABLE) { ret = glusterd_quota_disable (volinfo, op_errstr); + if (ret < 0) + goto out; - goto out; + goto create_vol; } if (type == GF_QUOTA_OPTION_TYPE_LIMIT_USAGE) { ret = glusterd_quota_limit_usage (volinfo, dict, op_errstr); if (ret < 0) goto out; + + goto create_vol; } if (type == GF_QUOTA_OPTION_TYPE_REMOVE) { ret = glusterd_quota_remove_limits (volinfo, dict, op_errstr); if (ret < 0) goto out; + + goto create_vol; } if (type == GF_QUOTA_OPTION_TYPE_LIST) { @@ -4642,11 +4593,11 @@ glusterd_op_quota (dict_t *dict, char **op_errstr) goto out; } - glusted_quota_get_limit_usages (priv, volinfo, volname, dict, op_errstr); + glusterd_quota_get_limit_usages (priv, volinfo, volname, dict, op_errstr); goto out; } - +create_vol: ret = glusterd_create_volfiles (volinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to re-create volfile for" @@ -4826,13 +4777,6 @@ glusterd_op_set_volume (dict_t *dict) goto out; } - if (strcmp (key, MARKER_VOL_KEY) == 0 && - GLUSTERD_STATUS_STARTED == volinfo->status) { - - restart_flag = 1; - } - - if (key_fixed) { GF_FREE (key_fixed); @@ -6704,7 +6648,7 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr, break; case GD_OP_QUOTA: - ret = glusterd_op_quota (dict, op_errstr); + ret = glusterd_op_stage_quota (dict, op_errstr); break; default: @@ -6783,7 +6727,7 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, break; case GD_OP_QUOTA: - ret = glusterd_op_stage_quota (dict, op_errstr); + ret = glusterd_op_quota (dict, op_errstr); break; default: diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index a61eb2011..3ac6f2895 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -140,8 +140,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = { {"performance.quick-read", "performance/quick-read", "!perf", "on", NO_DOC}, /* NODOC */ {"performance.stat-prefetch", "performance/stat-prefetch", "!perf", "on", NO_DOC}, /* NODOC */ - {MARKER_VOL_KEY, "features/marker", "!marker", "off", NO_DOC}, - {"features.marker_gsync", "features/marker", "gsync", "off"}, + {"features.marker_gsync", "features/marker", "gsync", "off", NO_DOC}, {"nfs.enable-ino32", "nfs/server", "nfs.enable-ino32", NULL, GLOBAL_DOC}, {"nfs.mem-factor", "nfs/server", "nfs.mem-factor", NULL, GLOBAL_DOC}, @@ -164,9 +163,9 @@ static struct volopt_map_entry glusterd_volopt_map[] = { {"nfs.export-dir", "nfs/server", "!nfs-export-dir", NULL, DOC}, {"nfs.disable", "nfs/server", "!nfs-disable", NULL, DOC}, - {"features.quota", "features/quota", "quota", "off"}, - {"features.quota", "features/marker", "quota", "off"}, - {"features.limit-usage", "features/quota", "limit-set", NULL}, + {"features.quota", "features/quota", "quota", "off", NO_DOC}, + {"features.quota", "features/marker", "quota", "off", NO_DOC}, + {"features.limit-usage", "features/quota", "limit-set", NULL, NO_DOC}, {NULL, } }; @@ -1114,7 +1113,83 @@ server_spec_option_handler (glusterfs_graph_t *graph, return ret; } -static void get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo); +static void +get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo) +{ + glusterd_conf_t *priv = NULL; + + priv = THIS->private; + + GLUSTERD_GET_VOLUME_DIR (filename, volinfo, priv); + strncat (filename, "/marker.tstamp", + PATH_MAX - strlen(filename) - 1); +} + +static int32_t +glusterd_gsync_option_set (glusterd_volinfo_t *volinfo, + xlator_t *xl, dict_t *set_dict) +{ + int32_t ret = -1; + char *gsync_val = NULL; + gf_boolean_t gsync = _gf_false; + char volume_id [64] = {0, }; + char tstamp_file[PATH_MAX] = {0,}; + + GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out); + GF_VALIDATE_OR_GOTO ("glusterd", xl, out); + GF_VALIDATE_OR_GOTO ("glusterd", set_dict, out); + + ret = volgen_dict_get (set_dict, "features.marker_gsync", + &gsync_val); + if (ret) + return -1; + + if (gsync_val) + ret = gf_string2boolean (gsync_val, &gsync); + if (ret) { + gf_log ("", GF_LOG_ERROR, + "value for marker_gsync option is junk"); + return -1; + } + get_vol_tstamp_file (tstamp_file, volinfo); + if (gsync == _gf_false) { + ret = unlink (tstamp_file); + if (ret == -1 && errno == ENOENT) + ret = 0; + if (ret == -1) { + gf_log ("", GF_LOG_ERROR, "failed to unlink %s (%s)", + tstamp_file, strerror (errno)); + return -1; + } + goto out; + } + + ret = open (tstamp_file, O_WRONLY|O_CREAT|O_EXCL, 0644); + if (ret == -1 && errno == EEXIST) { + gf_log ("", GF_LOG_DEBUG, "timestamp file exist"); + ret = -2; + } + if (ret == -1) { + gf_log ("", GF_LOG_WARNING, "failed to create %s (%s)", + tstamp_file, strerror (errno)); + return -1; + } + if (ret >= 0) + close (ret); + + uuid_unparse (volinfo->volume_id, volume_id); + ret = xlator_set_option (xl, "volume-uuid", volume_id); + if (ret) + return -1; + + ret = xlator_set_option (xl, "timestamp-file", tstamp_file); + if (ret) + return -1; + + ret = 0; +out: + return ret; +} static int server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, @@ -1127,10 +1202,6 @@ server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, xlator_t *txl = NULL; xlator_t *rbxl = NULL; char transt[16] = {0,}; - char volume_id[64] = {0,}; - char tstamp_file[PATH_MAX] = {0,}; - char *marker_val = NULL; - gf_boolean_t marker = _gf_false; int ret = 0; path = param; @@ -1184,29 +1255,13 @@ server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, if (!xl) return -1; - ret = volgen_dict_get (set_dict, MARKER_VOL_KEY, &marker_val); - if (ret) + xl = volgen_graph_add (graph, "features/marker", volname); + if (!xl) return -1; - if (marker_val) - ret = gf_string2boolean (marker_val, &marker); - if (ret) { - gf_log ("", GF_LOG_ERROR, "value for "MARKER_VOL_KEY" option is junk"); + ret = glusterd_gsync_option_set (volinfo, xl, set_dict); + if (ret < 0) return -1; - } - if (marker) { - xl = volgen_graph_add (graph, "features/marker", volname); - if (!xl) - return -1; - uuid_unparse (volinfo->volume_id, volume_id); - ret = xlator_set_option (xl, "volume-uuid", volume_id); - if (ret) - return -1; - get_vol_tstamp_file (tstamp_file, volinfo); - ret = xlator_set_option (xl, "timestamp-file", tstamp_file); - if (ret) - return -1; - } xl = volgen_graph_add_as (graph, "debug/io-stats", path); if (!xl) @@ -1774,64 +1829,12 @@ glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo, return ret; } -static void -get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo) -{ - glusterd_conf_t *priv = NULL; - - priv = THIS->private; - - GLUSTERD_GET_VOLUME_DIR (filename, volinfo, priv); - strncat (filename, "/marker.tstamp", - PATH_MAX - strlen(filename) - 1); -} - static int generate_brick_volfiles (glusterd_volinfo_t *volinfo) { glusterd_brickinfo_t *brickinfo = NULL; - char tstamp_file[PATH_MAX] = {0,}; - char *marker_val = NULL; - gf_boolean_t marker = _gf_false; int ret = -1; - ret = glusterd_volinfo_get (volinfo, MARKER_VOL_KEY, &marker_val); - if (ret) - return -1; - if (marker_val) - ret = gf_string2boolean (marker_val, &marker); - if (ret) { - gf_log ("", GF_LOG_ERROR, "value for "MARKER_VOL_KEY" option is junk"); - - return -1; - } - - get_vol_tstamp_file (tstamp_file, volinfo); - - if (marker) { - ret = open (tstamp_file, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (ret == -1 && errno == EEXIST) { - gf_log ("", GF_LOG_DEBUG, "timestamp file exist"); - ret = -2; - } - if (ret == -1) { - gf_log ("", GF_LOG_ERROR, "failed to create %s (%s)", - tstamp_file, strerror (errno)); - return -1; - } - if (ret >= 0) - close (ret); - } else { - ret = unlink (tstamp_file); - if (ret == -1 && errno == ENOENT) - ret = 0; - if (ret == -1) { - gf_log ("", GF_LOG_ERROR, "failed to unlink %s (%s)", - tstamp_file, strerror (errno)); - return -1; - } - } - list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { gf_log ("", GF_LOG_DEBUG, "Found a brick - %s:%s", brickinfo->hostname, diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index 4f4b4b73d..3e56b5628 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -27,8 +27,6 @@ #include "glusterd.h" -#define MARKER_VOL_KEY "monitor.xtime-marker" - int glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); |