summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2012-04-29 23:08:42 +0530
committerAnand Avati <avati@redhat.com>2012-05-08 22:14:01 -0700
commit53a09f49abb291625c96409627cba348f0c35e55 (patch)
treeda830022b780f277e7baca43e55a861877810943 /xlators/mgmt/glusterd/src/glusterd-utils.c
parent8af87a7ff4da6791a339e2bdb159a4b0c4a66c30 (diff)
mgmt/glusterd: Avoid re-starting nfs unconditionally.
NFS server is restarted unconditionally when a volume option is configured through the set interface. This patch prevents restart of NFS server when operations are performed on translators that are not part of the NFS graph. This does not prevent re-start of a NFS server when an option corresponding to a translator that is part of the NFS graph is re-configured. Change-Id: Ic4b8e48e5e7e80438f230521042c267ec3b96a25 Signed-off-by: Vijay Bellur <vijay@gluster.com> Reviewed-on: http://review.gluster.com/3247 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Bhat <raghavendrabhat@gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c81
1 files changed, 80 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 0f77350c181..8e28a7a1b3c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3181,6 +3181,28 @@ glusterd_reconfigure_shd ()
}
int
+glusterd_reconfigure_nfs ()
+{
+ int ret = -1;
+ gf_boolean_t identical = _gf_false;
+
+ ret = glusterd_check_nfs_volfile_identical (&identical);
+ if (ret)
+ goto out;
+
+ if (identical) {
+ ret = 0;
+ goto out;
+ }
+
+ ret = glusterd_check_generate_start_nfs ();
+
+out:
+ return ret;
+}
+
+
+int
glusterd_check_generate_start_nfs ()
{
int ret = 0;
@@ -3304,7 +3326,7 @@ int
glusterd_nodesvcs_handle_reconfigure (glusterd_volinfo_t *volinfo)
{
return glusterd_nodesvcs_batch_op (volinfo,
- glusterd_check_generate_start_nfs,
+ glusterd_reconfigure_nfs,
glusterd_reconfigure_shd);
}
@@ -5459,3 +5481,60 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo,
return ret;
}
+
+int
+glusterd_check_files_identical (char *filename1, char *filename2,
+ gf_boolean_t *identical)
+{
+ int ret = -1;
+ struct stat buf1 = {0,};
+ struct stat buf2 = {0,};
+ uint32_t cksum1 = 0;
+ uint32_t cksum2 = 0;
+ xlator_t *this = NULL;
+
+ GF_ASSERT (filename1);
+ GF_ASSERT (filename2);
+ GF_ASSERT (identical);
+
+ this = THIS;
+
+ ret = stat (filename1, &buf1);
+
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "stat on file: %s failed "
+ "(%s)", filename1, strerror (errno));
+ goto out;
+ }
+
+ ret = stat (filename2, &buf2);
+
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "stat on file: %s failed "
+ "(%s)", filename2, strerror (errno));
+ goto out;
+ }
+
+ if (buf1.st_size != buf2.st_size) {
+ *identical = _gf_false;
+ goto out;
+ }
+
+ ret = get_checksum_for_path (filename1, &cksum1);
+ if (ret)
+ goto out;
+
+
+ ret = get_checksum_for_path (filename2, &cksum2);
+ if (ret)
+ goto out;
+
+ if (cksum1 != cksum2)
+ *identical = _gf_false;
+ else
+ *identical = _gf_true;
+
+out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ return ret;
+}