2021-06-08 03:05:20

by Baokun Li

[permalink] [raw]
Subject: [PATCH -next] btrfs: send: use list_move_tail instead of list_del/list_add_tail

Using list_move_tail() instead of list_del() + list_add_tail().

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Baokun Li <[email protected]>
---
fs/btrfs/send.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index bd69db72acc5..a0e51b2416a1 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2083,8 +2083,7 @@ static struct name_cache_entry *name_cache_search(struct send_ctx *sctx,
*/
static void name_cache_used(struct send_ctx *sctx, struct name_cache_entry *nce)
{
- list_del(&nce->list);
- list_add_tail(&nce->list, &sctx->name_cache_list);
+ list_move_tail(&nce->list, &sctx->name_cache_list);
}

/*


2021-06-08 05:21:04

by Anand Jain

[permalink] [raw]
Subject: Re: [PATCH -next] btrfs: send: use list_move_tail instead of list_del/list_add_tail

On 8/6/21 11:12 am, Baokun Li wrote:
> Using list_move_tail() instead of list_del() + list_add_tail().
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Baokun Li <[email protected]>
> ---
> fs/btrfs/send.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index bd69db72acc5..a0e51b2416a1 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2083,8 +2083,7 @@ static struct name_cache_entry *name_cache_search(struct send_ctx *sctx,
> */
> static void name_cache_used(struct send_ctx *sctx, struct name_cache_entry *nce)
> {
> - list_del(&nce->list);
> - list_add_tail(&nce->list, &sctx->name_cache_list);
> + list_move_tail(&nce->list, &sctx->name_cache_list);
> }


Looks good.
You can consider open-code name_cache_used() as there is only one user.

Thanks, Anand

> /*
>

2021-06-08 14:18:50

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH -next] btrfs: send: use list_move_tail instead of list_del/list_add_tail

On Tue, Jun 08, 2021 at 01:16:21PM +0800, Anand Jain wrote:
> On 8/6/21 11:12 am, Baokun Li wrote:
> > Using list_move_tail() instead of list_del() + list_add_tail().
> >
> > Reported-by: Hulk Robot <[email protected]>
> > Signed-off-by: Baokun Li <[email protected]>
> > ---
> > fs/btrfs/send.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> > index bd69db72acc5..a0e51b2416a1 100644
> > --- a/fs/btrfs/send.c
> > +++ b/fs/btrfs/send.c
> > @@ -2083,8 +2083,7 @@ static struct name_cache_entry *name_cache_search(struct send_ctx *sctx,
> > */
> > static void name_cache_used(struct send_ctx *sctx, struct name_cache_entry *nce)
> > {
> > - list_del(&nce->list);
> > - list_add_tail(&nce->list, &sctx->name_cache_list);
> > + list_move_tail(&nce->list, &sctx->name_cache_list);
> > }
>
>
> Looks good.
> You can consider open-code name_cache_used() as there is only one user.

Yeah sounds like a good idea, with part of the function comment next to
the list_move_tail.

2021-06-11 06:09:47

by Baokun Li

[permalink] [raw]
Subject: Re: [PATCH -next] btrfs: send: use list_move_tail instead of list_del/list_add_tail

Thank you for your advice.

I'm about to send a patch v2 with the changes suggested by you.

Best Regards


?? 2021/6/8 22:12, David Sterba ะด??:
> On Tue, Jun 08, 2021 at 01:16:21PM +0800, Anand Jain wrote:
>> On 8/6/21 11:12 am, Baokun Li wrote:
>>> Using list_move_tail() instead of list_del() + list_add_tail().
>>>
>>> Reported-by: Hulk Robot <[email protected]>
>>> Signed-off-by: Baokun Li <[email protected]>
>>> ---
>>> fs/btrfs/send.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
>>> index bd69db72acc5..a0e51b2416a1 100644
>>> --- a/fs/btrfs/send.c
>>> +++ b/fs/btrfs/send.c
>>> @@ -2083,8 +2083,7 @@ static struct name_cache_entry *name_cache_search(struct send_ctx *sctx,
>>> */
>>> static void name_cache_used(struct send_ctx *sctx, struct name_cache_entry *nce)
>>> {
>>> - list_del(&nce->list);
>>> - list_add_tail(&nce->list, &sctx->name_cache_list);
>>> + list_move_tail(&nce->list, &sctx->name_cache_list);
>>> }
>>
>> Looks good.
>> You can consider open-code name_cache_used() as there is only one user.
> Yeah sounds like a good idea, with part of the function comment next to
> the list_move_tail.
> .