[PATCH] 0/4: Add the ability to splice a list into another list

"Darrick J. Wong" <[email protected]>
Newsgroups gmane.linux.ataraid
Organization IBM LTC
Message-ID <[email protected]>
Hi all,

These are preliminary patches to modify dmraid so that we can have
multiple raid_dev structures per physical device.  The DDF1
specification allows for a disk to participate in multiple RAID arrays,
which is what is gained from these patches.  They've been tested against
2.6.16.19 + dmraid45 on Ubuntu 6.06, and seem to be pretty stable.  At
this stage, I'm looking for comments about the code because it touches
core dmraid code and could (but shouldn't) break support for hardware
that I don't have.

This first patch is a simple one that adds an operation to splice a
headless doubly-linked list into an existing headed list.  The headless
lists are created in the second patch.

--D

Signed-off-by: Darrick J. Wong <[email protected]>

_______________________________________________
Ataraid-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/ataraid-list
list-splice.patch (text/x-patch, 773 B)
diff -Naurp v11.orig/include/dmraid/list.h v11-mdisk3/include/dmraid/list.h
--- v11.orig/include/dmraid/list.h	2005-09-13 06:37:33.000000000 -0700
+++ v11-mdisk3/include/dmraid/list.h	2006-06-01 16:35:57.000000000 -0700
@@ -67,4 +67,26 @@ static inline void __list_add(struct lis
              pos != (head); \
              pos = n, n = pos->next)
 
+/*
+ * Insert list into the list anchored by head.
+ * Assume that "list" is a self-contained loop.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+	struct list_head *l1, *h1;
+
+	if (list_empty(list)) {
+		list_add_tail(list, head);
+		return;
+	}
+
+	l1 = list->next;
+	h1 = head->next;
+
+	head->next = l1;
+	l1->prev = head;
+	list->next = h1;
+	h1->prev = list;
+}
+
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.