diff options
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 133 |
1 files changed, 53 insertions, 80 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index fd3b4792c..1cea50bda 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1181,83 +1181,7 @@ server_spec_option_handler (glusterfs_graph_t *graph, 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 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, VKEY_MARKER_XTIME, - &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 void get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo); static int server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, @@ -1270,6 +1194,8 @@ 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,}; int ret = 0; path = param; @@ -1326,9 +1252,13 @@ server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo, xl = volgen_graph_add (graph, "features/marker", volname); if (!xl) return -1; - - ret = glusterd_gsync_option_set (volinfo, xl, set_dict); - if (ret < 0) + 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); @@ -1885,12 +1815,55 @@ 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,}; int ret = -1; + ret = glusterd_volinfo_get_boolean (volinfo, VKEY_MARKER_XTIME); + if (ret == -1) + return -1; + + get_vol_tstamp_file (tstamp_file, volinfo); + + if (ret) { + 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, |