[PATCH 2/8] io-wq: add helper to merge two wq_lists

Hao Xu
2021-09-27T06:17:32Z

add a helper to merge two wq_lists, it will be useful in the next
patches.

Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
---
fs/io-wq.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/fs/io-wq.h b/fs/io-wq.h
index 8369a51b65c0..7510b05d4a86 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -39,6 +39,26 @@ static inline void wq_list_add_after(struct io_wq_work_node *node,
list->last = node;
}

+/**
+ * wq_list_merge - merge the second list to the first one.
+ * @list0: the first list
+ * @list1: the second list
+ * after merge, list0 contains the merged list.
+ */
+static inline void wq_list_merge(struct io_wq_work_list *list0,
+ struct io_wq_work_list *list1)
+{
+ if (!list1)
+ return;
+
+ if (!list0) {
+ list0 = list1;
+ return;
+ }
+ list0->last->next = list1->first;
+ list0->last = list1->last;
+}
+
static inline void wq_list_add_tail(struct io_wq_work_node *node,
struct io_wq_work_list *list)
{
--
2.24.4