Skip to contentSkip to conversation

btrfs: send: use list_move_tail instead of list_del/list_add_tail

PATCH Superseded Baokun Li 3 participants 4 messages Jun 8, 2021 – Jun 11, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Baokun Li

author
#0 lore raw

PATCH 1/1 btrfs: send: use list_move_tail instead of list_del/list_add_tail

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

---
 fs/btrfs/send.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/send.c +1 -2
index bd69db72acc5..a0e51b2416a1 100644
@@ -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);
 }
 
 /*
#1 lore raw
Quoted 13 lines · Baokun Li

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

---
  fs/btrfs/send.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/send.c +0 -0
index bd69db72acc5..a0e51b2416a1 100644

fs/btrfs/send.c static struct name_cache_entry *name_cache_search(struct send_ctx *sctx, · line 2087

Quoted 7 lines
fs/btrfs/send.c +1 -2
@@ -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

Quoted 2 lines
fs/btrfs/send.c +0 -0
  /*
 
#2 lore raw
Quoted 9 lines · Anand Jain
Quoted 8 lines · Baokun Li

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

---
  fs/btrfs/send.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 16 lines

fs/btrfs/send.c static struct name_cache_entry *name_cache_search(struct send_ctx *sctx, · line 2087

Quoted 12 lines
fs/btrfs/send.c +1 -2
index bd69db72acc5..a0e51b2416a1 100644
@@ -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.

#3 lore raw

Thank you for your advice.

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

Best Regards

Quoted 28 lines · David Sterba
Quoted 9 lines · Anand Jain
Quoted 8 lines · Baokun Li

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

---
   fs/btrfs/send.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 15 lines

fs/btrfs/send.c static struct name_cache_entry *name_cache_search(struct send_ctx *sctx, · line 2087

Quoted 12 lines
fs/btrfs/send.c +1 -2
index bd69db72acc5..a0e51b2416a1 100644
@@ -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.
.