3604df
From 8ca5890039e1960f9366c5031e57173ff0db5db5 Mon Sep 17 00:00:00 2001
3604df
From: Atin Mukherjee <amukherj@redhat.com>
3604df
Date: Mon, 23 Jan 2017 13:03:06 +0530
3604df
Subject: [PATCH 279/285] glusterd: regenerate volfiles on op-version bump up
3604df
3604df
Please note that LOC of downstream patch differs because of a
3604df
downstream only fix https://code.engineering.redhat.com/gerrit/94006
3604df
3604df
>Reviewed-on: https://review.gluster.org/16455
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Prashanth Pai <ppai@redhat.com>
3604df
>Reviewed-by: Kaushal M <kaushal@redhat.com>
3604df
3604df
Change-Id: I2fe7a3ebea19492d52253ad5a1fdd67ac95c71c8
3604df
BUG: 1411270
3604df
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/96368
3604df
Reviewed-by: Samikshan Bairagya <sbairagy@redhat.com>
3604df
Reviewed-by: Prashanth Pai <ppai@redhat.com>
3604df
---
3604df
 xlators/mgmt/glusterd/src/glusterd-op-sm.c | 102 ++++++++++++++++++-----------
3604df
 1 file changed, 63 insertions(+), 39 deletions(-)
3604df
3604df
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
index 1293d29..9ebdb9e 100644
3604df
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
@@ -2366,19 +2366,18 @@ static int
3604df
 glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
3604df
                                     char **op_errstr)
3604df
 {
3604df
-        char            *key                    = NULL;
3604df
-        char            *key_fixed              = NULL;
3604df
-        char            *value                  = NULL;
3604df
-        char            *dup_value              = NULL;
3604df
-        int             ret                     = -1;
3604df
-        glusterd_conf_t *conf                   = NULL;
3604df
-        dict_t          *dup_opt                = NULL;
3604df
-        char            *next_version           = NULL;
3604df
-        gf_boolean_t    quorum_action           = _gf_false;
3604df
-        uint32_t        op_version              = 0;
3604df
-        glusterd_volinfo_t  *volinfo            = NULL;
3604df
-        glusterd_volinfo_t  *tmp_volinfo        = NULL;
3604df
-        glusterd_volinfo_t  *voliter            = NULL;
3604df
+        char                *key                    = NULL;
3604df
+        char                *key_fixed              = NULL;
3604df
+        char                *value                  = NULL;
3604df
+        char                *dup_value              = NULL;
3604df
+        int                  ret                     = -1;
3604df
+        glusterd_conf_t     *conf                   = NULL;
3604df
+        dict_t              *dup_opt                = NULL;
3604df
+        char                *next_version           = NULL;
3604df
+        gf_boolean_t         quorum_action          = _gf_false;
3604df
+        uint32_t             op_version             = 0;
3604df
+        glusterd_volinfo_t  *volinfo                = NULL;
3604df
+        glusterd_svc_t      *svc                    = NULL;
3604df
         gf_boolean_t         start_nfs_svc      = _gf_false;
3604df
 
3604df
         conf = this->private;
3604df
@@ -2434,16 +2433,57 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
3604df
                          * needs to be changed to 17 bytes. Look
3604df
                          * glusterd_store_quota_config for more details.
3604df
                          */
3604df
-                        cds_list_for_each_entry (voliter, &conf->volumes, vol_list) {
3604df
-                                tmp_volinfo = voliter;
3604df
-                                ret = glusterd_store_quota_config (tmp_volinfo,
3604df
-                                                                   NULL, NULL,
3604df
-                                                                   GF_QUOTA_OPTION_TYPE_UPGRADE,
3604df
-                                                                   NULL);
3604df
+                        cds_list_for_each_entry (volinfo, &conf->volumes,
3604df
+                                                 vol_list) {
3604df
+                                ret = glusterd_store_quota_config
3604df
+                                             (volinfo, NULL, NULL,
3604df
+                                              GF_QUOTA_OPTION_TYPE_UPGRADE,
3604df
+                                              NULL);
3604df
+                                if (ret)
3604df
+                                        goto out;
3604df
+                                ret = glusterd_update_volumes_dict
3604df
+                                                (volinfo, &start_nfs_svc);
3604df
                                 if (ret)
3604df
                                         goto out;
3604df
+                                if (!volinfo->is_snap_volume) {
3604df
+                                        svc = &(volinfo->snapd.svc);
3604df
+                                        ret = svc->manager (svc, volinfo,
3604df
+                                                            PROC_START_NO_WAIT);
3604df
+                                        if (ret)
3604df
+                                                goto out;
3604df
+                                }
3604df
+                                ret = glusterd_create_volfiles_and_notify_services (volinfo);
3604df
+                                if (ret) {
3604df
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
+                                                GD_MSG_VOLFILE_CREATE_FAIL,
3604df
+                                                "Unable to create volfile for"
3604df
+                                                " 'volume set'");
3604df
+                                        goto out;
3604df
+                                }
3604df
+                                if (GLUSTERD_STATUS_STARTED
3604df
+                                                 == volinfo->status) {
3604df
+                                        ret = glusterd_svcs_reconfigure ();
3604df
+                                        if (ret) {
3604df
+                                                gf_msg (this->name,
3604df
+                                                        GF_LOG_ERROR, 0,
3604df
+                                                        GD_MSG_SVC_RESTART_FAIL,
3604df
+                                                        "Unable to restart "
3604df
+                                                        "services");
3604df
+                                                goto out;
3604df
+                                        }
3604df
+                                }
3604df
+                        }
3604df
+                        if (start_nfs_svc) {
3604df
+                                ret = conf->nfs_svc.manager (&(conf->nfs_svc),
3604df
+                                                             NULL,
3604df
+                                                             PROC_START_NO_WAIT);
3604df
+                                if (ret) {
3604df
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
+                                                GD_MSG_SVC_START_FAIL,
3604df
+                                                 "unable to start nfs service");
3604df
+                                        goto out;
3604df
+                                }
3604df
                         }
3604df
-
3604df
                         ret = glusterd_store_global_info (this);
3604df
                         if (ret) {
3604df
                                 gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
@@ -2451,22 +2491,6 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
3604df
                                         "Failed to store op-version.");
3604df
                         }
3604df
                 }
3604df
-                cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
3604df
-                        ret = glusterd_update_volumes_dict (volinfo,
3604df
-                                                            &start_nfs_svc);
3604df
-                        if (ret)
3604df
-                                goto out;
3604df
-                }
3604df
-                if (start_nfs_svc) {
3604df
-                        ret = conf->nfs_svc.manager (&(conf->nfs_svc), NULL,
3604df
-                                                     PROC_START_NO_WAIT);
3604df
-                        if (ret) {
3604df
-                                gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
-                                        GD_MSG_SVC_START_FAIL,
3604df
-                                         "unable to start nfs service");
3604df
-                                goto out;
3604df
-                        }
3604df
-                }
3604df
                 /* No need to save cluster.op-version in conf->opts
3604df
                  */
3604df
                 goto out;
3604df
@@ -2872,9 +2896,9 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
3604df
                         if (GLUSTERD_STATUS_STARTED == volinfo->status) {
3604df
                                 ret = glusterd_svcs_reconfigure ();
3604df
                                 if (ret) {
3604df
-                                        gf_msg (this->name, GF_LOG_WARNING, 0,
3604df
-                                                GD_MSG_NFS_SERVER_START_FAIL,
3604df
-                                                "Unable to restart NFS-Server");
3604df
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
+                                                GD_MSG_SVC_RESTART_FAIL,
3604df
+                                                 "Unable to restart services");
3604df
                                         goto out;
3604df
                                 }
3604df
                         }
3604df
-- 
3604df
2.9.3
3604df