linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next v2] btrfs: send: use list_move_tail instead of list_del/list_add_tail in send.c
@ 2021-06-11  6:51 Baokun Li
  2021-06-11 12:37 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Baokun Li @ 2021-06-11  6:51 UTC (permalink / raw)
  To: clm, josef, dsterba, anand.jain, linux-btrfs, linux-kernel
  Cc: weiyongjun1, yuehaibing, yangjihong1, yukuai3, libaokun1, Hulk Robot

Using list_move_tail() instead of list_del() + list_add_tail() in send.c.
And open-code name_cache_used() as there is only one user.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
V1->V2:
        open-code name_cache_used()

 fs/btrfs/send.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index bd69db72acc5..418ada6139fd 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2077,16 +2077,6 @@ static struct name_cache_entry *name_cache_search(struct send_ctx *sctx,
 	return NULL;
 }
 
-/*
- * Removes the entry from the list and adds it back to the end. This marks the
- * entry as recently used so that name_cache_clean_unused does not remove it.
- */
-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);
-}
-
 /*
  * Remove some entries from the beginning of name_cache_list.
  */
@@ -2147,7 +2137,14 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx,
 			kfree(nce);
 			nce = NULL;
 		} else {
-			name_cache_used(sctx, nce);
+
+			/*
+			 * Removes the entry from the list and adds it back to the end.
+			 * This marks the entry as recently used so that
+			 * name_cache_clean_unused does not remove it.
+			 */
+			list_move_tail(&nce->list, &sctx->name_cache_list);
+
 			*parent_ino = nce->parent_ino;
 			*parent_gen = nce->parent_gen;
 			ret = fs_path_add(dest, nce->name, nce->name_len);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] btrfs: send: use list_move_tail instead of list_del/list_add_tail in send.c
  2021-06-11  6:51 [PATCH -next v2] btrfs: send: use list_move_tail instead of list_del/list_add_tail in send.c Baokun Li
@ 2021-06-11 12:37 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2021-06-11 12:37 UTC (permalink / raw)
  To: Baokun Li
  Cc: clm, josef, dsterba, anand.jain, linux-btrfs, linux-kernel,
	weiyongjun1, yuehaibing, yangjihong1, yukuai3, Hulk Robot

On Fri, Jun 11, 2021 at 02:51:15PM +0800, Baokun Li wrote:
> Using list_move_tail() instead of list_del() + list_add_tail() in send.c.
> And open-code name_cache_used() as there is only one user.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> ---
> V1->V2:
>         open-code name_cache_used()

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-11 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11  6:51 [PATCH -next v2] btrfs: send: use list_move_tail instead of list_del/list_add_tail in send.c Baokun Li
2021-06-11 12:37 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).