Commit 84af994b authored by Ruan Jinjie's avatar Ruan Jinjie Committed by David Sterba

btrfs: use LIST_HEAD() to initialize the list_head

Use LIST_HEAD() to initialize the list_head instead of open-coding it.
Signed-off-by: default avatarRuan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 25761430
...@@ -4554,9 +4554,7 @@ static void btrfs_destroy_ordered_extents(struct btrfs_root *root) ...@@ -4554,9 +4554,7 @@ static void btrfs_destroy_ordered_extents(struct btrfs_root *root)
static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info) static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info)
{ {
struct btrfs_root *root; struct btrfs_root *root;
struct list_head splice; LIST_HEAD(splice);
INIT_LIST_HEAD(&splice);
spin_lock(&fs_info->ordered_root_lock); spin_lock(&fs_info->ordered_root_lock);
list_splice_init(&fs_info->ordered_roots, &splice); list_splice_init(&fs_info->ordered_roots, &splice);
...@@ -4662,9 +4660,7 @@ static void btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, ...@@ -4662,9 +4660,7 @@ static void btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
{ {
struct btrfs_inode *btrfs_inode; struct btrfs_inode *btrfs_inode;
struct list_head splice; LIST_HEAD(splice);
INIT_LIST_HEAD(&splice);
spin_lock(&root->delalloc_lock); spin_lock(&root->delalloc_lock);
list_splice_init(&root->delalloc_inodes, &splice); list_splice_init(&root->delalloc_inodes, &splice);
...@@ -4697,9 +4693,7 @@ static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) ...@@ -4697,9 +4693,7 @@ static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
static void btrfs_destroy_all_delalloc_inodes(struct btrfs_fs_info *fs_info) static void btrfs_destroy_all_delalloc_inodes(struct btrfs_fs_info *fs_info)
{ {
struct btrfs_root *root; struct btrfs_root *root;
struct list_head splice; LIST_HEAD(splice);
INIT_LIST_HEAD(&splice);
spin_lock(&fs_info->delalloc_root_lock); spin_lock(&fs_info->delalloc_root_lock);
list_splice_init(&fs_info->delalloc_roots, &splice); list_splice_init(&fs_info->delalloc_roots, &splice);
......
...@@ -3018,7 +3018,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3018,7 +3018,7 @@ static long btrfs_fallocate(struct file *file, int mode,
struct extent_changeset *data_reserved = NULL; struct extent_changeset *data_reserved = NULL;
struct falloc_range *range; struct falloc_range *range;
struct falloc_range *tmp; struct falloc_range *tmp;
struct list_head reserve_list; LIST_HEAD(reserve_list);
u64 cur_offset; u64 cur_offset;
u64 last_byte; u64 last_byte;
u64 alloc_start; u64 alloc_start;
...@@ -3110,7 +3110,6 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3110,7 +3110,6 @@ static long btrfs_fallocate(struct file *file, int mode,
btrfs_assert_inode_range_clean(BTRFS_I(inode), alloc_start, locked_end); btrfs_assert_inode_range_clean(BTRFS_I(inode), alloc_start, locked_end);
/* First, check if we exceed the qgroup limit */ /* First, check if we exceed the qgroup limit */
INIT_LIST_HEAD(&reserve_list);
while (cur_offset < alloc_end) { while (cur_offset < alloc_end) {
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset, em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset,
alloc_end - cur_offset); alloc_end - cur_offset);
......
...@@ -5861,8 +5861,8 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx) ...@@ -5861,8 +5861,8 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
struct btrfs_key found_key; struct btrfs_key found_key;
struct btrfs_path *path; struct btrfs_path *path;
void *addr; void *addr;
struct list_head ins_list; LIST_HEAD(ins_list);
struct list_head del_list; LIST_HEAD(del_list);
int ret; int ret;
char *name_ptr; char *name_ptr;
int name_len; int name_len;
...@@ -5881,8 +5881,6 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx) ...@@ -5881,8 +5881,6 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
addr = private->filldir_buf; addr = private->filldir_buf;
path->reada = READA_FORWARD; path->reada = READA_FORWARD;
INIT_LIST_HEAD(&ins_list);
INIT_LIST_HEAD(&del_list);
put = btrfs_readdir_get_delayed_items(inode, private->last_index, put = btrfs_readdir_get_delayed_items(inode, private->last_index,
&ins_list, &del_list); &ins_list, &del_list);
...@@ -9244,14 +9242,11 @@ static int start_delalloc_inodes(struct btrfs_root *root, ...@@ -9244,14 +9242,11 @@ static int start_delalloc_inodes(struct btrfs_root *root,
struct btrfs_inode *binode; struct btrfs_inode *binode;
struct inode *inode; struct inode *inode;
struct btrfs_delalloc_work *work, *next; struct btrfs_delalloc_work *work, *next;
struct list_head works; LIST_HEAD(works);
struct list_head splice; LIST_HEAD(splice);
int ret = 0; int ret = 0;
bool full_flush = wbc->nr_to_write == LONG_MAX; bool full_flush = wbc->nr_to_write == LONG_MAX;
INIT_LIST_HEAD(&works);
INIT_LIST_HEAD(&splice);
mutex_lock(&root->delalloc_mutex); mutex_lock(&root->delalloc_mutex);
spin_lock(&root->delalloc_lock); spin_lock(&root->delalloc_lock);
list_splice_init(&root->delalloc_inodes, &splice); list_splice_init(&root->delalloc_inodes, &splice);
...@@ -9339,14 +9334,12 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr, ...@@ -9339,14 +9334,12 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
.range_end = LLONG_MAX, .range_end = LLONG_MAX,
}; };
struct btrfs_root *root; struct btrfs_root *root;
struct list_head splice; LIST_HEAD(splice);
int ret; int ret;
if (BTRFS_FS_ERROR(fs_info)) if (BTRFS_FS_ERROR(fs_info))
return -EROFS; return -EROFS;
INIT_LIST_HEAD(&splice);
mutex_lock(&fs_info->delalloc_root_mutex); mutex_lock(&fs_info->delalloc_root_mutex);
spin_lock(&fs_info->delalloc_root_lock); spin_lock(&fs_info->delalloc_root_lock);
list_splice_init(&fs_info->delalloc_roots, &splice); list_splice_init(&fs_info->delalloc_roots, &splice);
......
...@@ -740,11 +740,9 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr, ...@@ -740,11 +740,9 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
const u64 range_start, const u64 range_len) const u64 range_start, const u64 range_len)
{ {
struct btrfs_root *root; struct btrfs_root *root;
struct list_head splice; LIST_HEAD(splice);
u64 done; u64 done;
INIT_LIST_HEAD(&splice);
mutex_lock(&fs_info->ordered_operations_mutex); mutex_lock(&fs_info->ordered_operations_mutex);
spin_lock(&fs_info->ordered_root_lock); spin_lock(&fs_info->ordered_root_lock);
list_splice_init(&fs_info->ordered_roots, &splice); list_splice_init(&fs_info->ordered_roots, &splice);
......
...@@ -3685,7 +3685,7 @@ static void tail_append_pending_moves(struct send_ctx *sctx, ...@@ -3685,7 +3685,7 @@ static void tail_append_pending_moves(struct send_ctx *sctx,
static int apply_children_dir_moves(struct send_ctx *sctx) static int apply_children_dir_moves(struct send_ctx *sctx)
{ {
struct pending_dir_move *pm; struct pending_dir_move *pm;
struct list_head stack; LIST_HEAD(stack);
u64 parent_ino = sctx->cur_ino; u64 parent_ino = sctx->cur_ino;
int ret = 0; int ret = 0;
...@@ -3693,7 +3693,6 @@ static int apply_children_dir_moves(struct send_ctx *sctx) ...@@ -3693,7 +3693,6 @@ static int apply_children_dir_moves(struct send_ctx *sctx)
if (!pm) if (!pm)
return 0; return 0;
INIT_LIST_HEAD(&stack);
tail_append_pending_moves(sctx, pm, &stack); tail_append_pending_moves(sctx, pm, &stack);
while (!list_empty(&stack)) { while (!list_empty(&stack)) {
...@@ -4165,7 +4164,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) ...@@ -4165,7 +4164,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
int ret = 0; int ret = 0;
struct recorded_ref *cur; struct recorded_ref *cur;
struct recorded_ref *cur2; struct recorded_ref *cur2;
struct list_head check_dirs; LIST_HEAD(check_dirs);
struct fs_path *valid_path = NULL; struct fs_path *valid_path = NULL;
u64 ow_inode = 0; u64 ow_inode = 0;
u64 ow_gen; u64 ow_gen;
...@@ -4184,7 +4183,6 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) ...@@ -4184,7 +4183,6 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
* which is always '..' * which is always '..'
*/ */
BUG_ON(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID); BUG_ON(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID);
INIT_LIST_HEAD(&check_dirs);
valid_path = fs_path_alloc(); valid_path = fs_path_alloc();
if (!valid_path) { if (!valid_path) {
......
...@@ -4841,13 +4841,11 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, ...@@ -4841,13 +4841,11 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
struct btrfs_ordered_extent *tmp; struct btrfs_ordered_extent *tmp;
struct extent_map *em, *n; struct extent_map *em, *n;
struct list_head extents; LIST_HEAD(extents);
struct extent_map_tree *tree = &inode->extent_tree; struct extent_map_tree *tree = &inode->extent_tree;
int ret = 0; int ret = 0;
int num = 0; int num = 0;
INIT_LIST_HEAD(&extents);
write_lock(&tree->lock); write_lock(&tree->lock);
list_for_each_entry_safe(em, n, &tree->modified_extents, list) { list_for_each_entry_safe(em, n, &tree->modified_extents, list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment