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

Pavel Begunkov
2021-09-29T11:24:34Z

On 9/28/21 5:48 PM, Hao Xu wrote:
> 在 2021/9/28 下午7:10, Pavel Begunkov 写道:
>> On 9/27/21 7:17 AM, 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@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;
>>
>> It assigns a local var and returns, the assignment will be compiled
>> out, something is wrong
> True, I've corrected it in v2.

Was looking at a wrong version then, need to look through v2

>>
>>> +        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)
>>>   {
>>>
>>
>

--
Pavel Begunkov