[PATCH 4/5] list_bl: add hlist_bl_move_list and two macros

Woody Zhang posted 5 patches 1 year, 5 months ago
[PATCH 4/5] list_bl: add hlist_bl_move_list and two macros
Posted by Woody Zhang 1 year, 5 months ago
hlist_bl_move_list is similar to hlist_move_list. Caller should decide
whether bit locking is required for old and new hash list.

Signed-off-by: Woody Zhang <woodyzhang666@gmail.com>
---
 include/linux/list_bl.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index d25c659f6635..928048354e04 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -38,6 +38,8 @@ struct hlist_bl_head {
 struct hlist_bl_node {
 	struct hlist_bl_node *next, **pprev;
 };
+#define HLIST_BL_HEAD_INIT { .first = NULL }
+#define HLIST_BL_HEAD(name) struct hlist_bl_head name = {  .first = NULL }
 #define INIT_HLIST_BL_HEAD(ptr) \
 	((ptr)->first = NULL)
 
@@ -142,6 +144,17 @@ static inline void hlist_bl_del_init(struct hlist_bl_node *n)
 	}
 }
 
+static inline void hlist_bl_move_list(struct hlist_bl_head *old,
+				   struct hlist_bl_head *new)
+{
+	struct hlist_bl_node *n = hlist_bl_first(old);
+
+	hlist_bl_set_first(new, n);
+	if (n)
+		n->pprev = &new->first;
+	hlist_bl_set_first(old, NULL);
+}
+
 static inline void hlist_bl_lock(struct hlist_bl_head *b)
 {
 	bit_spin_lock(0, (unsigned long *)b);
-- 
2.45.2