summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot.c
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-02-14 20:01:38 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-03 22:58:23 -0800
commitfe5927b6bd1ed795c9e85996e7c54c3abe36ceba (patch)
treed69e25c323a4b57c49af8555db75ff65c9690701 /xlators/mgmt/glusterd/src/glusterd-snapshot.c
parent60d4f64cea4752f76b9495bdea255b51d09820ff (diff)
glusterd/snapshot: store location for snap driven changes
Currently snapshot volfiles are stored at: <workdir>/vols/<volname>/snaps/<snapvol> With snap driven approach we need to store the volfiles at: <workdir>/snaps/<snapname>/<snapvol> Change-Id: I8efdd5db29833b2b06b64a900cbb4c9b9a5d36b6 Signed-off-by: Vijaikumar M <vmallika@redhat.com> Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/7006 Reviewed-by: Avra Sengupta <asengupt@redhat.com> 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.c393
1 files changed, 168 insertions, 225 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 4093cda1c..ee077e7bc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -114,7 +114,7 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr)
goto out;
}
- snap = glusterd_find_snap_by_name (volinfo, snapname);
+ snap = glusterd_find_snap_by_name (snapname);
if (NULL == snap) {
ret = gf_asprintf (op_errstr, "Snap (%s) not found",
snapname);
@@ -257,7 +257,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
- snap = glusterd_find_snap_by_name (volinfo, snapname);
+ snap = glusterd_find_snap_by_name (snapname);
if (NULL == snap) {
ret = gf_asprintf (op_errstr, "Snap (%s) not found",
snapname);
@@ -844,6 +844,7 @@ glusterd_new_snap_object()
if (snap) {
LOCK_INIT (&snap->lock);
INIT_LIST_HEAD (&snap->snap_list);
+ INIT_LIST_HEAD (&snap->volumes);
snap->snap_status = GD_SNAP_STATUS_INIT;
}
@@ -876,178 +877,124 @@ glusterd_new_snap_cg_object(int64_t 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
-glusterd_add_snap (glusterd_volinfo_t *volinfo, glusterd_snap_t *snap)
+glusterd_list_add_snapvol (glusterd_volinfo_t *origin_vol,
+ glusterd_volinfo_t *snap_vol)
{
- int ret = -1;
- uint64_t count = -1;
- glusterd_snap_t *entry = NULL;
- glusterd_snap_t *last = NULL;
- glusterd_snap_t *tmp = NULL;
+ int ret = -1;
+ glusterd_snap_t *snap = NULL;
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
- GF_VALIDATE_OR_GOTO ("glusterd", snap, out);
+ GF_VALIDATE_OR_GOTO ("glusterd", origin_vol, out);
+ GF_VALIDATE_OR_GOTO ("glusterd", snap_vol, out);
- LOCK (&volinfo->lock);
- {
- list_for_each_entry_safe (entry, tmp, &volinfo->snaps,
- snap_list) {
- count++;
- if (!strcmp (entry->snap_name, snap->snap_name) ||
- !uuid_compare (entry->snap_id, snap->snap_id)) {
- gf_log (THIS->name, GF_LOG_ERROR, "Found "
- "duplicate snap %s (%s)",
- entry->snap_name,
- uuid_utoa (entry->snap_id));
- goto unlock;
- }
- last = entry;
- }
- list_add_tail (&snap->snap_list, &volinfo->snaps);
- volinfo->snap_count++;
- gf_log (THIS->name, GF_LOG_DEBUG, "Snap %s added @ %"PRIu64,
- snap->snap_name, count);
- ret = 0;
- }
-unlock:
- UNLOCK (&volinfo->lock);
-out:
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
- return ret;
-}
-
-glusterd_snap_t*
-glusterd_find_snap_by_index (glusterd_volinfo_t *volinfo, uint64_t index)
-{
- uint64_t count = 0;
- glusterd_snap_t *entry = NULL;
- glusterd_snap_t *tmp = NULL;
+ snap = snap_vol->snapshot;
+ GF_ASSERT (snap);
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
+ list_add_tail (&snap_vol->vol_list, &snap->volumes);
+ /* TODO: As of now there is only one volume per snapshot.
+ Below line should be removed once multiple volumes for
+ snap driven structucture is implemented */
+ snap->snap_volume = snap_vol;
- LOCK (&volinfo->lock);
+ LOCK (&origin_vol->lock);
{
- list_for_each_entry_safe (entry, tmp, &volinfo->snaps,
- snap_list) {
- if (index == count) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found "
- "snap %s (%s)", entry->snap_name,
- uuid_utoa (entry->snap_id));
- break;
- }
- ++count;
- }
+ list_add_tail (&snap_vol->snapvol_list,
+ &origin_vol->snap_volumes);
+ origin_vol->snap_count++;
}
- UNLOCK (&volinfo->lock);
+ UNLOCK (&origin_vol->lock);
+
+ gf_log (THIS->name, GF_LOG_DEBUG, "Snap %s added to the list",
+ snap->snapname);
+ ret = 0;
out:
- return entry;
+ return ret;
}
glusterd_snap_t*
-glusterd_find_snap_by_name (glusterd_volinfo_t *volinfo, char *snap_name)
+glusterd_find_snap_by_name (char *snapname)
{
- uint64_t count = -1;
- glusterd_snap_t *entry = NULL;
- glusterd_snap_t *dup = NULL;
- glusterd_snap_t *tmp = NULL;
+ glusterd_snap_t *snap = NULL;
+ glusterd_conf_t *priv = NULL;
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
- GF_VALIDATE_OR_GOTO ("glusterd", snap_name, out);
+ priv = THIS->private;
+ GF_ASSERT (priv);
+ GF_ASSERT (snapname);
- LOCK (&volinfo->lock);
- {
- list_for_each_entry_safe (entry, tmp, &volinfo->snaps,
- snap_list) {
- count++;
- if (!strcmp (entry->snap_name, snap_name)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found "
- "snap %s (%s)", entry->snap_name,
- uuid_utoa (entry->snap_id));
- dup = entry;
- break;
- }
+
+ list_for_each_entry (snap, &priv->snapshots, snap_list) {
+ if (!strcmp (snap->snapname, snapname)) {
+ gf_log (THIS->name, GF_LOG_DEBUG, "Found "
+ "snap %s (%s)", snap->snapname,
+ uuid_utoa (snap->snap_id));
+ goto out;
}
}
- UNLOCK (&volinfo->lock);
+ snap = NULL;
out:
- return dup;
+ return snap;
}
glusterd_snap_t*
-glusterd_find_snap_by_id (glusterd_volinfo_t *volinfo, uuid_t snap_id)
+glusterd_find_snap_by_id (uuid_t snap_id)
{
- uint64_t count = -1;
- glusterd_snap_t *entry = NULL;
- glusterd_snap_t *dup = NULL;
- glusterd_snap_t *tmp = NULL;
+ glusterd_snap_t *snap = NULL;
+ glusterd_conf_t *priv = NULL;
+
+ priv = THIS->private;
+ GF_ASSERT (priv);
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
if (uuid_is_null(snap_id))
goto out;
- LOCK (&volinfo->lock);
- {
- list_for_each_entry_safe (entry, tmp, &volinfo->snaps,
- snap_list) {
- count++;
- if (!uuid_compare (entry->snap_id, snap_id)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found "
- "snap %s (%s)", entry->snap_name,
- uuid_utoa (entry->snap_id));
- dup = entry;
- break;
- }
+ list_for_each_entry (snap, &priv->snapshots, snap_list) {
+ if (!uuid_compare (snap->snap_id, snap_id)) {
+ gf_log (THIS->name, GF_LOG_DEBUG, "Found "
+ "snap %s (%s)", snap->snapname,
+ uuid_utoa (snap->snap_id));
+ goto out;
}
}
- UNLOCK (&volinfo->lock);
+ snap = NULL;
out:
- return dup;
+ return snap;
}
glusterd_snap_t*
-glusterd_remove_snap_by_id (glusterd_volinfo_t *volinfo, uuid_t snap_id)
+glusterd_remove_snap_by_id (uuid_t snap_id)
{
- glusterd_snap_t *entry = NULL;
+ glusterd_snap_t *snap = NULL;
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
if (uuid_is_null(snap_id))
goto out;
- entry = glusterd_find_snap_by_id (volinfo, snap_id);
+ snap = glusterd_find_snap_by_id (snap_id);
- if (entry) {
- LOCK (&volinfo->lock);
- {
- entry->snap_status = GD_SNAP_STATUS_DECOMMISSION;
- list_del_init (&entry->snap_list);
- }
- UNLOCK (&volinfo->lock);
+ if (snap) {
+ snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
+ list_del_init (&snap->snap_list);
}
out:
- return entry;
+ return snap;
}
glusterd_snap_t*
-glusterd_remove_snap_by_name (glusterd_volinfo_t *volinfo, char *snap_name)
+glusterd_remove_snap_by_name (char *snapname)
{
- glusterd_snap_t *entry = NULL;
+ glusterd_snap_t *snap = NULL;
- GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out);
- GF_VALIDATE_OR_GOTO ("glusterd", snap_name, out);
+ GF_VALIDATE_OR_GOTO ("glusterd", snapname, out);
- entry = glusterd_find_snap_by_name (volinfo, snap_name);
+ snap = glusterd_find_snap_by_name (snapname);
- if (entry) {
- LOCK (&volinfo->lock);
- {
- entry->snap_status = GD_SNAP_STATUS_DECOMMISSION;
- list_del_init (&entry->snap_list);
- volinfo->snap_count--;
- }
- UNLOCK (&volinfo->lock);
+ if (snap) {
+ snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
+ list_del_init (&snap->snap_list);
}
out:
- return entry;
+ return snap;
}
// Big lock should already acquired before this is called
@@ -1165,13 +1112,12 @@ out:
}
int32_t
-glusterd_delete_snap_volume (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snapinfo)
+glusterd_delete_snap_volume (glusterd_volinfo_t *snapinfo)
{
int ret = -1;
- GF_ASSERT (volinfo);
+ GF_ASSERT (snapinfo);
- ret = glusterd_store_delete_volume (volinfo, snapinfo);
+ ret = glusterd_store_delete_volume (snapinfo);
if (ret)
goto out;
@@ -1215,7 +1161,7 @@ glusterd_snapshot_get_snapdetail_lk (dict_t *dict, char *keyprefix,
GF_ASSERT (entry);
/* Snap Name */
- value = gf_strdup (entry->snap_name);
+ value = gf_strdup (entry->snapname);
if (NULL == value) {
goto out;
}
@@ -1560,7 +1506,7 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix,
value = NULL;
/* snapshot taken first should be displayed first */
- list_for_each_entry_safe (entry, tmp, &volinfo->snaps,
+ list_for_each_entry_safe (entry, tmp, &conf->snapshots,
snap_list) {
ret = snprintf (key, sizeof (key), "%s.snap-%ld", keyprefix,
index);
@@ -1584,8 +1530,8 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix,
/* If snapname is provided then get snap detail
* for only that snap */
- if (strncmp (entry->snap_name, snapname,
- sizeof (entry->snap_name))) {
+ if (strncmp (entry->snapname, snapname,
+ sizeof (entry->snapname))) {
/* Entry not yet found.*/
ret = -1;
continue; /* Check the next entry */
@@ -2294,7 +2240,7 @@ glusterd_get_cg_snap_name_lk (dict_t *dict, glusterd_snap_cg_t *cg)
goto out;
}
- snap = glusterd_find_snap_by_index (volinfo, 0);
+ //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);
@@ -2302,7 +2248,7 @@ glusterd_get_cg_snap_name_lk (dict_t *dict, glusterd_snap_cg_t *cg)
goto out;
}
- snapname = gf_strdup (snap->snap_name);
+ snapname = gf_strdup (snap->snapname);
if (NULL == snapname) {
ret = -1;
goto out;
@@ -2652,11 +2598,11 @@ glusterd_snap_delete (glusterd_snap_t *snap)
goto out;
}
- GF_FREE (snap->description);
- ret = glusterd_volinfo_delete (snap->snap_volume);
+ ret = glusterd_store_delete_snap (snap);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "deleting the snap volume"
- "failed for the snap %s", snap->snap_name);
+ goto out;
+
+ GF_FREE (snap->description);
GF_FREE (snap);
ret = 0;
@@ -2693,21 +2639,21 @@ out:
3. Then do this and take the snapshot OR take the snapshot and build the
snap object (Can be decided later)
*/
-int32_t
+glusterd_snap_t*
glusterd_snap_create (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo, char *snapname,
+ char *snapname, uuid_t *snap_id,
char *description, uuid_t *cg_id,
glusterd_snap_cg_t *cg, char *cg_name)
{
glusterd_snap_t *snap = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
- int ret = -1;
+ int ret = -1;
this = THIS;
priv = this->private;
- GF_ASSERT (snap_volinfo);
+ GF_ASSERT (snap_id);
GF_ASSERT (snapname);
if (cg_id)
GF_ASSERT (cg_name);
@@ -2748,37 +2694,30 @@ glusterd_snap_create (glusterd_volinfo_t *volinfo,
}
}
snap->time_stamp = time (NULL);
- uuid_copy (snap->snap_id, snap_volinfo->volume_id);
+ uuid_copy (snap->snap_id, *snap_id);
if (cg_id){
uuid_copy (snap->cg_id, *cg_id);
strncpy (snap->cg_name, cg_name,
sizeof (snap->cg_name) - 1);
}
- snap->snap_volume = snap_volinfo;
- strcpy (snap->snap_name, snapname);
-
- ret = glusterd_add_snap (volinfo, snap);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "could not add the snap "
- "object %s to the snap list of the volume %s",
- snap_volinfo->volname, volinfo->volname);
- goto out;
- }
+ strcpy (snap->snapname, snapname);
snap->snap_status = GD_SNAP_STATUS_IN_USE;
+ ret = 0;
out:
if (ret) {
if (snap) {
list_del_init (&snap->snap_list);
+ list_del_init (&snap->volumes);
LOCK_DESTROY (&snap->lock);
GF_FREE (snap->description);
GF_FREE (snap->snap_volume);
GF_FREE (snap);
}
+ snap = NULL;
}
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
- return ret;
+ return snap;
}
/* This function is called to get the device path of the snap lvm. Usually
@@ -3104,7 +3043,7 @@ out:
int32_t
glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
glusterd_snap_cg_t *cg, uuid_t *cg_id, int volcount,
- uuid_t snap_volid, char *cg_name)
+ uuid_t *snap_volid, char *cg_name)
{
char *snap_brick_mount_path = "";
char snapmntname[PATH_MAX] = "";
@@ -3117,6 +3056,7 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
glusterd_brickinfo_t *brickinfo = NULL;
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *snap_volume = NULL;
+ glusterd_snap_t *snap = NULL;
int32_t ret = -1;
int32_t brick_count = 0;
xlator_t *this = NULL;
@@ -3132,6 +3072,16 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
if (cg_id)
GF_ASSERT (cg_name);
+ snap = glusterd_snap_create (volinfo, snapname, snap_volid,
+ description, cg_id, cg, cg_name);
+ if (!snap) {
+ gf_log (this->name, GF_LOG_ERROR, "creating the "
+ "snap object failed for the volume %s",
+ volinfo->volname);
+ ret = -1;
+ goto out;
+ }
+
ret = glusterd_volinfo_dup (volinfo, &snap_volume);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to duplicate volinfo "
@@ -3141,12 +3091,13 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
/* snap uuid is used as lvm snapshot name.
This will avoid restrictions on snapshot names provided by user */
- GLUSTERD_GET_UUID_NOHYPHEN (snap_volume->volname, snap_volid);
-
+ GLUSTERD_GET_UUID_NOHYPHEN (snap_volume->volname, *snap_volid);
+ snap_volume->snapshot = snap;
snap_volume->is_snap_volume = _gf_true;
strncpy (snap_volume->parent_volname, volinfo->volname,
sizeof(snap_volume->parent_volname) - 1);
- uuid_copy (snap_volume->volume_id, snap_volid);
+ uuid_copy (snap_volume->volume_id, *snap_volid);
+ snap->snap_volume = snap_volume;
/* fetch internal username and password for the snap*/
@@ -3251,22 +3202,19 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
//TODO: the quorum check of the snap volume here
- ret = dict_get_str (dict, "snap-description", &description);
- // for now continue the snap, if getting description fails.
-
- ret = glusterd_snap_create (volinfo, snap_volume, snapname,
- description, cg_id, cg, cg_name);
+ ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "creating the"
- "snap object failed for the volume %s",
+ gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
+ "object after taking the snapshot (volume: %s)",
volinfo->volname);
goto out;
}
- ret = glusterd_store_perform_snap_store (volinfo, snapname);
+ ret = glusterd_store_volinfo (snap_volume,
+ GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "could not do volume store"
- " after taking the snapshot (volume: %s)",
+ gf_log (this->name, GF_LOG_ERROR, "Failed to store snapshot "
+ "volinfo (%s) for volume %s", snap_volume->volname,
volinfo->volname);
goto out;
}
@@ -3297,15 +3245,21 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
goto out;
}
- //check whether this is needed or not
- list_add_tail (&snap_volume->vol_list, &priv->snap_list);
+ list_add_tail (&snap->snap_list, &priv->snapshots);
+ ret = glusterd_list_add_snapvol (volinfo, snap_volume);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "could not add the snap "
+ "volume %s to the list",
+ snap_volume->volname);
+ goto out;
+ }
list_for_each_entry (brickinfo, &snap_volume->bricks, brick_list) {
if (uuid_compare (brickinfo->uuid, MY_UUID))
continue;
- ret = glusterd_snap_brick_start (volinfo, snap_volume, brickinfo,
- _gf_true);
+ ret = glusterd_brick_start (snap_volume, brickinfo,
+ _gf_true);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "starting the "
"brick %s:%s for the snap %s (volume: %s) "
@@ -3317,23 +3271,20 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
snap_volume->status = GLUSTERD_STATUS_STARTED;
- ret = glusterd_store_perform_snap_volume_store (volinfo, snap_volume);
+out:
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to store snapshot volinfo (%s) for volume "
- "%s", snap_volume->volname, volinfo->volname);
- goto out;
- }
+ if (snap_volume) {
+ list_del_init (&snap_volume->vol_list);
+ list_del_init (&snap_volume->snapvol_list);
+ glusterd_delete_snap_volume (snap_volume);
+ }
- ret = glusterd_volume_compute_cksum (volinfo, snap_volume);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to compute cksum for %s", snap_volume->volname);
- goto out;
+ if (snap) {
+ glusterd_remove_snap_by_name (snap->snapname);
+ glusterd_snap_delete (snap);
+ }
}
-out:
- if (ret)
- glusterd_volinfo_delete (snap_volume);
-
gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -3603,7 +3554,7 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr,
"failed (volume: %s)", volname);
goto out;
}
- snap = glusterd_find_snap_by_name (volinfo, name);
+ snap = glusterd_find_snap_by_name (name);
if (!snap) {
ret = -1;
snprintf (err_str, sizeof (err_str), "snap %s does "
@@ -3621,17 +3572,17 @@ out:
}
int
-glusterd_remove_snap (glusterd_brickinfo_t *brickinfo, const char *mount_pt,
- const char *volname, const char *snapname,
+glusterd_remove_snap (glusterd_volinfo_t *snap_vol,
+ glusterd_brickinfo_t *brickinfo, const char *mount_pt,
const char *snap_device)
{
- int ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- runner_t runner = {0,};
- char msg[1024] = {0, };
+ int ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ runner_t runner = {0,};
+ char msg[1024] = {0, };
char pidfile[PATH_MAX] = {0, };
- pid_t pid = -1;
+ pid_t pid = -1;
this = THIS;
GF_ASSERT (this);
@@ -3643,9 +3594,8 @@ glusterd_remove_snap (glusterd_brickinfo_t *brickinfo, const char *mount_pt,
goto out;
}
+ GF_ASSERT (snap_vol);
GF_ASSERT (mount_pt);
- GF_ASSERT (volname);
- GF_ASSERT (snapname);
GF_ASSERT (snap_device);
/* sleep for some time so that the glusterfsd process associated
@@ -3657,8 +3607,7 @@ glusterd_remove_snap (glusterd_brickinfo_t *brickinfo, const char *mount_pt,
//ret = umount2 (mount_pt, MNT_FORCE);
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volname, snapname, brickinfo,
- priv);
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, snap_vol, brickinfo, priv);
if (glusterd_is_service_running (pidfile, &pid)) {
ret = kill (pid, SIGKILL);
if (ret && errno != ESRCH) {
@@ -3761,9 +3710,8 @@ glusterd_brick_snapshot_remove (glusterd_volinfo_t *snap_volinfo,
ret = -1;
goto out;
}
- ret = glusterd_remove_snap (brickinfo, mnt_pt,
- actual_volinfo->volname,
- name, entry->mnt_fsname);
+ ret = glusterd_remove_snap (snap_volinfo, brickinfo, mnt_pt,
+ entry->mnt_fsname);
if (mtab)
endmntent (mtab);
if (ret) {
@@ -3806,7 +3754,7 @@ glusterd_do_snap_remove (glusterd_volinfo_t *volinfo, char *name)
goto out;
}
- snap = glusterd_find_snap_by_name (volinfo, name);
+ snap = glusterd_find_snap_by_name (name);
if (!snap) {
gf_log (this->name, GF_LOG_ERROR, "could not find "
"the snap object by the name %s",
@@ -3831,9 +3779,7 @@ glusterd_do_snap_remove (glusterd_volinfo_t *volinfo, char *name)
(May be a force option to delete forcefully even
when the snap volume is in use.)
*/
- ret = glusterd_snap_brick_stop (volinfo, snap_volinfo,
- brickinfo,
- _gf_false);
+ ret = glusterd_brick_stop (snap_volinfo, brickinfo, _gf_false);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "stopping "
"the brick %s:%s for the snap %s "
@@ -3853,26 +3799,20 @@ glusterd_do_snap_remove (glusterd_volinfo_t *volinfo, char *name)
goto out;
}
- ret = glusterd_store_delete_volume (volinfo, snap->snap_volume);
+ list_del_init (&snap->snap_volume->vol_list);
+ list_del_init (&snap->snap_volume->snapvol_list);
+ ret = glusterd_delete_snap_volume (snap->snap_volume);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "removing the snap "
"store for the snap %s (volume %s) failed",
- snap->snap_name, volinfo->volname);
+ snap->snapname, volinfo->volname);
goto out;
}
- snap = glusterd_remove_snap_by_name (volinfo, snap->snap_name);
+ snap = glusterd_remove_snap_by_name (snap->snapname);
GF_ASSERT (snap); //snap cannot be NULL;
glusterd_snap_delete (snap); //deletes in memory snap object
- ret = glusterd_store_perform_snap_list_store (volinfo);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "doing the snap "
- "store for the volume %s failed",
- volinfo->volname);
- goto out;
- }
-
ret = 0;
out:
return ret;
@@ -3884,10 +3824,12 @@ 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;
- GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!volinfo) {
gf_log (this->name, GF_LOG_WARNING, "volinfo NULL");
@@ -3899,7 +3841,7 @@ glusterd_get_snap_from_cg (glusterd_volinfo_t *volinfo, glusterd_snap_cg_t *cg)
goto out;
}
- list_for_each_entry (tmp_snap, &volinfo->snaps, snap_list) {
+ 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;
@@ -3908,7 +3850,7 @@ glusterd_get_snap_from_cg (glusterd_volinfo_t *volinfo, glusterd_snap_cg_t *cg)
}
if (snap)
- snap_name = gf_strdup (snap->snap_name);
+ snap_name = gf_strdup (snap->snapname);
out:
return snap_name;
@@ -4003,6 +3945,7 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
(volinfo)?"snap":"cg", name);
goto out;
}
+ volinfo->snap_count--;
if (free_name)
GF_FREE (name);
name = NULL;
@@ -4162,8 +4105,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
goto out;
}
- list_for_each_entry (snap, &volinfo->snaps, snap_list) {
- if (!strcmp (snap->snap_name, tmp_name)) {
+ list_for_each_entry (snap, &priv->snapshots, snap_list) {
+ if (!strcmp (snap->snapname, tmp_name)) {
snprintf (err_str, sizeof (err_str), "snap with"
" name %s already exists", tmp_name);
gf_log (this->name, GF_LOG_ERROR, "%s",
@@ -4188,11 +4131,11 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
*/
if (is_cg) {
ret = glusterd_do_snap (volinfo, tmp_name, dict,
- cg, cg_id, i, *snap_volid, name);
+ cg, cg_id, i, snap_volid, name);
}
else {
ret = glusterd_do_snap (volinfo, tmp_name, dict,
- cg, cg_id, i, *snap_volid, NULL);
+ cg, cg_id, i, snap_volid, NULL);
}
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "taking the "