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

Hao Xu
2021-09-27T10:17:25Z

在 2021/9/27 下午2:17, Hao Xu 写道:
> 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;
> +}
This needs some tweak, will send v2 soon.
> +
> static inline void wq_list_add_tail(struct io_wq_work_node *node,
> struct io_wq_work_list *list)
> {
>