From 1e26f070bb470adafd0a316c18f2fb9e1b103f27 Mon Sep 17 00:00:00 2001 From: Vijaykumar M Date: Fri, 3 Jan 2014 12:11:19 +0530 Subject: glusterd: add volinfo to the list data structure in an order Currently volinfo is added at the end of the list while creating a volume. On gluster restart, readdir will not provide the ordered list and the data is populated in the same order as readdir. Solution is to insert the volinfo to the list in an order Change-Id: I1716ac6abbd7dd301a7125425fc413c6833f7a48 BUG: 1039912 Signed-off-by: Vijaykumar M Reviewed-on: http://review.gluster.org/6472 Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System Reviewed-by: Kaushal M --- libglusterfs/src/list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h index 7f3712b51..794586e35 100644 --- a/libglusterfs/src/list.h +++ b/libglusterfs/src/list.h @@ -45,6 +45,21 @@ list_add_tail (struct list_head *new, struct list_head *head) } +static inline void +list_add_order (struct list_head *new, struct list_head *head, + int (*compare)(struct list_head *, struct list_head *)) +{ + struct list_head *pos = head->next; + + while ( pos != head ) { + if (compare(new, pos) <= 0) + break; + pos = pos->next; + } + + list_add_tail(new, pos); +} + static inline void list_del (struct list_head *old) { -- cgit