Blob Blame History Raw
From 8ca5890039e1960f9366c5031e57173ff0db5db5 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Mon, 23 Jan 2017 13:03:06 +0530
Subject: [PATCH 279/285] glusterd: regenerate volfiles on op-version bump up

Please note that LOC of downstream patch differs because of a
downstream only fix https://code.engineering.redhat.com/gerrit/94006

>Reviewed-on: https://review.gluster.org/16455
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Prashanth Pai <ppai@redhat.com>
>Reviewed-by: Kaushal M <kaushal@redhat.com>

Change-Id: I2fe7a3ebea19492d52253ad5a1fdd67ac95c71c8
BUG: 1411270
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/96368
Reviewed-by: Samikshan Bairagya <sbairagy@redhat.com>
Reviewed-by: Prashanth Pai <ppai@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c | 102 ++++++++++++++++++-----------
 1 file changed, 63 insertions(+), 39 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 1293d29..9ebdb9e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2366,19 +2366,18 @@ static int
 glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
                                     char **op_errstr)
 {
-        char            *key                    = NULL;
-        char            *key_fixed              = NULL;
-        char            *value                  = NULL;
-        char            *dup_value              = NULL;
-        int             ret                     = -1;
-        glusterd_conf_t *conf                   = NULL;
-        dict_t          *dup_opt                = NULL;
-        char            *next_version           = NULL;
-        gf_boolean_t    quorum_action           = _gf_false;
-        uint32_t        op_version              = 0;
-        glusterd_volinfo_t  *volinfo            = NULL;
-        glusterd_volinfo_t  *tmp_volinfo        = NULL;
-        glusterd_volinfo_t  *voliter            = NULL;
+        char                *key                    = NULL;
+        char                *key_fixed              = NULL;
+        char                *value                  = NULL;
+        char                *dup_value              = NULL;
+        int                  ret                     = -1;
+        glusterd_conf_t     *conf                   = NULL;
+        dict_t              *dup_opt                = NULL;
+        char                *next_version           = NULL;
+        gf_boolean_t         quorum_action          = _gf_false;
+        uint32_t             op_version             = 0;
+        glusterd_volinfo_t  *volinfo                = NULL;
+        glusterd_svc_t      *svc                    = NULL;
         gf_boolean_t         start_nfs_svc      = _gf_false;
 
         conf = this->private;
@@ -2434,16 +2433,57 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
                          * needs to be changed to 17 bytes. Look
                          * glusterd_store_quota_config for more details.
                          */
-                        cds_list_for_each_entry (voliter, &conf->volumes, vol_list) {
-                                tmp_volinfo = voliter;
-                                ret = glusterd_store_quota_config (tmp_volinfo,
-                                                                   NULL, NULL,
-                                                                   GF_QUOTA_OPTION_TYPE_UPGRADE,
-                                                                   NULL);
+                        cds_list_for_each_entry (volinfo, &conf->volumes,
+                                                 vol_list) {
+                                ret = glusterd_store_quota_config
+                                             (volinfo, NULL, NULL,
+                                              GF_QUOTA_OPTION_TYPE_UPGRADE,
+                                              NULL);
+                                if (ret)
+                                        goto out;
+                                ret = glusterd_update_volumes_dict
+                                                (volinfo, &start_nfs_svc);
                                 if (ret)
                                         goto out;
+                                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) {
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                                GD_MSG_VOLFILE_CREATE_FAIL,
+                                                "Unable to create volfile for"
+                                                " 'volume set'");
+                                        goto out;
+                                }
+                                if (GLUSTERD_STATUS_STARTED
+                                                 == volinfo->status) {
+                                        ret = glusterd_svcs_reconfigure ();
+                                        if (ret) {
+                                                gf_msg (this->name,
+                                                        GF_LOG_ERROR, 0,
+                                                        GD_MSG_SVC_RESTART_FAIL,
+                                                        "Unable to restart "
+                                                        "services");
+                                                goto out;
+                                        }
+                                }
+                        }
+                        if (start_nfs_svc) {
+                                ret = conf->nfs_svc.manager (&(conf->nfs_svc),
+                                                             NULL,
+                                                             PROC_START_NO_WAIT);
+                                if (ret) {
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                                GD_MSG_SVC_START_FAIL,
+                                                 "unable to start nfs service");
+                                        goto out;
+                                }
                         }
-
                         ret = glusterd_store_global_info (this);
                         if (ret) {
                                 gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -2451,22 +2491,6 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
                                         "Failed to store op-version.");
                         }
                 }
-                cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
-                        ret = glusterd_update_volumes_dict (volinfo,
-                                                            &start_nfs_svc);
-                        if (ret)
-                                goto out;
-                }
-                if (start_nfs_svc) {
-                        ret = conf->nfs_svc.manager (&(conf->nfs_svc), NULL,
-                                                     PROC_START_NO_WAIT);
-                        if (ret) {
-                                gf_msg (this->name, GF_LOG_ERROR, 0,
-                                        GD_MSG_SVC_START_FAIL,
-                                         "unable to start nfs service");
-                                goto out;
-                        }
-                }
                 /* No need to save cluster.op-version in conf->opts
                  */
                 goto out;
@@ -2872,9 +2896,9 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
                         if (GLUSTERD_STATUS_STARTED == volinfo->status) {
                                 ret = glusterd_svcs_reconfigure ();
                                 if (ret) {
-                                        gf_msg (this->name, GF_LOG_WARNING, 0,
-                                                GD_MSG_NFS_SERVER_START_FAIL,
-                                                "Unable to restart NFS-Server");
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                                GD_MSG_SVC_RESTART_FAIL,
+                                                 "Unable to restart services");
                                         goto out;
                                 }
                         }
-- 
2.9.3