diff options
author | Vijaikumar M <vmallika@redhat.com> | 2014-03-25 15:44:56 +0530 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2014-03-25 03:32:21 -0700 |
commit | e078092e827807aec0eef185198771f49f809b34 (patch) | |
tree | 5eea84d1266cf2261cd8a9acb39e2262742013bc /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | cb9bb522972b6cff45c0b6646100151e30e6424c (diff) |
snapshot: cleanup unwanted CG-code
Change-Id: Id3da2a7aac84027aeff050f6dd9a3484719362bc
BUG: 1073780
Signed-off-by: Vijaikumar M <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/7204
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 409 |
1 files changed, 0 insertions, 409 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 613f03abc..8dee4d421 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -677,32 +677,6 @@ glusterd_store_create_snap_dir (glusterd_snap_t *snap) return ret; } -static void -glusterd_store_vol_snaps_cg_dirpath_set (char *cgdirpath, size_t len) -{ - glusterd_conf_t *priv = NULL; - - priv = THIS->private; - GF_ASSERT (priv); - - snprintf (cgdirpath, len, "%s/%s", priv->workdir, - GLUSTERD_VOL_SNAP_CG_DIR_PREFIX); -} - -/* creates GLUSTERD_VOLUME_DIR_PREFIX/cg directory */ -static int32_t -glusterd_store_create_snaps_cg_dir () -{ - int32_t ret = -1; - char cgdirpath[PATH_MAX] = {0,}; - - glusterd_store_vol_snaps_cg_dirpath_set (cgdirpath, - sizeof (cgdirpath)); - ret = gf_store_mkdir (cgdirpath); - 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) { @@ -830,33 +804,6 @@ glusterd_store_snapfpath_set (glusterd_snap_t *snap, char *snap_fpath, snap->snapname, GLUSTERD_SNAP_INFO_FILE); } -static void -glusterd_store_snap_cgfpath_set (char *cg_name, - char *cgfpath, size_t len) -{ - char cgdirpath[PATH_MAX] = {0,}; - GF_ASSERT (cg_name); - GF_ASSERT (cgfpath); - GF_ASSERT (len <= PATH_MAX); - - glusterd_store_vol_snaps_cg_dirpath_set (cgdirpath, - sizeof (cgdirpath)); - snprintf (cgfpath, len, "%s/%s.info", cgdirpath, cg_name); -} - -int32_t -glusterd_store_create_snap_cg_shandle_on_absence (glusterd_snap_cg_t *cg) -{ - char cgfpath[PATH_MAX] = {0}; - int32_t ret = 0; - - GF_ASSERT (cg); - - glusterd_store_snap_cgfpath_set (cg->cg_name, cgfpath, - sizeof (cgfpath)); - ret = gf_store_handle_create_on_absence (&cg->shandle, cgfpath); - return ret; -} int32_t glusterd_store_create_rbstate_shandle_on_absence (glusterd_volinfo_t *volinfo) { @@ -1058,147 +1005,6 @@ out: } int32_t -glusterd_store_snap_cg_write (int fd, glusterd_snap_cg_t *cg) -{ - int ret = -1; - char buf[PATH_MAX] = {0, }; - uint64_t count = 0; - glusterd_volinfo_t *volinfo = NULL; - - GF_ASSERT (fd > 0); - GF_ASSERT (cg); - - snprintf (buf, sizeof (buf), "%"PRIu64, cg->volume_count); - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_CG_VOL_COUNT, buf); - if (ret) - goto out; - - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_NAME, - cg->cg_name); - if (ret) - goto out; - - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_CG_ID, - uuid_utoa(cg->cg_id)); - if (ret) - goto out; - - snprintf (buf, sizeof (buf), "%d", cg->cg_status); - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_STATUS, buf); - if (ret) - goto out; - - if (cg->description) { - snprintf (buf, sizeof (buf), "%s", cg->description); - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_DESC, - buf); - if (ret) - goto out; - } - while (count < cg->volume_count) { - volinfo = cg->volumes[count]; - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_ID, - uuid_utoa (volinfo->volume_id)); - if (ret) - goto out; - - count++; - } -out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); - return ret; -} -int32_t -glusterd_store_perform_snap_cg_store (glusterd_snap_cg_t *cg) -{ - int fd = -1; - int32_t ret = -1; - GF_ASSERT (cg); - - ret = glusterd_store_create_snap_cg_shandle_on_absence (cg); - if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to create " - " shandle for cg %s ", cg->cg_name); - goto out; - } - fd = gf_store_mkstemp (cg->shandle); - if (fd <= 0) { - ret = -1; - goto out; - } - - ret = glusterd_store_snap_cg_write (fd, cg); - if (ret) - goto out; - - ret = gf_store_rename_tmppath (cg->shandle); - if (ret) - goto out; - -out: - if (ret && (fd > 0)) - gf_store_unlink_tmppath (cg->shandle); - if (fd > 0) - close (fd); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); - return ret; -} - -int32_t -glusterd_store_snap_cg (glusterd_snap_cg_t *cg) -{ - int32_t ret = -1; - - GF_ASSERT (cg); - - - LOCK (&cg->lock); - { - ret = glusterd_store_perform_snap_cg_store (cg); - if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, - "Failed store snap cg (%s)", cg->cg_name); - goto unlock; - } - } -unlock: - UNLOCK (&cg->lock); - - return 0; - -} -int32_t -glusterd_store_perform_snap_cgs_store (glusterd_conf_t *priv) -{ - int32_t ret = -1; - glusterd_snap_cg_t *entry = NULL; - glusterd_snap_cg_t *tmp = NULL; - - GF_ASSERT (priv); - - - ret = glusterd_store_create_snaps_cg_dir (priv); - if (ret) - goto out; - -// LOCK (&priv->lock); - { - list_for_each_entry_safe (entry, tmp, &priv->snap_cg, - cg_list) { - ret = glusterd_store_snap_cg (entry); - if (ret) - goto unlock; - } - } -unlock: -// UNLOCK (&priv->lock); - -out: - 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; @@ -1472,74 +1278,6 @@ out: } int32_t -glusterd_store_delete_snap_cg (glusterd_snap_cg_t *cg) -{ - char pathname[PATH_MAX] = {0,}; - int32_t ret = 0; - glusterd_conf_t *priv = NULL; - char path[PATH_MAX] = {0,}; - char delete_path[PATH_MAX] = {0,}; - char trashdir[PATH_MAX] = {0,}; - xlator_t *this = NULL; - gf_boolean_t rename_fail = _gf_false; - - this = THIS; - GF_ASSERT (this); - - GF_ASSERT (cg); - priv = this->private; - - GF_ASSERT (priv); - - glusterd_store_snap_cgfpath_set (cg->cg_name, pathname, sizeof (path)); - snprintf (delete_path, sizeof (delete_path), - "%s/"GLUSTERD_TRASH"/%s/%s.deleted", priv->workdir, - GLUSTERD_VOL_SNAP_CG_DIR_PREFIX, cg->cg_name); - - snprintf (trashdir, sizeof (trashdir), "%s/"GLUSTERD_TRASH"/%s", - priv->workdir, GLUSTERD_VOL_SNAP_CG_DIR_PREFIX); - - ret = mkdir_p (trashdir, 0777, _gf_true); - if (ret && errno != EEXIST) { - gf_log (this->name, GF_LOG_ERROR, "Failed to create trash " - "directory, reason : %s", strerror (errno)); - ret = -1; - goto out; - } - - ret = rename (pathname, delete_path); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to rename %s cg " - "info file", cg->cg_name); - rename_fail = _gf_true; - goto out; - } - - ret = unlink (delete_path); - - if (ret) { - gf_log (this->name, GF_LOG_DEBUG, " Failed to remove " - "%s. Reason : %s", delete_path, strerror (errno)); - } - - ret = rmdir (trashdir); - if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:" - " %s", trashdir, strerror (errno)); - } - -out: - if (!ret && cg->shandle) { - gf_store_handle_destroy (cg->shandle); - cg->shandle = NULL; - } - ret = (rename_fail == _gf_true) ? -1: 0; - - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); - return ret; -} - -int32_t glusterd_store_delete_volume (glusterd_volinfo_t *volinfo) { char pathname[PATH_MAX] = {0,}; @@ -2803,149 +2541,6 @@ out: } int32_t -glusterd_store_retrieve_snap_cg (char *cg_store_name, glusterd_conf_t *priv) -{ - int32_t ret = -1; - gf_store_iter_t *iter = NULL; - char *key = NULL; - char *value = NULL; - char cg_path[PATH_MAX] = {0,}; - char path[PATH_MAX] = {0,}; - gf_store_op_errno_t op_errno = GD_STORE_SUCCESS; - glusterd_snap_cg_t *cg = NULL; - uint64_t vol_count = 0; - gf_store_handle_t *tmp_shandle = NULL; - uint64_t count = 0; - glusterd_volinfo_t *volinfo = NULL; - uuid_t vol_id = {0, }; - - GF_ASSERT (cg_store_name); - GF_ASSERT (priv); - - snprintf (path, sizeof (path), "%s/%s/%s", priv->workdir, - GLUSTERD_VOL_SNAP_CG_DIR_PREFIX, cg_store_name); - ret = gf_store_handle_retrieve (path, &tmp_shandle); - if (ret) - goto out; - - ret = gf_store_iter_new (tmp_shandle, &iter); - if (ret) - goto out; - - ret = gf_store_iter_get_matching (iter, - GLUSTERD_STORE_KEY_CG_VOL_COUNT, - &value); - if (ret) - goto out; - - vol_count = atoi (value); - - GF_FREE (value); - value = NULL; - - cg = glusterd_new_snap_cg_object (vol_count); - if (!cg) { - gf_log (THIS->name, GF_LOG_ERROR, - "Failed to create snap cg object"); - goto out; - } - cg->shandle = tmp_shandle; - - GLUSTERD_GET_SNAP_CG_DIR (cg_path, priv); - snprintf (path, sizeof (path), "%s/%s", cg_path, - cg_store_name); - - ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); - while (!ret) { - - if (!strncmp(key, GLUSTERD_STORE_KEY_SNAP_NAME, - sizeof (*key))) { - strcpy (cg->cg_name, value); - } else if (!strncmp(key, GLUSTERD_STORE_KEY_SNAP_STATUS, - sizeof (*key))) { - cg->cg_status = atoi (value); - } 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 (value, vol_id); - ret = glusterd_volinfo_find_by_volume_id (vol_id, &volinfo); - if (ret) - break; - if (count < vol_count) { - cg->volumes[count] = volinfo; - count++; - } - } - - GF_FREE (value); - value = NULL; - ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); - } - - ret = glusterd_add_snap_cg (priv, cg); - if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to add %s to" - " cg_list", cg_store_name); - goto out; - } - - 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_snap_cgs (xlator_t *this) -{ - int32_t ret = 0; - char path[PATH_MAX] = {0,}; - glusterd_conf_t *priv = NULL; - DIR *dir = NULL; - struct dirent *entry = NULL; - - GF_ASSERT (this); - priv = this->private; - - GF_ASSERT (priv); - - snprintf (path, PATH_MAX, "%s/%s", priv->workdir, - GLUSTERD_VOL_SNAP_CG_DIR_PREFIX); - - dir = opendir (path); - - if (!dir) { - gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path); - ret = -1; - goto out; - } - - glusterd_for_each_entry (entry, dir); - - while (entry) { - ret = glusterd_store_retrieve_snap_cg (entry->d_name, priv); - if (ret) - goto out; - glusterd_for_each_entry (entry, dir); - } -out: - return 0; -} - -int32_t glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap) { int32_t ret = -1; @@ -3679,10 +3274,6 @@ glusterd_restore () if (ret) goto out; - ret = glusterd_store_retrieve_snap_cgs (this); - if (ret) - goto out; - ret = glusterd_store_retrieve_peers (this); if (ret) goto out; |