diff options
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 23 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 24 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 14 | 
3 files changed, 50 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index aa0543609e4..acd851663cb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1619,6 +1619,19 @@ glusterd_op_set_volume (dict_t *dict)                  goto out;          } +        /* Update the cluster op-version before regenerating volfiles so that +         * correct volfiles are generated +         */ +        if (new_op_version > priv->op_version) { +                priv->op_version = new_op_version; +                ret = glusterd_store_global_info (this); +                if (ret) { +                        gf_log (this->name, GF_LOG_ERROR, +                                "Failed to store op-version"); +                        goto out; +                } +        } +          if (!global_opt) {                  ret = glusterd_create_volfiles_and_notify_services (volinfo);                  if (ret) { @@ -1672,16 +1685,6 @@ glusterd_op_set_volume (dict_t *dict)                  }          } -        if (new_op_version > priv->op_version) { -                priv->op_version = new_op_version; -                ret = glusterd_store_global_info (this); -                if (ret) { -                        gf_log (this->name, GF_LOG_ERROR, -                                "Failed to store op-version"); -                        goto out; -                } -        } -   out:          GF_FREE (key_fixed);          gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 94bfe5fe137..0309a539cbe 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -7516,7 +7516,8 @@ _update_volume_op_versions (dict_t *this, char *key, data_t *value, void *data)  void  gd_update_volume_op_versions (glusterd_volinfo_t *volinfo)  { -        glusterd_conf_t    *conf = NULL; +        glusterd_conf_t *conf = NULL; +        gf_boolean_t    ob_enabled = _gf_false;          GF_ASSERT (volinfo); @@ -7529,5 +7530,26 @@ gd_update_volume_op_versions (glusterd_volinfo_t *volinfo)          dict_foreach (volinfo->dict, _update_volume_op_versions, volinfo); +        /* Special case for open-behind +         * If cluster op-version >= 2 and open-behind hasn't been explicitly +         * disabled, volume op-versions must be updated to account for it +         */ + +        /* TODO: Remove once we have a general way to update automatically +         * enabled features +         */ +        if (conf->op_version >= 2) { +                ob_enabled = dict_get_str_boolean (volinfo->dict, +                                                   "performance.open-behind", +                                                   _gf_true); +                if (ob_enabled) { + +                        if (volinfo->op_version < 2) +                                volinfo->op_version = 2; +                        if (volinfo->client_op_version < 2) +                                volinfo->client_op_version = 2; +                } +        } +          return;  } diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index ccfa28e3528..3d07412b207 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -460,6 +460,8 @@ process_option (dict_t *dict, char *key, data_t *value, void *param)          vme.key = key;          vme.voltype = odt->vme->voltype;          vme.option = odt->vme->option; +        vme.op_version = odt->vme->op_version; +          if (!vme.option) {                  vme.option = strrchr (key, '.');                  if (vme.option) @@ -1673,6 +1675,12 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,  {          char *volname = NULL;          gf_boolean_t enabled = _gf_false; +        xlator_t *this = NULL; +        glusterd_conf_t *conf = NULL; + +        this = THIS; +        GF_ASSERT (this); +        conf = this->private;          volname = param; @@ -1684,6 +1692,12 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,          if (!enabled)                  return 0; +        /* Check op-version before adding the 'open-behind' xlator in the graph +         */ +        if (!strcmp (vme->key, "performance.open-behind") && +            (vme->op_version > conf->op_version)) +                return 0; +          if (volgen_graph_add (graph, vme->voltype, volname))                  return 0;          else  | 
