summaryrefslogtreecommitdiff
path: root/fs/io-wq.h
diff options
context:
space:
mode:
authorHao Xu <haoxu@linux.alibaba.com>2021-12-07 17:39:47 +0800
committerJens Axboe <axboe@kernel.dk>2021-12-07 15:01:57 -0700
commit24115c4e95e137b73954bbbd94354889552a4b08 (patch)
tree4d95c9b1c0890a1f9e11258240c3d917465f9c24 /fs/io-wq.h
parenta90c8bf6590676035336ae98cc51bce1aeb96c33 (diff)
downloadlwn-24115c4e95e137b73954bbbd94354889552a4b08.tar.gz
lwn-24115c4e95e137b73954bbbd94354889552a4b08.zip
io-wq: add helper to merge two wq_lists
add a helper to merge two wq_lists, it will be useful in the next patches. Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Hao Xu <haoxu@linux.alibaba.com> Link: https://lore.kernel.org/r/20211207093951.247840-2-haoxu@linux.alibaba.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io-wq.h')
-rw-r--r--fs/io-wq.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 41bf37674a49..3709b7c5ec98 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -52,6 +52,28 @@ 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 the first node after mergence.
+ */
+static inline struct io_wq_work_node *wq_list_merge(struct io_wq_work_list *list0,
+ struct io_wq_work_list *list1)
+{
+ struct io_wq_work_node *ret;
+
+ if (!list0->first) {
+ ret = list1->first;
+ } else {
+ ret = list0->first;
+ list0->last->next = list1->first;
+ }
+ INIT_WQ_LIST(list0);
+ INIT_WQ_LIST(list1);
+ return ret;
+}
+
static inline void wq_list_add_tail(struct io_wq_work_node *node,
struct io_wq_work_list *list)
{