summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2014-06-02 14:47:15 +0530
committerKaushal M <kaushal@redhat.com>2014-06-09 23:12:30 -0700
commit4b846dbb61fc6f41ba1bb3d52455f1b44e3a656e (patch)
treec1da54b6b1adf0f03999343d93677032b1a37a0a /xlators/mgmt
parent66b99406a769a14b50aac2d077b5698b8be30aa6 (diff)
mgmt/glusterd: delete only the oldest snapshot as part of autodelete
Now this is how autodelete behaves: 1) Upon creation when the max-soft-limit exceeds, the oldest snapshot is deleted. i.e if hard limit is 100 and by default soft limit is 90. Whenever snap count reaches 90, every new create results in the deletion of the oldest snapshot. 2) If the snap limit (hard) is reconfigured and brought down the current snap count, then no snapshot is deleted and the next snapshot create fails as the current snapcount is more than the hard limit. 3) When soft limit is brought down: say max limit is 100 and by default soft limit is 90 and current snap count is 90. Now, soft limit is changed to 70 (70%). In this case the snapshot count remains 90 itself (i.e extra 20 snapshots more than the soft limit are not deleted) and for every new create the oldest snapshot is deleted. Change-Id: I1f3b4b9eb093649f8628ebf09a15bd2570ddf340 BUG: 1103665 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/7951 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 7d3c795b436..7a6d143e5de 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -5681,7 +5681,6 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
glusterd_snap_t *snap = NULL;
glusterd_volinfo_t *tmp_volinfo = NULL;
glusterd_volinfo_t *other_volinfo = NULL;
- int64_t var = 0;
this = THIS;
GF_ASSERT (this);
@@ -5727,35 +5726,30 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
if (count <= 0)
goto out;
- list_for_each_entry_safe (tmp_volinfo, other_volinfo,
- &volinfo->snap_volumes, snapvol_list) {
- if (var == count)
- break;
-
- snap = tmp_volinfo->snapshot;
- GF_ASSERT (snap);
-
- LOCK (&snap->lock);
- {
- snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
- ret = glusterd_store_snap (snap);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "could "
- "not store snap object %s",
- snap->snapname);
- goto unlock;
- }
+ tmp_volinfo = list_entry (volinfo->snap_volumes.next,
+ glusterd_volinfo_t, snapvol_list);
+ snap = tmp_volinfo->snapshot;
+ GF_ASSERT (snap);
- ret = glusterd_snap_remove (rsp_dict, snap,
- _gf_true, _gf_true);
- if (ret)
- gf_log (this->name, GF_LOG_WARNING,
- "failed to remove snap %s",
- snap->snapname);
+ LOCK (&snap->lock);
+ {
+ snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
+ ret = glusterd_store_snap (snap);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "could "
+ "not store snap object %s",
+ snap->snapname);
+ goto unlock;
}
- unlock: UNLOCK (&snap->lock);
- var++;
+
+ ret = glusterd_snap_remove (rsp_dict, snap,
+ _gf_true, _gf_true);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to remove snap %s",
+ snap->snapname);
}
+ unlock: UNLOCK (&snap->lock);
}
out: