diff options
| author | Kaushik BV <kaushikbv@gluster.com> | 2010-10-03 02:41:29 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-03 03:05:03 -0700 | 
| commit | 609a89ceace25a0a81d0a9cafde3a4d1afd1b916 (patch) | |
| tree | 0205b67be6e1e2f33e9a0c9c1ca4ea0737ebff05 /xlators/mgmt/glusterd/src/glusterd-store.c | |
| parent | 53b8c7470f9e40c60c5eebd1fbad5c6d274f7ee5 (diff) | |
mgmt/Glusterd: new command volume reset <volname>, volume set enhancementsv3.1.0qa39
- Write the reconfigured options in 'info' file to make it persistant
- Implementation of volume set  <volname> history
- Implementation of volume reset <volname>
Signed-off-by: Kaushik BV <kaushikbv@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1159 ()
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 54 | 
1 files changed, 53 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 27bed10d21f..7c18b69a927 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -20,6 +20,8 @@  #define _CONFIG_H  #include "config.h"  #endif + +#include "glusterd-op-sm.h"  #include <inttypes.h> @@ -970,6 +972,7 @@ glusterd_store_retrieve_volume (char    *volname)          char                    volpath[PATH_MAX] = {0,};          glusterd_conf_t         *priv = NULL;          char                    path[PATH_MAX] = {0,}; +        gf_boolean_t            exists = _gf_false;          ret = glusterd_volinfo_new (&volinfo); @@ -1025,7 +1028,21 @@ glusterd_store_retrieve_volume (char    *volname)                                  gf_log ("", GF_LOG_WARNING,                                          "failed to parse uuid");                  } else { -                        gf_log ("", GF_LOG_ERROR, "Unknown key: %s", +                        exists = glusterd_check_option_exists (key); +                        if (exists) { +                                ret = dict_set_str(volinfo->dict, key,  +                                                     gf_strdup (value)); +                                if (ret) { +                                        gf_log ("",GF_LOG_ERROR, "Error in " +                                                        "dict_set_str"); +                                        goto out; +                                } +                                gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-" +                                                "set:key=%s,value:%s",  +                                                                key, value); +                        } +                        else +                                gf_log ("", GF_LOG_DEBUG, "Unknown key: %s",                                          key);                  } @@ -1104,6 +1121,39 @@ out:          return ret;  } +void _setopts(dict_t *this, char *key, data_t *value, void *data) +{ +        int                      ret = 0; +        glusterd_store_handle_t *shandle = NULL; +        gf_boolean_t             exists = _gf_false; +         + +        shandle = (glusterd_store_handle_t *) data; + +        GF_ASSERT (shandle); +        if (!key) +                return; +        if (!value || !value->data) +                return; + +        exists = glusterd_check_option_exists (key); +        if (exists) +                gf_log ("", GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s", +                        key, value->data); +        else { +                gf_log ("", GF_LOG_DEBUG, "Discarding:key= %s, val=%s", +                        key, value->data); +                return; +        } +         +        ret = glusterd_store_save_value (shandle, key, value->data); +        if (ret) { +                gf_log ("", GF_LOG_ERROR, "Unable to write into store" +                                " handle for path: %s", shandle->path); +                return; +        } +} +  int32_t  glusterd_store_update_volume (glusterd_volinfo_t *volinfo)  { @@ -1171,6 +1221,8 @@ glusterd_store_update_volume (glusterd_volinfo_t *volinfo)                          goto out;                  brick_count++;          } +         +        dict_foreach (volinfo->dict, _setopts, volinfo->shandle);          ret = 0;  | 
