diff options
| author | shishir gowda <sgowda@redhat.com> | 2013-10-31 09:51:21 +0530 | 
|---|---|---|
| committer | Gerrit Code Review <review@dev.gluster.org> | 2013-11-07 21:59:56 -0800 | 
| commit | 697f0f4329ffa1fc974ad63c101e8d76691485d7 (patch) | |
| tree | 89976afdf2788fdc16fedf17da490b7eed9b5c72 | |
| parent | 7966b9cc4149b490a932919c38d43a4b4373e2ea (diff) | |
mgmt/glusterd: store for snapshot description
Change-Id: I0ba50ba2963edf8d890a2dc78d48d42db7f71ae2
Signed-off-by: shishir gowda <sgowda@redhat.com>
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 37 | 
1 files changed, 35 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 7be56bd0e..b6c1305ef 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1166,8 +1166,8 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo)          GF_ASSERT (volinfo);          if (volinfo->rebal.defrag_cmd == GF_DEFRAG_CMD_STATUS) { -                ret = 0; -                goto out; +                        ret = 0; +                        goto out;          }          snprintf (buf, sizeof (buf), "%d", volinfo->rebal.defrag_cmd); @@ -1223,6 +1223,16 @@ glusterd_store_snap_list_write (int fd, glusterd_snap_t *snap, uint64_t count)          ret = gf_store_save_value (fd, key, buf);          if (ret)                  goto out; + +        if (snap->description) { +                snprintf (buf, sizeof (buf), "%s\n", snap->description); +                snprintf (key, sizeof (key), "%s-%"PRIu64, +                          GLUSTERD_STORE_KEY_SNAP_DESC, count); +                ret = gf_store_save_value (fd, key, buf); +                if (ret) +                        goto out; +        } +  out:          gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);          return ret; @@ -1257,6 +1267,14 @@ glusterd_store_snap_cg_write (int fd, glusterd_snap_cg_t *cg)          ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_STATUS, buf);          if (ret)                  goto out; + +        if (cg->description) { +                snprintf (buf, sizeof (buf), "%s\n", cg->description); +                ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_DESC, +                                           buf); +                if (ret) +                        goto out; +        }          while (count < cg->volume_count) {                  ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_ID,                                        uuid_utoa (cg->volumes[count].volume_id)); @@ -2990,6 +3008,9 @@ glusterd_store_retrieve_snap_cg (char   *cg_name, glusterd_conf_t *priv)                  } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_CG_ID,                             sizeof (*key))) {                          uuid_parse (value, cg->cg_id); +                } else  if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_DESC, +                             sizeof (*key))) { +                        cg->description = gf_strdup (value);                  } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_ID,                             sizeof (*key))) {                          uuid_parse (key, vol_id); @@ -3123,6 +3144,18 @@ glusterd_store_retrieve_snap_list (char   *volname)                  GF_FREE (value);                  value = NULL; +                snprintf (key, sizeof (key), "%s-%"PRIu64, +                          GLUSTERD_STORE_KEY_SNAP_DESC, count); +                ret = gf_store_retrieve_value (shandle, key, &value); +                if (!ret) { +                        snap->description = value; +                        value = NULL; +                } else { +                        ret = 0; +                        gf_log (THIS->name, GF_LOG_TRACE, "No desc for %s", +                                snap->snap_name); +                } +                  ret = glusterd_add_snap (volinfo, snap);                  if (ret) {                          gf_log (THIS->name, GF_LOG_ERROR, "Failed to add %s to"  | 
