summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);