diff options
author | shishir gowda <sgowda@redhat.com> | 2013-10-09 10:42:56 +0530 |
---|---|---|
committer | shishir gowda <sgowda@redhat.com> | 2013-11-15 12:37:58 +0530 |
commit | 6726c1617daeb783053a15d12189a64c27343f8c (patch) | |
tree | 915d19016df91568ce1b03a28342bb72de2d363e /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | 8c89a5ffc9d1a9aa6a52a915cdd988c40aececb7 (diff) |
mgmt/glusterd: Store for snapshot
Introduced a new store for storing snapshot list for a given volume.
$GLUSTERD_INSTALL_PATH/vols/<volname>/snap_list.info
$GLUSTERD_INSTALL_PATH/vols/<volname>/snaps/
$GLUSTERD_INSTALL_PATH/vols/<volname>/snaps/<snap-name>/info <-snapshot volume info
$GLUSTERD_INSTALL_PATH/vols/<volname>/snaps/<snap-name>/bricks <-snapshot volume brick dir
$GLUSTERD_INSTALL_PATH/vols/<volname>/snaps/<snap-name>/bricks/<infos>
<-snapshot volume brick info files
store delete options
TODO -
$GLUSTERD_INSTALL_PATH/CG/ <-place holder for all cg's
.../CG/<cg-name>/info <- per cg information placeholder
Change-Id: I1f9fd8ff7cc0682d05b33965736a43dca6adb3e9
Signed-off-by: shishir gowda <sgowda@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 604 |
1 files changed, 595 insertions, 9 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 5902589f4..97c8a5d4f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -76,6 +76,26 @@ glusterd_store_create_brick_dir (glusterd_volinfo_t *volinfo) return ret; } +int32_t +glusterd_store_create_snap_brick_dir (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo) +{ + int32_t ret = -1; + char brickdirpath[PATH_MAX] = {0,}; + glusterd_conf_t *priv = NULL; + + GF_ASSERT (volinfo); + GF_ASSERT (snapinfo); + + priv = THIS->private; + GF_ASSERT (priv); + + GLUSTERD_GET_SNAP_BRICK_DIR (brickdirpath, volinfo, snapinfo->volname, + priv); + ret = gf_store_mkdir (brickdirpath); + + return ret; +} static void glusterd_store_key_vol_brick_set (glusterd_brickinfo_t *brickinfo, char *key_vol_brick, size_t len) @@ -125,6 +145,32 @@ glusterd_store_brickinfopath_set (glusterd_volinfo_t *volinfo, snprintf (brickpath, len, "%s/%s", brickdirpath, brickfname); } +static void +glusterd_store_snap_brickinfopath_set (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo, + glusterd_brickinfo_t *brickinfo, + char *brickpath, size_t len) +{ + char brickfname[PATH_MAX] = {0}; + char brickdirpath[PATH_MAX] = {0,}; + glusterd_conf_t *priv = NULL; + + GF_ASSERT (volinfo); + GF_ASSERT (snapinfo); + GF_ASSERT (brickpath); + GF_ASSERT (brickinfo); + GF_ASSERT (len >= PATH_MAX); + + priv = THIS->private; + GF_ASSERT (priv); + + GLUSTERD_GET_SNAP_BRICK_DIR (brickdirpath, volinfo, + snapinfo->volname, priv); + glusterd_store_brickinfofname_set (brickinfo, brickfname, + sizeof (brickfname)); + snprintf (brickpath, len, "%s/%s", brickdirpath, brickfname); +} + gf_boolean_t glusterd_store_is_valid_brickpath (char *volname, char *brick) { @@ -210,6 +256,24 @@ glusterd_store_create_brick_shandle_on_absence (glusterd_volinfo_t *volinfo, } int32_t +glusterd_store_create_snap_brick_shandle_on_absence(glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo, + glusterd_brickinfo_t *brickinfo) +{ + char brickpath[PATH_MAX] = {0,}; + int32_t ret = 0; + + GF_ASSERT (volinfo); + GF_ASSERT (snapinfo); + GF_ASSERT (brickinfo); + + glusterd_store_snap_brickinfopath_set (volinfo, snapinfo, brickinfo, + brickpath, sizeof (brickpath)); + ret = gf_store_handle_create_on_absence (&brickinfo->shandle, + brickpath); + return ret; +} +int32_t glusterd_store_brickinfo_write (int fd, glusterd_brickinfo_t *brickinfo) { char value[256] = {0,}; @@ -308,6 +372,39 @@ out: } int32_t +glusterd_store_snap_brickinfo (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo, + glusterd_brickinfo_t *brickinfo, + int32_t brick_count, + int vol_fd) +{ + int32_t ret = -1; + + GF_ASSERT (volinfo); + GF_ASSERT (snapinfo); + GF_ASSERT (brickinfo); + + ret = glusterd_store_volinfo_brick_fname_write (vol_fd, brickinfo, + brick_count); + if (ret) + goto out; + + ret = glusterd_store_create_snap_brick_dir (volinfo, snapinfo); + if (ret) + goto out; + + ret = glusterd_store_create_snap_brick_shandle_on_absence (volinfo, + snapinfo, + brickinfo); + if (ret) + goto out; + + ret = glusterd_store_perform_brick_store (brickinfo); +out: + gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + return ret; +} +int32_t glusterd_store_delete_brick (glusterd_brickinfo_t *brickinfo, char *delete_path) { int32_t ret = -1; @@ -630,6 +727,73 @@ glusterd_store_create_volume_dir (glusterd_volinfo_t *volinfo) return ret; } +static void +glusterd_store_vol_snaps_dirpath_set (glusterd_volinfo_t *volinfo, + char *snapdirpath, size_t len) +{ + glusterd_conf_t *priv = NULL; + + GF_ASSERT (volinfo); + priv = THIS->private; + GF_ASSERT (priv); + + snprintf (snapdirpath, len, "%s/%s/%s/%s", priv->workdir, + GLUSTERD_VOLUME_DIR_PREFIX, volinfo->volname, + GLUSTERD_VOL_SNAP_DIR_PREFIX); +} + +static void +glusterd_store_snap_vol_dirpath_set (glusterd_volinfo_t *volinfo, + char *snapdirpath, size_t len, + char *snap_name) +{ + glusterd_conf_t *priv = NULL; + size_t strlen = 0; + + GF_ASSERT (volinfo); + priv = THIS->private; + GF_ASSERT (priv); + + glusterd_store_vol_snaps_dirpath_set (volinfo, snapdirpath, len); + strlen = sizeof (snapdirpath) + sizeof (*snap_name); + snprintf (snapdirpath, strlen, "%s/%s", snapdirpath, snap_name); +} +/* creates GLUSTERD_VOLUME_DIR_PREFIX/<volname>/snaps directory */ +static int32_t +glusterd_store_create_snaps_dir (glusterd_volinfo_t *volinfo) +{ + int32_t ret = -1; + char snapdirpath[PATH_MAX] = {0,}; + + GF_ASSERT (volinfo); + + glusterd_store_vol_snaps_dirpath_set (volinfo, snapdirpath, + sizeof (snapdirpath)); + ret = gf_store_mkdir (snapdirpath); + gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + return ret; +} + + +/* creates GLUSTERD_VOLUME_DIR_PREFIX/<volname>/snaps/<snap-name> directory */ +static int32_t +glusterd_store_create_snap_vol_dir (glusterd_volinfo_t *volinfo, char *snap_name) +{ + int32_t ret = -1; + char snapdirpath[PATH_MAX] = {0,}; + + GF_ASSERT (volinfo); + GF_ASSERT (snap_name); + + glusterd_store_snap_vol_dirpath_set (volinfo, snapdirpath, + sizeof (snapdirpath), + snap_name); + + ret = gf_store_mkdir (snapdirpath); + gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + return ret; +} + int32_t glusterd_store_volinfo_write (int fd, glusterd_volinfo_t *volinfo) { @@ -698,6 +862,51 @@ glusterd_store_node_state_path_set (glusterd_volinfo_t *volinfo, GLUSTERD_NODE_STATE_FILE); } +static void +glusterd_store_snap_list_path_set (glusterd_volinfo_t *volinfo, + char *snap_list_path, size_t len) +{ + char voldirpath[PATH_MAX] = {0,}; + GF_ASSERT (volinfo); + GF_ASSERT (snap_list_path); + GF_ASSERT (len <= PATH_MAX); + + glusterd_store_voldirpath_set (volinfo, voldirpath, + sizeof (voldirpath)); + snprintf (snap_list_path, len, "%s/%s", voldirpath, + GLUSTERD_VOL_SNAP_FILE); +} + +static void +glusterd_store_snap_volfpath_set (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo, + char *volfpath, size_t len) +{ + char voldirpath[PATH_MAX] = {0,}; + GF_ASSERT (volinfo); + GF_ASSERT (volfpath); + GF_ASSERT (len <= PATH_MAX); + + glusterd_store_snap_vol_dirpath_set (volinfo, voldirpath, + sizeof (voldirpath), + snapinfo->volname); + snprintf (volfpath, len, "%s/%s", voldirpath, GLUSTERD_VOLUME_INFO_FILE); +} + +int32_t +glusterd_store_create_snap_vol_shandle_on_absence (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo) +{ + char volfpath[PATH_MAX] = {0}; + int32_t ret = 0; + + GF_ASSERT (volinfo); + + glusterd_store_snap_volfpath_set (volinfo, snapinfo, + volfpath, sizeof (volfpath)); + ret = gf_store_handle_create_on_absence (&snapinfo->shandle, volfpath); + return ret; +} int32_t glusterd_store_create_rbstate_shandle_on_absence (glusterd_volinfo_t *volinfo) { @@ -743,6 +952,23 @@ glusterd_store_create_nodestate_sh_on_absence (glusterd_volinfo_t *volinfo) } int32_t +glusterd_store_create_snap_list_sh_on_absence (glusterd_volinfo_t *volinfo) +{ + char snap_list_path[PATH_MAX] = {0}; + int32_t ret = 0; + + GF_ASSERT (volinfo); + + glusterd_store_snap_list_path_set (volinfo, snap_list_path, + sizeof (snap_list_path)); + ret = + gf_store_handle_create_on_absence (&volinfo->snap_list_shandle, + snap_list_path); + + return ret; +} + +int32_t glusterd_store_brickinfos (glusterd_volinfo_t *volinfo, int vol_fd) { int32_t ret = 0; @@ -764,6 +990,28 @@ out: } int32_t +glusterd_store_snap_brickinfos (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo, int vol_fd) +{ + int32_t ret = 0; + glusterd_brickinfo_t *brickinfo = NULL; + int32_t brick_count = 0; + + GF_ASSERT (volinfo); + + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + ret = glusterd_store_snap_brickinfo (volinfo, snapinfo, + brickinfo, brick_count, + vol_fd); + if (ret) + goto out; + brick_count++; + } +out: + gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} +int32_t glusterd_store_rbstate_write (int fd, glusterd_volinfo_t *volinfo) { int ret = -1; @@ -886,6 +1134,184 @@ out: } int32_t +glusterd_store_snap_list_write (int fd, glusterd_snap_t *snap, uint64_t count) +{ + int ret = -1; + char key[256] = {0, }; + char buf[PATH_MAX] = {0, }; + + GF_ASSERT (fd > 0); + GF_ASSERT (snap); + + snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_NAME, + count); + ret = gf_store_save_value (fd, key, snap->snap_name); + if (ret) + goto out; + + snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_ID, + count); + ret = gf_store_save_value (fd, key, uuid_utoa(snap->snap_id)); + if (ret) + goto out; + + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_CG_ID, count); + ret = gf_store_save_value (fd, key, uuid_utoa(snap->cg_id)); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%d", snap->snap_status); + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_STATUS, 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; +} + +int32_t +glusterd_store_perform_snap_volume_store (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snap_volinfo) +{ + int fd = -1; + int32_t ret = -1; + GF_ASSERT (volinfo); + GF_ASSERT (snap_volinfo); + + ret = glusterd_store_create_snap_vol_shandle_on_absence (volinfo, + snap_volinfo); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to create " + " shandle for snap %s of volume %s", volinfo->volname, + snap_volinfo->volname); + goto out; + } + fd = gf_store_mkstemp (snap_volinfo->shandle); + if (fd <= 0) { + ret = -1; + goto out; + } + + ret = glusterd_store_volinfo_write (fd, snap_volinfo); + if (ret) + goto out; + ret = glusterd_store_snap_brickinfos (volinfo, snap_volinfo, fd); + if (ret) + goto out; +out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->shandle); + if (fd > 0) + close (fd); + gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + +int32_t +glusterd_store_snap_volume (glusterd_volinfo_t *volinfo, glusterd_snap_t *snap) +{ + int32_t ret = -1; + glusterd_volinfo_t *snap_volinfo = NULL; + + GF_ASSERT (volinfo); + GF_ASSERT (snap); + + + LOCK (&snap->lock); + { + snap_volinfo = snap->snap_volume; + + ret = glusterd_store_create_snap_vol_dir (volinfo, + snap->snap_name); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Failed create snapshot dir (%s) for volume " + "%s", snap->snap_name, volinfo->volname); + goto unlock; + } + + ret = glusterd_store_perform_snap_volume_store (volinfo, + snap_volinfo); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Failed store snapshot volinfo (%s) for volume " + "%s", snap->snap_name, volinfo->volname); + goto unlock; + } + } +unlock: + UNLOCK (&snap->lock); + + return 0; + +} + +int32_t +glusterd_store_perform_snap_store (glusterd_volinfo_t *volinfo) +{ + int fd = -1; + int32_t ret = -1; + glusterd_snap_t *entry = NULL; + glusterd_snap_t *tmp = NULL; + uint64_t count = 0; + char buf[PATH_MAX] = {0,}; + + GF_ASSERT (volinfo); + + ret = glusterd_store_create_snaps_dir (volinfo); + if (ret) + goto out; + + ret = glusterd_store_create_snap_list_sh_on_absence (volinfo); + if (ret) + goto out; + fd = gf_store_mkstemp (volinfo->snap_list_shandle); + if (fd <= 0) { + ret = -1; + goto out; + } + + LOCK (&volinfo->lock); + { + list_for_each_entry_safe (entry, tmp, &volinfo->snaps, + snap_list) { + ret = glusterd_store_snap_list_write (fd, entry, count); + if (ret) + goto unlock; + ret = glusterd_store_snap_volume (volinfo, entry); + if (ret) + goto unlock; + count++; + } + snprintf (buf, sizeof(buf), "%"PRIu64, count); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_COUNT, + buf); + if (ret) + goto unlock; + } +unlock: + UNLOCK (&volinfo->lock); + + ret = gf_store_rename_tmppath (volinfo->snap_list_shandle); + if (ret) + goto out; + +out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->snap_list_shandle); + if (fd > 0) + close (fd); + gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + + + + +int32_t glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo) { int fd = -1; @@ -1063,6 +1489,9 @@ glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t a if (ret) goto out; + ret = glusterd_store_create_snap_list_sh_on_absence (volinfo); + if (ret) + goto out; ret = glusterd_store_perform_volume_store (volinfo); if (ret) goto out; @@ -1082,6 +1511,10 @@ glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t a if (ret) goto out; + ret = glusterd_store_perform_snap_store (volinfo); + if (ret) + goto out; + //checksum should be computed at the end ret = glusterd_volume_compute_cksum (volinfo); if (ret) @@ -1098,7 +1531,8 @@ out: int32_t -glusterd_store_delete_volume (glusterd_volinfo_t *volinfo) +glusterd_store_delete_volume (glusterd_volinfo_t *volinfo, + glusterd_volinfo_t *snapinfo) { char pathname[PATH_MAX] = {0,}; int32_t ret = 0; @@ -1120,7 +1554,12 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo) GF_ASSERT (priv); - GLUSTERD_GET_VOLUME_DIR (pathname, volinfo, priv); + if (snapinfo) { + GLUSTERD_GET_SNAP_DIR (pathname, volinfo, snapinfo->volname, + priv); + } else { + GLUSTERD_GET_VOLUME_DIR (pathname, volinfo, priv); + } snprintf (delete_path, sizeof (delete_path), "%s/"GLUSTERD_TRASH"/%s.deleted", priv->workdir, @@ -1444,7 +1883,7 @@ out: int32_t -glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) +glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo, char *snap_name) { int32_t ret = 0; @@ -1467,7 +1906,12 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) priv = THIS->private; - GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv) + if (snap_name) { + GLUSTERD_GET_SNAP_BRICK_DIR (brickdir, volinfo, snap_name, + priv); + } else { + GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv); + } ret = gf_store_iter_new (volinfo->shandle, &tmpiter); @@ -1770,7 +2214,7 @@ out: } int32_t -glusterd_store_retrieve_volume (char *volname) +glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) { int32_t ret = -1; glusterd_volinfo_t *volinfo = NULL; @@ -1791,7 +2235,11 @@ glusterd_store_retrieve_volume (char *volname) priv = THIS->private; - GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv); + if (snap) { + GLUSTERD_GET_SNAP_DIR (volpath, volinfo, snap->snap_name, priv); + } else { + GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv); + } snprintf (path, sizeof (path), "%s/%s", volpath, GLUSTERD_VOLUME_INFO_FILE); @@ -1967,7 +2415,7 @@ glusterd_store_retrieve_volume (char *volname) if (ret) goto out; - ret = glusterd_store_retrieve_bricks (volinfo); + ret = glusterd_store_retrieve_bricks (volinfo, snap->snap_name); if (ret) goto out; @@ -1976,7 +2424,12 @@ glusterd_store_retrieve_volume (char *volname) goto out; - list_add_tail (&volinfo->vol_list, &priv->volumes); + if (!snap) { + list_add_tail (&volinfo->vol_list, &priv->volumes); + } else { + snap->snap_volume = volinfo; + } + out: gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); @@ -2081,6 +2534,128 @@ out: } int32_t +glusterd_store_retrieve_snap_list (char *volname) +{ + int32_t ret = -1; + glusterd_volinfo_t *volinfo = NULL; + gf_store_iter_t *iter = NULL; + char key[256] = {0, }; + char *value = NULL; + char volpath[PATH_MAX] = {0,}; + glusterd_conf_t *priv = NULL; + char path[PATH_MAX] = {0,}; + gf_store_op_errno_t op_errno = GD_STORE_SUCCESS; + glusterd_snap_t *snap = NULL; + uint64_t count = 0; + + priv = THIS->private; + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Couldn't get" + "volinfo for %s.", volname); + goto out; + } + + GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv); + snprintf (path, sizeof (path), "%s/%s", volpath, + GLUSTERD_VOL_SNAP_FILE); + + ret = gf_store_handle_retrieve (path, &volinfo->snap_list_shandle); + if (ret) + goto out; + + ret = gf_store_iter_new (volinfo->snap_list_shandle, &iter); + if (ret) + goto out; + + ret = gf_store_iter_get_matching (iter, GLUSTERD_STORE_KEY_SNAP_COUNT, + &value); + if(ret) + goto out; + + volinfo->snap_count = atol(value); + GF_FREE (value); + value = NULL; + + while (count <= volinfo->snap_count) { + snap = glusterd_new_snap_object (); + if (!snap) { + gf_log (THIS->name, GF_LOG_ERROR, + "Failed to create snap object"); + goto out; + } + + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_NAME, count); + ret = gf_store_iter_get_matching (iter, key, &value); + if (ret) + goto out; + + strncpy (snap->snap_name, value, sizeof (*value)); + GF_FREE (value); + value = NULL; + + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_STATUS, count); + ret = gf_store_iter_get_matching (iter, key, + &value); + if (ret) + goto out; + + snap->snap_status = atoi (value); + GF_FREE (value); + value = NULL; + + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_ID, count); + ret = gf_store_iter_get_matching (iter, key, &value); + if (ret) + goto out; + + uuid_parse (value, snap->snap_id); + GF_FREE (value); + value = NULL; + + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_CG_ID, count); + ret = gf_store_iter_get_matching (iter, key, &value); + if (ret) + goto out; + + uuid_parse (value, snap->cg_id); + GF_FREE (value); + value = NULL; + + ret = glusterd_add_snap (volinfo, snap); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to add %s to" + " snap_list", value); + goto out; + } + ret = glusterd_store_retrieve_volume (volname, snap); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to retrieve " + "snap %s for volume %s", snap->snap_name, volname); + goto out; + } + count++; + } + + if (op_errno != GD_STORE_EOF) + goto out; + + ret = gf_store_iter_destroy (iter); + + if (ret) + goto out; + +out: + gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); + + return ret; +} +int32_t glusterd_store_retrieve_volumes (xlator_t *this) { int32_t ret = 0; @@ -2109,7 +2684,7 @@ glusterd_store_retrieve_volumes (xlator_t *this) glusterd_for_each_entry (entry, dir); while (entry) { - ret = glusterd_store_retrieve_volume (entry->d_name); + ret = glusterd_store_retrieve_volume (entry->d_name, NULL); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to restore " "volume: %s", entry->d_name); @@ -2137,6 +2712,17 @@ glusterd_store_retrieve_volumes (xlator_t *this) ret = glusterd_store_perform_node_state_store (volinfo); } + ret = glusterd_store_retrieve_snap_list (entry->d_name); + if (ret) { + /* Backward compatibility */ + gf_log ("", GF_LOG_INFO, "Creating a new snap_list " + "for volume: %s.", entry->d_name); + ret = glusterd_volinfo_find (entry->d_name, &volinfo); + ret = + glusterd_store_create_snap_list_sh_on_absence (volinfo); + ret = glusterd_store_perform_snap_list_store (volinfo); + + } glusterd_for_each_entry (entry, dir); } |