From d473623668f91303287bfe539709a3b7f4a654a7 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 15 Mar 2011 01:53:42 +0000 Subject: core: Add list_append_init To append to end of list, as compared to list_splice_init which prepends. Signed-off-by: Shehjar Tikoo Signed-off-by: Anand Avati BUG: 2491 ([glusterfs-3.1.3qa4]: iozone fails due to data corruption) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2491 --- libglusterfs/src/list.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h index d4851dfec..9c2b7720b 100644 --- a/libglusterfs/src/list.h +++ b/libglusterfs/src/list.h @@ -120,6 +120,7 @@ list_splice (struct list_head *list, struct list_head *head) } +/* Splice moves @list to the head of the list at @head. */ static inline void list_splice_init (struct list_head *list, struct list_head *head) { @@ -131,6 +132,38 @@ list_splice_init (struct list_head *list, struct list_head *head) } +static inline void +__list_append (struct list_head *list, struct list_head *head) +{ + (head->prev)->next = (list->next); + (list->next)->prev = (head->prev); + (head->prev) = (list->prev); + (list->prev)->next = head; +} + + +static inline void +list_append (struct list_head *list, struct list_head *head) +{ + if (list_empty (list)) + return; + + __list_append (list, head); +} + + +/* Append moves @list to the end of @head */ +static inline void +list_append_init (struct list_head *list, struct list_head *head) +{ + if (list_empty (list)) + return; + + __list_append (list, head); + INIT_LIST_HEAD (list); +} + + #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) -- cgit