summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c41
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mem-types.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c362
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c409
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h41
7 files changed, 20 insertions, 857 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index e8cda53..6774311 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7535,12 +7535,8 @@ out:
int32_t
cli_snapshot_remove_reply (gf_cli_rsp *rsp, dict_t *dict, call_frame_t *frame)
{
- int32_t ret = -1;
- char *snap_name = NULL;
- char *cg_name = NULL;
- int64_t volcount = -1;
- char *volname = NULL;
- gf_boolean_t is_cg = _gf_false;
+ int32_t ret = -1;
+ char *snap_name = NULL;
GF_ASSERT (rsp);
GF_ASSERT (dict);
@@ -7554,35 +7550,14 @@ cli_snapshot_remove_reply (gf_cli_rsp *rsp, dict_t *dict, call_frame_t *frame)
goto out;
}
- ret = dict_get_int64 (dict, "volcount", &volcount);
- if (!ret) {
- if (volcount == 1) {
- ret = dict_get_str (dict, "volname1", &volname);
- if (ret)
- gf_log ("", GF_LOG_WARNING, "getting volume name"
- " failed");
- } else
- is_cg = _gf_true;
- }
-
- if (is_cg) {
- if (dict_get_str (dict, "cgname",
- &cg_name) != 0)
- cg_name = "???";
-
- cli_out ("snapshot delete: %s: consistency "
- "group removed successfully",
- cg_name);
- } else {
- if (dict_get_str (dict, "snapname",
- &snap_name) != 0)
- snap_name = "???";
-
- cli_out ("snapshot delete: %s: "
- "snap removed successfully",
- snap_name);
+ ret = dict_get_str (dict, "snapname", &snap_name);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get snapname");
+ goto out;
}
+ cli_out ("snapshot delete: %s: snap removed successfully",
+ snap_name);
ret = 0;
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
index c1009d6..158e8ba 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
@@ -68,8 +68,7 @@ typedef enum gf_gld_mem_types_ {
gf_gld_mt_mop_commit_req_t = gf_common_mt_end + 52,
gf_gld_mt_int = gf_common_mt_end + 53,
gf_gld_mt_snap_t = gf_common_mt_end + 54,
- gf_gld_mt_snap_cg_t = gf_common_mt_end + 55,
- gf_gld_mt_end = gf_common_mt_end + 56,
+ gf_gld_mt_end = gf_common_mt_end + 55,
} gf_gld_mem_types_t;
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 9552c93..7434b7a 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)
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 613f03a..8dee4d4 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;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index 46f5ffb..008cca0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -63,13 +63,10 @@ typedef enum glusterd_store_ver_ac_{
#define GLUSTERD_STORE_KEY_SNAP_NAME "name"
#define GLUSTERD_STORE_KEY_SNAP_ID "snap-id"
-#define GLUSTERD_STORE_KEY_SNAP_CG_ID "cg-id"
-#define GLUSTERD_STORE_KEY_SNAP_CG_NAME "cg-name"
#define GLUSTERD_STORE_KEY_SNAP_DESC "desc"
#define GLUSTERD_STORE_KEY_SNAP_TIMESTAMP "time-stamp"
#define GLUSTERD_STORE_KEY_SNAP_STATUS "status"
#define GLUSTERD_STORE_KEY_SNAP_RESTORED "snap-restored"
-#define GLUSTERD_STORE_KEY_CG_VOL_COUNT "count"
#define GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT "snap-max-hard-limit"
#define GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT "snap-max-soft-limit"
@@ -160,11 +157,4 @@ glusterd_store_perform_volume_store (glusterd_volinfo_t *volinfo);
int32_t
glusterd_store_snap (glusterd_snap_t *snap);
-
-int32_t
-glusterd_store_snap_cg (glusterd_snap_cg_t *cg);
-
-int32_t
-glusterd_store_delete_snap_cg (glusterd_snap_cg_t *cg);
-
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index cd1bb88..45a0b7d 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -1275,16 +1275,6 @@ init (xlator_t *this)
exit (1);
}
- snprintf (storedir, PATH_MAX, "%s/%s", workdir,
- GLUSTERD_VOL_SNAP_CG_DIR_PREFIX);
- ret = mkdir (storedir, 0777);
- if ((-1 == ret) && (errno != EEXIST)) {
- gf_log (this->name, GF_LOG_CRITICAL,
- "Unable to create cgs directory %s"
- " ,errno = %d", storedir, errno);
- exit (1);
- }
-
ret = glusterd_rpcsvc_options_build (this->options);
if (ret)
goto out;
@@ -1349,7 +1339,6 @@ init (xlator_t *this)
INIT_LIST_HEAD (&conf->peers);
INIT_LIST_HEAD (&conf->volumes);
- INIT_LIST_HEAD (&conf->snap_cg);
INIT_LIST_HEAD (&conf->snapshots);
pthread_mutex_init (&conf->mutex, NULL);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index e81369e..cb4196a 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -163,7 +163,6 @@ typedef struct {
gf_boolean_t restart_done;
rpcsvc_t *uds_rpc; /* RPCSVC for the unix domain socket */
uint32_t base_port;
- struct list_head snap_cg;
uint64_t snap_max_hard_limit;
uint64_t snap_max_soft_limit;
char *snap_bricks_directory;
@@ -367,29 +366,13 @@ struct glusterd_snap_ {
struct list_head snap_list;
char snapname[GLUSTERD_MAX_SNAP_NAME];
uuid_t snap_id;
- char cg_name[256];
- uuid_t cg_id;
char *description;
time_t time_stamp;
- gf_boolean_t snap_restored;
+ gf_boolean_t snap_restored;
gd_snap_status_t snap_status;
gf_store_handle_t *shandle;
};
-struct glusterd_snap_cg_ {
- gf_lock_t lock;
- uuid_t cg_id;
- char cg_name[256];
- char *description;
- gd_snap_status_t cg_status;
- int64_t volume_count;
- struct list_head cg_list;
- gf_store_handle_t *shandle;
- glusterd_volinfo_t *volumes[0];
-};
-
-typedef struct glusterd_snap_cg_ glusterd_snap_cg_t;
-
typedef enum gd_node_type_ {
GD_NODE_NONE,
GD_NODE_BRICK,
@@ -437,7 +420,6 @@ enum glusterd_vol_comp_status_ {
#define GLUSTERD_NODE_STATE_FILE "node_state.info"
#define GLUSTERD_VOL_SNAP_FILE "snap_list.info"
#define GLUSTERD_VOL_SNAP_DIR_PREFIX "snaps"
-#define GLUSTERD_VOL_SNAP_CG_DIR_PREFIX "cgs"
#define GLUSTERD_DEFAULT_SNAPS_BRICK_DIR "/gluster/snaps"
#define GLUSTERD_VAR_RUN_DIR "/var/run"
@@ -467,10 +449,6 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);
snprintf (path, PATH_MAX, "%s/snaps/%s", priv->workdir, \
snap->snapname);
-#define GLUSTERD_GET_SNAP_CG_DIR(path, priv) \
- snprintf (path, PATH_MAX, "%s/%s", priv->workdir,\
- GLUSTERD_VOL_SNAP_CG_DIR_PREFIX);
-
#define GLUSTERD_GET_BRICK_DIR(path, volinfo, priv) \
if (volinfo->is_snap_volume) { \
snprintf (path, PATH_MAX, "%s/snaps/%s/%s/%s", priv->workdir, \
@@ -907,9 +885,6 @@ glusterd_txn_opinfo_init ();
glusterd_snap_t*
glusterd_new_snap_object();
-glusterd_snap_cg_t*
-glusterd_new_snap_cg_object(int64_t volume_count);
-
int32_t
glusterd_list_add_snapvol (glusterd_volinfo_t *origin_vol,
glusterd_volinfo_t *snap_vol);
@@ -926,20 +901,6 @@ glusterd_find_snap_by_name (char *snap_name);
glusterd_snap_t*
glusterd_find_snap_by_id (uuid_t snap_id);
-int32_t
-glusterd_add_snap_cg (glusterd_conf_t *conf, glusterd_snap_cg_t *cg);
-
-glusterd_snap_cg_t*
-glusterd_remove_snap_cg_by_name (glusterd_conf_t *conf, char *cg_name);
-
-glusterd_snap_cg_t*
-glusterd_remove_snap_cg_by_id (glusterd_conf_t *conf, uuid_t cg_id);
-
-glusterd_snap_cg_t*
-glusterd_find_snap_cg_by_id (glusterd_conf_t *conf, uuid_t cg_id);
-
-glusterd_snap_cg_t*
-glusterd_find_snap_cg_by_name (glusterd_conf_t *conf, char *cg_name);
int
glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
dict_t *rsp_dict);