summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-03-21 11:43:10 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-25 02:43:37 -0700
commitcb9bb522972b6cff45c0b6646100151e30e6424c (patch)
treea06e771ace5e43378552e557c7c1410d18366115
parent36ed5cfb45a63196b8350e32c1a0b81aedb3f51f (diff)
glusterd/snapshot: populate the snapshot volume list in the order when the glusterd is restarted
We are storing the snapshot objects in the order. We need to do the same for snapshot volumes Change-Id: Iea9594632e52d069f167cc8a840c78d0f7109947 Signed-off-by: Vijaikumar M <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/7307 Reviewed-by: Sachin Pandit <spandit@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c18
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
3 files changed, 24 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 1115dda..9552c93 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -840,8 +840,9 @@ glusterd_list_add_snapvol (glusterd_volinfo_t *origin_vol,
LOCK (&origin_vol->lock);
{
- list_add_tail (&snap_vol->snapvol_list,
- &origin_vol->snap_volumes);
+ list_add_order (&snap_vol->snapvol_list,
+ &origin_vol->snap_volumes,
+ glusterd_compare_snap_vol_time);
origin_vol->snap_count++;
}
UNLOCK (&origin_vol->lock);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index cd2fb80..a398058 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -8613,3 +8613,21 @@ glusterd_compare_snap_time(struct list_head *list1, struct list_head *list2)
return ((int)diff_time);
}
+
+int
+glusterd_compare_snap_vol_time(struct list_head *list1, struct list_head *list2)
+{
+ glusterd_volinfo_t *snapvol1 = NULL;
+ glusterd_volinfo_t *snapvol2 = NULL;
+ double diff_time = 0;
+
+ GF_ASSERT (list1);
+ GF_ASSERT (list2);
+
+ snapvol1 = list_entry(list1, glusterd_volinfo_t, snapvol_list);
+ snapvol2 = list_entry(list2, glusterd_volinfo_t, snapvol_list);
+ diff_time = difftime(snapvol1->snapshot->time_stamp,
+ snapvol2->snapshot->time_stamp);
+
+ return ((int)diff_time);
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index f15f305..ae2406c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -610,6 +610,9 @@ glusterd_get_brick_root (char *path, char **mount_point);
int
glusterd_compare_snap_time(struct list_head *, struct list_head *);
+int
+glusterd_compare_snap_vol_time(struct list_head *, struct list_head *);
+
int32_t
glusterd_snap_volinfo_restore (glusterd_volinfo_t *new_volinfo,
glusterd_volinfo_t *snap_volinfo);