Skip to content

Commit

Permalink
btrfs: send: use list_move_tail instead of list_del/list_add_tail
Browse files Browse the repository at this point in the history
Use list_move_tail() instead of list_del() + list_add_tail() as it's
doing the same thing and allows further cleanups.  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>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Baokun Li authored and David Sterba committed Jun 22, 2021
1 parent b05fbcc commit bb93000
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
@@ -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,13 @@ 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);

0 comments on commit bb93000

Please sign in to comment.