diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-bitd-svc.c | 64 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-nfs-svc.c | 116 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 15 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quotad-svc.c | 82 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quotad-svc.h | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-scrub-svc.c | 69 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 66 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 129 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-svc-helper.h | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.h | 12 |
14 files changed, 420 insertions, 171 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c index 6b606f874b5..ee96ccbff80 100644 --- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c @@ -14,6 +14,7 @@ #include "glusterd-utils.h" #include "glusterd-volgen.h" #include "glusterd-bitd-svc.h" +#include "glusterd-svc-helper.h" void glusterd_bitdsvc_build (glusterd_svc_t *svc) @@ -141,5 +142,66 @@ glusterd_bitdsvc_stop (glusterd_svc_t *svc, int sig) int glusterd_bitdsvc_reconfigure () { - return glusterd_svc_reconfigure (glusterd_bitdsvc_create_volfile); + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + gf_boolean_t identical = _gf_false; + + this = THIS; + GF_VALIDATE_OR_GOTO (this->name, this, out); + + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, out); + + if (glusterd_should_i_stop_bitd ()) + goto manager; + /* + * Check both OLD and NEW volfiles, if they are SAME by size + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ + ret = glusterd_svc_check_volfile_identical (priv->bitd_svc.name, + build_bitd_graph, + &identical); + if (ret) + goto out; + if (identical) { + ret = 0; + goto out; + } + + /* + * They are not identical. Find out if the topology is changed + * OR just the volume options. If just the options which got + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ + ret = glusterd_svc_check_topology_identical (priv->bitd_svc.name, + build_bitd_graph, + &identical); + if (ret) + goto out; /*not able to compare due to some corruption */ + + /* Topology is not changed, but just the options. But write the + * options to bitd volfile, so that bitd will be reconfigured. + */ + if (identical) { + ret = glusterd_bitdsvc_create_volfile (); + if (ret == 0) {/* Only if above PASSES */ + ret = glusterd_fetchspec_notify (THIS); + } + goto out; + } + +manager: + /* + * bitd volfile's topology has been changed. bitd server needs + * to be RESTARTED to ACT on the changed volfile. + */ + ret = priv->bitd_svc.manager (&(priv->bitd_svc), NULL, + PROC_START_NO_WAIT); + +out: + gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 6b5bdafd582..76a05b2ef93 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -2406,7 +2406,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) if (start_remove && volinfo->status == GLUSTERD_STATUS_STARTED) { - ret = glusterd_svcs_reconfigure (volinfo); + ret = glusterd_svcs_reconfigure (); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_NFS_RECONF_FAIL, diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 52df83f426c..7e3955465a4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -211,14 +211,9 @@ build_volfile_path (char *volume_id, char *path, } volid_ptr++; - if (strcmp (volid_ptr, "quotad") == 0) - glusterd_quotadsvc_build_volfile_path (volid_ptr, - priv->workdir, - path, path_len); - else - glusterd_svc_build_volfile_path (volid_ptr, - priv->workdir, - path, path_len); + glusterd_svc_build_volfile_path (volid_ptr, + priv->workdir, + path, path_len); ret = 0; goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c index b1d98146877..ea24c1e1d25 100644 --- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c @@ -15,6 +15,7 @@ #include "glusterd-volgen.h" #include "glusterd-nfs-svc.h" #include "glusterd-messages.h" +#include "glusterd-svc-helper.h" char *nfs_svc_name = "nfs"; @@ -66,107 +67,6 @@ glusterd_nfssvc_create_volfile () filepath, NULL); } -static int -glusterd_nfssvc_check_volfile_identical (gf_boolean_t *identical) -{ - char nfsvol[PATH_MAX] = {0,}; - char tmpnfsvol[PATH_MAX] = {0,}; - glusterd_conf_t *conf = NULL; - xlator_t *this = NULL; - int ret = -1; - int need_unlink = 0; - int tmp_fd = -1; - - this = THIS; - - GF_ASSERT (this); - GF_ASSERT (identical); - conf = this->private; - - glusterd_svc_build_volfile_path (nfs_svc_name, conf->workdir, - nfsvol, sizeof (nfsvol)); - - snprintf (tmpnfsvol, sizeof (tmpnfsvol), "/tmp/gnfs-XXXXXX"); - - tmp_fd = mkstemp (tmpnfsvol); - if (tmp_fd < 0) { - gf_msg (this->name, GF_LOG_WARNING, errno, - GD_MSG_FILE_OP_FAILED, "Unable to create temp file" - " %s:(%s)", tmpnfsvol, strerror (errno)); - goto out; - } - - need_unlink = 1; - - ret = glusterd_create_global_volfile (build_nfs_graph, - tmpnfsvol, NULL); - if (ret) - goto out; - - ret = glusterd_check_files_identical (nfsvol, tmpnfsvol, - identical); - if (ret) - goto out; - -out: - if (need_unlink) - unlink (tmpnfsvol); - - if (tmp_fd >= 0) - close (tmp_fd); - - return ret; -} - -static int -glusterd_nfssvc_check_topology_identical (gf_boolean_t *identical) -{ - char nfsvol[PATH_MAX] = {0,}; - char tmpnfsvol[PATH_MAX] = {0,}; - glusterd_conf_t *conf = NULL; - xlator_t *this = THIS; - int ret = -1; - int tmpclean = 0; - int tmpfd = -1; - - if ((!identical) || (!this) || (!this->private)) - goto out; - - conf = (glusterd_conf_t *) this->private; - GF_ASSERT (conf); - - /* Fetch the original NFS volfile */ - glusterd_svc_build_volfile_path (conf->nfs_svc.name, conf->workdir, - nfsvol, sizeof (nfsvol)); - - /* Create the temporary NFS volfile */ - snprintf (tmpnfsvol, sizeof (tmpnfsvol), "/tmp/gnfs-XXXXXX"); - tmpfd = mkstemp (tmpnfsvol); - if (tmpfd < 0) { - gf_msg (this->name, GF_LOG_WARNING, errno, - GD_MSG_FILE_OP_FAILED, "Unable to create temp file" - " %s: (%s)", tmpnfsvol, strerror (errno)); - goto out; - } - - tmpclean = 1; /* SET the flag to unlink() tmpfile */ - - ret = glusterd_create_global_volfile (build_nfs_graph, - tmpnfsvol, NULL); - if (ret) - goto out; - - /* Compare the topology of volfiles */ - ret = glusterd_check_topology_identical (nfsvol, tmpnfsvol, - identical); -out: - if (tmpfd >= 0) - close (tmpfd); - if (tmpclean) - unlink (tmpnfsvol); - return ret; -} - int glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags) { @@ -246,17 +146,18 @@ glusterd_nfssvc_reconfigure () gf_boolean_t identical = _gf_false; this = THIS; - GF_ASSERT (this); + GF_VALIDATE_OR_GOTO (this->name, this, out); priv = this->private; - GF_ASSERT (priv); - + GF_VALIDATE_OR_GOTO (this->name, priv, out); /* * Check both OLD and NEW volfiles, if they are SAME by size * and cksum i.e. "character-by-character". If YES, then * NOTHING has been changed, just return. */ - ret = glusterd_nfssvc_check_volfile_identical (&identical); + ret = glusterd_svc_check_volfile_identical (priv->nfs_svc.name, + build_nfs_graph, + &identical); if (ret) goto out; @@ -271,7 +172,9 @@ glusterd_nfssvc_reconfigure () * changed, then inform the xlator to reconfigure the options. */ identical = _gf_false; /* RESET the FLAG */ - ret = glusterd_nfssvc_check_topology_identical (&identical); + ret = glusterd_svc_check_topology_identical (priv->nfs_svc.name, + build_nfs_graph, + &identical); if (ret) goto out; @@ -294,6 +197,7 @@ glusterd_nfssvc_reconfigure () PROC_START_NO_WAIT); out: + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 40c48817c88..10c2d175ff2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1831,6 +1831,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, data_t *value = NULL; char *key_fixed = NULL; xlator_t *this = NULL; + glusterd_svc_t *svc = NULL; this = THIS; GF_ASSERT (this); @@ -1866,6 +1867,12 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, } gd_update_volume_op_versions (volinfo); + if (!volinfo->is_snap_volume) { + svc = &(volinfo->snapd.svc); + ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT); + if (ret) + goto out; + } ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { @@ -1882,7 +1889,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, goto out; if (GLUSTERD_STATUS_STARTED == volinfo->status) { - ret = glusterd_svcs_reconfigure (volinfo); + ret = glusterd_svcs_reconfigure (); if (ret) goto out; } @@ -2565,7 +2572,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) goto out; if (GLUSTERD_STATUS_STARTED == volinfo->status) { - ret = glusterd_svcs_reconfigure (volinfo); + ret = glusterd_svcs_reconfigure (); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_RESTART_FAIL, @@ -2603,7 +2610,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) goto out; if (GLUSTERD_STATUS_STARTED == volinfo->status) { - ret = glusterd_svcs_reconfigure (volinfo); + ret = glusterd_svcs_reconfigure (); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_NFS_SERVER_START_FAIL, @@ -2819,7 +2826,7 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, goto out; if (GLUSTERD_STATUS_STARTED == volinfo->status) - ret = glusterd_svcs_reconfigure (volinfo); + ret = glusterd_svcs_reconfigure (); ret = 0; diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c index 59a76711054..f3475a3f0ec 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c @@ -15,6 +15,7 @@ #include "glusterd-volgen.h" #include "glusterd-quotad-svc.h" #include "glusterd-messages.h" +#include "glusterd-svc-helper.h" char *quotad_svc_name = "quotad"; @@ -36,13 +37,6 @@ int glusterd_quotadsvc_init (glusterd_svc_t *svc) if (ret) goto out; - /* glusterd_svc_build_volfile_path () doesn't put correct quotad volfile - * path in proc object at service initialization. Re-initialize - * the correct path - */ - glusterd_quotadsvc_build_volfile_path (quotad_svc_name, conf->workdir, - volfile, sizeof (volfile)); - snprintf (svc->proc.volfile, sizeof (svc->proc.volfile), "%s", volfile); out: return ret; } @@ -53,8 +47,8 @@ glusterd_quotadsvc_create_volfile () char filepath[PATH_MAX] = {0,}; glusterd_conf_t *conf = THIS->private; - glusterd_quotadsvc_build_volfile_path (quotad_svc_name, conf->workdir, - filepath, sizeof (filepath)); + glusterd_svc_build_volfile_path (quotad_svc_name, conf->workdir, + filepath, sizeof (filepath)); return glusterd_create_global_volfile (build_quotad_graph, filepath, NULL); } @@ -162,17 +156,67 @@ out: int glusterd_quotadsvc_reconfigure () { - return glusterd_svc_reconfigure (glusterd_quotadsvc_create_volfile); -} + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + gf_boolean_t identical = _gf_false; -void -glusterd_quotadsvc_build_volfile_path (char *server, char *workdir, - char *volfile, size_t len) -{ - char dir[PATH_MAX] = {0,}; + this = THIS; + GF_VALIDATE_OR_GOTO (this->name, this, out); + + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, out); + + if (glusterd_all_volumes_with_quota_stopped ()) + goto manager; + + /* + * Check both OLD and NEW volfiles, if they are SAME by size + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ + ret = glusterd_svc_check_volfile_identical (priv->quotad_svc.name, + build_quotad_graph, + &identical); + if (ret) + goto out; + + if (identical) { + ret = 0; + goto out; + } + + /* + * They are not identical. Find out if the topology is changed + * OR just the volume options. If just the options which got + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ + ret = glusterd_svc_check_topology_identical (priv->quotad_svc.name, + build_quotad_graph, + &identical); + if (ret) + goto out; - GF_ASSERT (len == PATH_MAX); + /* Topology is not changed, but just the options. But write the + * options to quotad volfile, so that quotad will be reconfigured. + */ + if (identical) { + ret = glusterd_quotadsvc_create_volfile (); + if (ret == 0) {/* Only if above PASSES */ + ret = glusterd_fetchspec_notify (THIS); + } + goto out; + } +manager: + /* + * quotad volfile's topology has been changed. quotad server needs + * to be RESTARTED to ACT on the changed volfile. + */ + ret = priv->quotad_svc.manager (&(priv->quotad_svc), NULL, + PROC_START_NO_WAIT); - glusterd_svc_build_svcdir (server, workdir, dir, sizeof (dir)); - snprintf (volfile, len, "%s/%s.vol", dir, server); +out: + gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h index b330c5cf405..91da50dc36d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h +++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.h @@ -28,7 +28,4 @@ glusterd_quotadsvc_manager (glusterd_svc_t *svc, void *data, int flags); int glusterd_quotadsvc_reconfigure (); -void -glusterd_quotadsvc_build_volfile_path (char *server, char *workdir, - char *volfile, size_t len); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c index b5c97850a75..3761dbadfd1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c @@ -14,6 +14,7 @@ #include "glusterd-utils.h" #include "glusterd-volgen.h" #include "glusterd-scrub-svc.h" +#include "glusterd-svc-helper.h" char *scrub_svc_name = "scrub"; @@ -136,5 +137,71 @@ glusterd_scrubsvc_stop (glusterd_svc_t *svc, int sig) int glusterd_scrubsvc_reconfigure () { - return glusterd_svc_reconfigure (glusterd_scrubsvc_create_volfile); + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + gf_boolean_t identical = _gf_false; + + this = THIS; + GF_VALIDATE_OR_GOTO (this->name, this, out); + + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, out); + + if (glusterd_should_i_stop_bitd ()) + goto manager; + + + /* + * Check both OLD and NEW volfiles, if they are SAME by size + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ + ret = glusterd_svc_check_volfile_identical (priv->scrub_svc.name, + build_scrub_graph, + &identical); + if (ret) + goto out; + + if (identical) { + ret = 0; + goto out; + } + + /* + * They are not identical. Find out if the topology is changed + * OR just the volume options. If just the options which got + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ + ret = glusterd_svc_check_topology_identical (priv->scrub_svc.name, + build_scrub_graph, + &identical); + if (ret) + goto out; + + /* Topology is not changed, but just the options. But write the + * options to scrub volfile, so that scrub will be reconfigured. + */ + if (identical) { + ret = glusterd_scrubsvc_create_volfile (); + if (ret == 0) {/* Only if above PASSES */ + ret = glusterd_fetchspec_notify (THIS); + } + goto out; + } + +manager: + /* + * scrub volfile's topology has been changed. scrub server needs + * to be RESTARTED to ACT on the changed volfile. + */ + ret = priv->scrub_svc.manager (&(priv->scrub_svc), + NULL, + PROC_START_NO_WAIT); + +out: + gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c index f9f41898b39..0e664b5c786 100644 --- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c @@ -15,6 +15,7 @@ #include "glusterd-volgen.h" #include "glusterd-svc-mgmt.h" #include "glusterd-shd-svc.h" +#include "glusterd-svc-helper.h" char *shd_svc_name = "glustershd"; @@ -182,5 +183,68 @@ out: int glusterd_shdsvc_reconfigure () { - return glusterd_svc_reconfigure (glusterd_shdsvc_create_volfile); + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + gf_boolean_t identical = _gf_false; + + this = THIS; + GF_VALIDATE_OR_GOTO (this->name, this, out); + + priv = this->private; + GF_VALIDATE_OR_GOTO (this->name, priv, out); + + if (glusterd_all_shd_compatible_volumes_stopped ()) + goto manager; + + /* + * Check both OLD and NEW volfiles, if they are SAME by size + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ + ret = glusterd_svc_check_volfile_identical (priv->shd_svc.name, + build_shd_graph, + &identical); + if (ret) + goto out; + + if (identical) { + ret = 0; + goto out; + } + + /* + * They are not identical. Find out if the topology is changed + * OR just the volume options. If just the options which got + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ + ret = glusterd_svc_check_topology_identical (priv->shd_svc.name, + build_shd_graph, + &identical); + if (ret) + goto out; + + /* Topology is not changed, but just the options. But write the + * options to shd volfile, so that shd will be reconfigured. + */ + if (identical) { + ret = glusterd_shdsvc_create_volfile (); + if (ret == 0) {/* Only if above PASSES */ + ret = glusterd_fetchspec_notify (THIS); + } + goto out; + } +manager: + /* + * shd volfile's topology has been changed. shd server needs + * to be RESTARTED to ACT on the changed volfile. + */ + ret = priv->shd_svc.manager (&(priv->shd_svc), NULL, + PROC_START_NO_WAIT); + +out: + gf_msg_debug (this->name, 0, "Returning %d", ret); + return ret; + } diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c index c88b613bddd..18136fb6838 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c @@ -19,9 +19,10 @@ #include "glusterd-nfs-svc.h" #include "glusterd-bitd-svc.h" #include "glusterd-scrub-svc.h" +#include "glusterd-svc-helper.h" int -glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo) +glusterd_svcs_reconfigure () { int ret = 0; xlator_t *this = THIS; @@ -36,23 +37,17 @@ glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo) if (ret) goto out; - if (volinfo && !glusterd_is_shd_compatible_volume (volinfo)) { - ; /* Do nothing */ - } else { - ret = glusterd_shdsvc_reconfigure (); - if (ret) - goto out; - } + ret = glusterd_shdsvc_reconfigure (); + if (ret) + goto out; + if (conf->op_version == GD_OP_VERSION_MIN) goto out; - if (volinfo && !glusterd_is_volume_quota_enabled (volinfo)) { - /*Do nothing */ - } else { - ret = glusterd_quotadsvc_reconfigure (); - if (ret) - goto out; - } + ret = glusterd_quotadsvc_reconfigure (); + if (ret) + goto out; + ret = glusterd_bitdsvc_reconfigure (); if (ret) goto out; @@ -153,3 +148,107 @@ out: } +int +glusterd_svc_check_volfile_identical (char *svc_name, + glusterd_graph_builder_t builder, + gf_boolean_t *identical) +{ + char orgvol[PATH_MAX] = {0,}; + char tmpvol[PATH_MAX] = {0,}; + glusterd_conf_t *conf = NULL; + xlator_t *this = NULL; + int ret = -1; + int need_unlink = 0; + int tmp_fd = -1; + + this = THIS; + + GF_ASSERT (this); + GF_ASSERT (identical); + conf = this->private; + + glusterd_svc_build_volfile_path (svc_name, conf->workdir, + orgvol, sizeof (orgvol)); + + snprintf (tmpvol, sizeof (tmpvol), "/tmp/g%s-XXXXXX", svc_name); + + tmp_fd = mkstemp (tmpvol); + if (tmp_fd < 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + GD_MSG_FILE_OP_FAILED, "Unable to create temp file" + " %s:(%s)", tmpvol, strerror (errno)); + goto out; + } + + need_unlink = 1; + + ret = glusterd_create_global_volfile (builder, + tmpvol, NULL); + if (ret) + goto out; + + ret = glusterd_check_files_identical (orgvol, tmpvol, + identical); + if (ret) + goto out; + +out: + if (need_unlink) + unlink (tmpvol); + + if (tmp_fd >= 0) + close (tmp_fd); + + return ret; +} + +int +glusterd_svc_check_topology_identical (char *svc_name, + glusterd_graph_builder_t builder, + gf_boolean_t *identical) +{ + char orgvol[PATH_MAX] = {0,}; + char tmpvol[PATH_MAX] = {0,}; + glusterd_conf_t *conf = NULL; + xlator_t *this = THIS; + int ret = -1; + int tmpclean = 0; + int tmpfd = -1; + + if ((!identical) || (!this) || (!this->private)) + goto out; + + conf = this->private; + GF_VALIDATE_OR_GOTO (this->name, conf, out); + + /* Fetch the original volfile */ + glusterd_svc_build_volfile_path (svc_name, conf->workdir, + orgvol, sizeof (orgvol)); + + /* Create the temporary volfile */ + snprintf (tmpvol, sizeof (tmpvol), "/tmp/g%s-XXXXXX", svc_name); + tmpfd = mkstemp (tmpvol); + if (tmpfd < 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + GD_MSG_FILE_OP_FAILED, "Unable to create temp file" + " %s:(%s)", tmpvol, strerror (errno)); + goto out; + } + + tmpclean = 1; /* SET the flag to unlink() tmpfile */ + + ret = glusterd_create_global_volfile (builder, + tmpvol, NULL); + if (ret) + goto out; + + /* Compare the topology of volfiles */ + ret = glusterd_check_topology_identical (orgvol, tmpvol, + identical); +out: + if (tmpfd >= 0) + close (tmpfd); + if (tmpclean) + unlink (tmpvol); + return ret; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h index c1746b4189c..b5aafefc1b5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h +++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h @@ -13,13 +13,24 @@ #include "glusterd.h" #include "glusterd-svc-mgmt.h" +#include "glusterd-volgen.h" int -glusterd_svcs_reconfigure (glusterd_volinfo_t *volinfo); +glusterd_svcs_reconfigure (); int glusterd_svcs_stop (); int glusterd_svcs_manager (glusterd_volinfo_t *volinfo); + +int +glusterd_svc_check_volfile_identical (char *svc_name, + glusterd_graph_builder_t builder, + gf_boolean_t *identical); +int +glusterd_svc_check_topology_identical (char *svc_name, + glusterd_graph_builder_t builder, + gf_boolean_t *identical); + #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c index 8fba2b6b751..17179aed609 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c @@ -253,7 +253,11 @@ glusterd_svc_build_volfile_path (char *server, char *workdir, char *volfile, GF_ASSERT (len == PATH_MAX); glusterd_svc_build_svcdir (server, workdir, dir, sizeof (dir)); - snprintf (volfile, len, "%s/%s-server.vol", dir, server); + + if (!strcmp(server, "quotad")) /*quotad has different volfile name*/ + snprintf (volfile, len, "%s/%s.vol", dir, server); + else + snprintf (volfile, len, "%s/%s-server.vol", dir, server); } void diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 5ac392c309e..f89a5302315 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -5443,8 +5443,7 @@ out: } int -glusterd_create_global_volfile (int (*builder) (volgen_graph_t *graph, - dict_t *set_dict), +glusterd_create_global_volfile (glusterd_graph_builder_t builder, char *filepath, dict_t *mod_dict) { volgen_graph_t graph = {0,}; diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index cbd3cf38d51..dd46b07fa6e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -61,6 +61,9 @@ struct volgen_graph { }; typedef struct volgen_graph volgen_graph_t; +typedef int (*glusterd_graph_builder_t) (volgen_graph_t *graph, + dict_t *mod_dict); + #define COMPLETE_OPTION(key, completion, ret) \ do { \ if (!strchr (key, '.')) { \ @@ -159,8 +162,7 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, glusterd_volinfo_t *volinfo); int -glusterd_create_global_volfile (int (*builder) (volgen_graph_t *graph, - dict_t *set_dict), +glusterd_create_global_volfile (glusterd_graph_builder_t builder, char *filepath, dict_t *mod_dict); int @@ -263,12 +265,6 @@ end_sethelp_xml_doc (xmlTextWriterPtr writer); char* glusterd_get_trans_type_rb (gf_transport_type ttype); -int -glusterd_check_nfs_volfile_identical (gf_boolean_t *identical); - -int -glusterd_check_nfs_topology_identical (gf_boolean_t *identical); - uint32_t glusterd_get_op_version_for_key (char *key); |