On 10/29/21 13:22, Hao Xu wrote:
add a helper to merge two wq_lists, it will be useful in the next
patches.
Signed-off-by: Hao Xu <haoxu@xxxxxxxxxxxxxxxxx>
---
fs/io-wq.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 41bf37674a49..a7b0b505db9d 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -52,6 +52,27 @@ 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
+ * Return list0 if list1 is NULL, and vice versa.
+ * Otherwise after merge, list0 contains the merged list.
+ */
+static inline struct io_wq_work_list *wq_list_merge(struct io_wq_work_list *list0,
+ struct io_wq_work_list *list1)
might be easier if it'd be a splice or even initialising both lists
and returning a node ptr. E.g. (untested)
struct node* wq_list_splice(list0, list1) {
struct node *ret;
if (!list0->first) {
ret = list1->first;
} else {
ret = list0->first;
list0->last->next = list1->first;
}
init(list0);
init(list1);
return ret;
}
+{
+ if (!list1 || !list1->first)
Can also get rid of NULL checks, i.e. !list1
+ return list0;
+
+ if (!list0 || !list0->first)
+ return list1;
+
+ list0->last->next = list1->first;
+ list0->last = list1->last;
+ return list0;
+}
+
static inline void wq_list_add_tail(struct io_wq_work_node *node,
struct io_wq_work_list *list)
{
--
Pavel Begunkov