summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot.c
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-03-25 15:44:56 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-25 03:32:21 -0700
commite078092e827807aec0eef185198771f49f809b34 (patch)
tree5eea84d1266cf2261cd8a9acb39e2262742013bc /xlators/mgmt/glusterd/src/glusterd-snapshot.c
parentcb9bb522972b6cff45c0b6646100151e30e6424c (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-snapshot.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c362
1 files changed, 10 insertions, 352 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 9552c9367..7434b7abd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -46,8 +46,7 @@
char snap_mount_folder[PATH_MAX];
-/* This function will restore a snapshot for the entire
- * volume or the entire CG (Consistency Group)
+/* This function will restore a snapshot volumes
*
* @param dict dictionary containing snapshot restore request
* @param op_errstr In case of any failure error message will be returned
@@ -125,9 +124,8 @@ out:
return ret;
}
-/* This function is called before actual restore is taken place. This
- * function will validate whether the volume or CG is ready to be restored
- * or not.
+/* This function is called before actual restore is taken place. This function
+ * will validate whether the snapshot volumes are ready to be restored or not.
*
* @param dict dictionary containing snapshot restore request
* @param op_errstr In case of any failure error message will be returned
@@ -143,12 +141,12 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
int32_t i = 0;
int32_t volcount = 0;
gf_boolean_t snap_restored = _gf_false;
+ char key[PATH_MAX] = {0, };
char *volname = NULL;
char *snapname = NULL;
glusterd_volinfo_t *volinfo = NULL;
glusterd_snap_t *snap = NULL;
xlator_t *this = NULL;
- char key[PATH_MAX] = {0, };
this = THIS;
@@ -204,24 +202,21 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
}
/* Snapshot restore will only work if the volume is stopped.
- * If volume is running then snapshot restore will fail. In
- * case of CG if any of the volume in the CG is running then
- * snapshot restore for the entire CG will fail
+ * If volume is running then snapshot restore will fail.
*/
- for (i = 0; i < volcount; ++i) {
- /* TODO: Start the index from 0 when Jarvis code is fixed */
- snprintf (key, sizeof (key), "volname%d", i+1);
+ for (i = 1; i <= volcount; ++i) {
+ snprintf (key, sizeof (key), "volname%d", i);
ret = dict_get_str (dict, key, &volname);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "get volume name");
+ "get volume name");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
ret = gf_asprintf (op_errstr, "Volume (%s) not found",
- volname);
+ volname);
if (ret < 0) {
goto out;
}
@@ -233,8 +228,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
if (glusterd_is_volume_started (volinfo)) {
ret = gf_asprintf (op_errstr, "Volume (%s) has been "
"started. Volume needs to be stopped before restoring "
- "a snapshot.",
- volname);
+ "a snapshot.", volname);
if (ret < 0) {
goto out;
}
@@ -242,7 +236,6 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = -1;
goto out;
}
-
}
ret = 0;
@@ -792,31 +785,6 @@ glusterd_new_snap_object()
};
-glusterd_snap_cg_t*
-glusterd_new_snap_cg_object(int64_t volume_count)
-{
- glusterd_snap_cg_t *cg = NULL;
- glusterd_volinfo_t *volinfo = NULL;
-
- if (volume_count < 0) {
- gf_log (THIS->name, GF_LOG_ERROR, "Volume count < 0");
- return NULL;
- }
-
- cg = GF_CALLOC (1, (sizeof (*cg) +
- (volume_count * sizeof (volinfo))),
- gf_gld_mt_snap_cg_t);
-
- if (cg) {
- LOCK_INIT (&cg->lock);
- INIT_LIST_HEAD (&cg->cg_list);
- cg->cg_status = GD_SNAP_STATUS_INIT;
- cg->volume_count = volume_count;
- }
-
- return cg;
-}
-
/* Function glusterd_list_add_snapvol adds the volinfo object (snapshot volume)
to the snapshot object list and to the parent volume list */
int32_t
@@ -903,120 +871,6 @@ out:
return snap;
}
-// Big lock should already acquired before this is called
-int32_t
-glusterd_add_snap_cg (glusterd_conf_t *conf, glusterd_snap_cg_t *cg)
-{
- int ret = -1;
- uint64_t count = -1;
- glusterd_snap_cg_t *entry = NULL;
- glusterd_snap_cg_t *last = NULL;
- glusterd_snap_cg_t *tmp = NULL;
-
- GF_VALIDATE_OR_GOTO (THIS->name, conf, out);
- GF_VALIDATE_OR_GOTO (THIS->name, cg, out);
-
- list_for_each_entry_safe (entry, tmp, &conf->snap_cg, cg_list) {
- count++;
- if (!strcmp (entry->cg_name, cg->cg_name) ||
- !uuid_compare (entry->cg_id, cg->cg_id)) {
- gf_log (THIS->name, GF_LOG_ERROR, "Found duplicate "
- "CG %s(%s)", entry->cg_name,
- uuid_utoa(entry->cg_id));
- goto out;
- }
- last = entry;
- }
- list_add_tail (&cg->cg_list, &conf->snap_cg);
-
- gf_log (THIS->name, GF_LOG_DEBUG, "Added CG %s (%s) @ %"PRIu64,
- cg->cg_name, uuid_utoa(cg->cg_id), count);
- ret = 0;
-out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
- return ret;
-}
-
-glusterd_snap_cg_t*
-glusterd_find_snap_cg_by_name (glusterd_conf_t *conf, char *cg_name)
-{
- glusterd_snap_cg_t *entry = NULL;
- glusterd_snap_cg_t *dup = NULL;
- glusterd_snap_cg_t *tmp = NULL;
-
- GF_VALIDATE_OR_GOTO (THIS->name, conf, out);
- GF_VALIDATE_OR_GOTO (THIS->name, cg_name, out);
-
- list_for_each_entry_safe (entry, tmp, &conf->snap_cg, cg_list) {
- if (!strcmp (entry->cg_name, cg_name)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found CG %s(%s)",
- entry->cg_name, uuid_utoa(entry->cg_id));
- dup = entry;
- break;
- }
- }
-out:
- return dup;
-}
-
-glusterd_snap_cg_t*
-glusterd_find_snap_cg_by_id (glusterd_conf_t *conf, uuid_t cg_id)
-{
- glusterd_snap_cg_t *entry = NULL;
- glusterd_snap_cg_t *dup = NULL;
- glusterd_snap_cg_t *tmp = NULL;
-
- GF_VALIDATE_OR_GOTO (THIS->name, conf, out);
- if (uuid_is_null (cg_id))
- goto out;
-
- list_for_each_entry_safe (entry, tmp, &conf->snap_cg, cg_list) {
- if (!uuid_compare (entry->cg_id, cg_id)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found CG %s(%s)",
- entry->cg_name, uuid_utoa(entry->cg_id));
- dup = entry;
- break;
- }
- }
-out:
- return dup;
-}
-
-glusterd_snap_cg_t*
-glusterd_remove_snap_cg_by_name (glusterd_conf_t *conf, char *cg_name)
-{
- glusterd_snap_cg_t *entry = NULL;
-
- GF_VALIDATE_OR_GOTO (THIS->name, conf, out);
- GF_VALIDATE_OR_GOTO (THIS->name, cg_name, out);
-
- entry = glusterd_find_snap_cg_by_name(conf, cg_name);
- if (entry) {
- entry->cg_status = GD_SNAP_STATUS_DECOMMISSION;
- list_del_init (&entry->cg_list);
- }
-out:
- return entry;
-}
-
-glusterd_snap_cg_t*
-glusterd_remove_snap_cg_by_id (glusterd_conf_t *conf, uuid_t cg_id)
-{
- glusterd_snap_cg_t *entry = NULL;
-
- GF_VALIDATE_OR_GOTO (THIS->name, conf, out);
- if (uuid_is_null (cg_id))
- goto out;
-
- entry = glusterd_find_snap_cg_by_id (conf, cg_id);
- if (entry) {
- entry->cg_status = GD_SNAP_STATUS_DECOMMISSION;
- list_del_init (&entry->cg_list);
- }
-out:
- return entry;
-}
-
int
glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
glusterd_brickinfo_t *brickinfo,
@@ -2056,142 +1910,6 @@ out:
return ret;
}
-/* TODO: This function needs a revisit.
- *
- * As of now only one snap is supported per CG. This function will
- * retrieve the snap name which bleongs to the CG and put it in the
- * dictionary.
- *
- * @param dict dictionary containing snapshot restore request
- * @param cg CG object.
- * in this variable
- * @return Negative value on Failure and 0 in success
- */
-int
-glusterd_get_cg_snap_name_lk (dict_t *dict, glusterd_snap_cg_t *cg)
-{
- int ret = -1;
- uint64_t snap_count = 0;
- char *snapname = NULL;
- glusterd_snap_t *snap = NULL;
- xlator_t *this = NULL;
- glusterd_volinfo_t *volinfo = NULL;
-
- this = THIS;
-
- GF_ASSERT (this);
- GF_ASSERT (dict);
- GF_ASSERT (cg);
- /* CG should have at least one volume*/
- GF_ASSERT (cg->volume_count > 0);
-
- /* TODO: As of now only one snap is supported per CG When CG
- * management module comes in then this restriction can be removed.
- */
-
- /* TODO: As of now, consistency group can be created out of some volumes,
- even though the volumes already have snapshots taken. But the
- future plan is to have consistency group where past or future
- individual snapshots are not allowed. So this below check
- of snap count of the first volume of the CG to 1, is in accordance
- with that.
- */
- volinfo = cg->volumes[0];
- snap_count = volinfo->snap_count;
- if (1 != snap_count) {
- gf_log (this->name, GF_LOG_ERROR, "More than one snap is "
- "associated with the cg (%s)", cg->cg_name);
- ret = -1;
- goto out;
- }
-
- //snap = glusterd_find_snap_by_index (volinfo, 0);
- if (NULL == snap) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get snap for "
- "%s CG", cg->cg_name);
- ret = -1;
- goto out;
- }
-
- snapname = gf_strdup (snap->snapname);
- if (NULL == snapname) {
- ret = -1;
- goto out;
- }
-
- ret = dict_set_dynstr (dict, "snapname", snapname);
- if (ret) {
- GF_FREE (snapname);
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "set snap name");
- goto out;
- }
-
-out:
- return ret;
-}
-
-/* This is a helper function will get all the volume names present in CG
- * and write into dictionary.
- *
- * @param dict dictionary where volume names should be written
- * @param cg CG object.
- * in this variable
- * @return Negative value on Failure and 0 in success
- */
-int
-glusterd_get_cg_volume_names_lk (dict_t *dict, glusterd_snap_cg_t *cg)
-{
- int ret = -1;
- int64_t i = 0;
- char *volname = NULL;
- xlator_t *this = NULL;
- char key[PATH_MAX] = {0,};
- glusterd_volinfo_t *volinfo = NULL;
-
- this = THIS;
-
- GF_ASSERT (this);
- GF_ASSERT (dict);
- GF_ASSERT (cg);
-
- ret = dict_set_int64 (dict, "volcount", cg->volume_count);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "set volume count");
- goto out;
- }
-
- /* Set volume name of all the volumes present in CG in dict so that
- * Jarvis can use this to acquire mgmt_v3 locks on all the volume
- * present in the CG.
- */
- for (i = 0; i < cg->volume_count; ++i) {
- volinfo = cg->volumes[i];
- /* TODO: When Jarvis framework is fixed change the index
- * to start from 0 instead of 1
- */
- snprintf (key, sizeof (key), "volname%ld", i+1);
- volname = gf_strdup (volinfo->volname);
- if (NULL == volname) {
- ret = -1;
- goto out;
- }
-
- ret = dict_set_dynstr (dict, key, volname);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to set volname");
- GF_FREE (volname);
- volname = NULL;
- goto out;
- }
- }
- ret = 0;
-out:
- return ret;
-}
-
/* This is a snapshot create handler function. This function will be
* executed in the originator node. This function is responsible for
* calling mgmt_v3 framework to do the actual snap creation on all the bricks
@@ -2593,29 +2311,6 @@ out:
return ret;
}
-int32_t
-glusterd_cg_delete (glusterd_snap_cg_t *cg)
-{
- int32_t ret = -1;
- xlator_t *this = NULL;
-
- this = THIS;
- GF_ASSERT (this);
-
- if (!cg) {
- gf_log (this->name, GF_LOG_WARNING, "consistency group is "
- "NULL");
- goto out;
- }
-
- GF_FREE (cg->description);
- GF_FREE (cg);
- ret = 0;
-
-out:
- return ret;
-}
-
glusterd_snap_t*
glusterd_create_snap_object (dict_t *dict)
{
@@ -3376,43 +3071,6 @@ out:
return ret;
}
-char *
-glusterd_get_snap_from_cg (glusterd_volinfo_t *volinfo, glusterd_snap_cg_t *cg)
-{
- char *snap_name = NULL;
- glusterd_snap_t *tmp_snap = NULL;
- glusterd_snap_t *snap = NULL;
- glusterd_conf_t *priv = NULL;
- xlator_t *this = NULL;
-
- this = THIS;
- priv = this->private;
- GF_ASSERT (priv);
-
- if (!volinfo) {
- gf_log (this->name, GF_LOG_WARNING, "volinfo NULL");
- goto out;
- }
-
- if (!cg) {
- gf_log (this->name, GF_LOG_WARNING, "consistency group NULL");
- goto out;
- }
-
- list_for_each_entry (tmp_snap, &priv->snapshots, snap_list) {
- if ((!uuid_is_null (tmp_snap->cg_id)) &&
- (uuid_compare (tmp_snap->cg_id, cg->cg_id) == 0)) {
- snap = tmp_snap;
- break;
- }
- }
-
- if (snap)
- snap_name = gf_strdup (snap->snapname);
-out:
- return snap_name;
-}
-
int
glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
dict_t *rsp_dict)