Skip to content

Commit 84af994

Browse files
ruanjinjie-engkdave
authored andcommitted
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: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2576143 commit 84af994

6 files changed

Lines changed: 13 additions & 33 deletions

File tree

fs/btrfs/disk-io.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,9 +4554,7 @@ static void btrfs_destroy_ordered_extents(struct btrfs_root *root)
45544554
static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info)
45554555
{
45564556
struct btrfs_root *root;
4557-
struct list_head splice;
4558-
4559-
INIT_LIST_HEAD(&splice);
4557+
LIST_HEAD(splice);
45604558

45614559
spin_lock(&fs_info->ordered_root_lock);
45624560
list_splice_init(&fs_info->ordered_roots, &splice);
@@ -4662,9 +4660,7 @@ static void btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
46624660
static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
46634661
{
46644662
struct btrfs_inode *btrfs_inode;
4665-
struct list_head splice;
4666-
4667-
INIT_LIST_HEAD(&splice);
4663+
LIST_HEAD(splice);
46684664

46694665
spin_lock(&root->delalloc_lock);
46704666
list_splice_init(&root->delalloc_inodes, &splice);
@@ -4697,9 +4693,7 @@ static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
46974693
static void btrfs_destroy_all_delalloc_inodes(struct btrfs_fs_info *fs_info)
46984694
{
46994695
struct btrfs_root *root;
4700-
struct list_head splice;
4701-
4702-
INIT_LIST_HEAD(&splice);
4696+
LIST_HEAD(splice);
47034697

47044698
spin_lock(&fs_info->delalloc_root_lock);
47054699
list_splice_init(&fs_info->delalloc_roots, &splice);

fs/btrfs/file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ static long btrfs_fallocate(struct file *file, int mode,
30183018
struct extent_changeset *data_reserved = NULL;
30193019
struct falloc_range *range;
30203020
struct falloc_range *tmp;
3021-
struct list_head reserve_list;
3021+
LIST_HEAD(reserve_list);
30223022
u64 cur_offset;
30233023
u64 last_byte;
30243024
u64 alloc_start;
@@ -3110,7 +3110,6 @@ static long btrfs_fallocate(struct file *file, int mode,
31103110
btrfs_assert_inode_range_clean(BTRFS_I(inode), alloc_start, locked_end);
31113111

31123112
/* First, check if we exceed the qgroup limit */
3113-
INIT_LIST_HEAD(&reserve_list);
31143113
while (cur_offset < alloc_end) {
31153114
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset,
31163115
alloc_end - cur_offset);

fs/btrfs/inode.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5861,8 +5861,8 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
58615861
struct btrfs_key found_key;
58625862
struct btrfs_path *path;
58635863
void *addr;
5864-
struct list_head ins_list;
5865-
struct list_head del_list;
5864+
LIST_HEAD(ins_list);
5865+
LIST_HEAD(del_list);
58665866
int ret;
58675867
char *name_ptr;
58685868
int name_len;
@@ -5881,8 +5881,6 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
58815881
addr = private->filldir_buf;
58825882
path->reada = READA_FORWARD;
58835883

5884-
INIT_LIST_HEAD(&ins_list);
5885-
INIT_LIST_HEAD(&del_list);
58865884
put = btrfs_readdir_get_delayed_items(inode, private->last_index,
58875885
&ins_list, &del_list);
58885886

@@ -9244,14 +9242,11 @@ static int start_delalloc_inodes(struct btrfs_root *root,
92449242
struct btrfs_inode *binode;
92459243
struct inode *inode;
92469244
struct btrfs_delalloc_work *work, *next;
9247-
struct list_head works;
9248-
struct list_head splice;
9245+
LIST_HEAD(works);
9246+
LIST_HEAD(splice);
92499247
int ret = 0;
92509248
bool full_flush = wbc->nr_to_write == LONG_MAX;
92519249

9252-
INIT_LIST_HEAD(&works);
9253-
INIT_LIST_HEAD(&splice);
9254-
92559250
mutex_lock(&root->delalloc_mutex);
92569251
spin_lock(&root->delalloc_lock);
92579252
list_splice_init(&root->delalloc_inodes, &splice);
@@ -9339,14 +9334,12 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
93399334
.range_end = LLONG_MAX,
93409335
};
93419336
struct btrfs_root *root;
9342-
struct list_head splice;
9337+
LIST_HEAD(splice);
93439338
int ret;
93449339

93459340
if (BTRFS_FS_ERROR(fs_info))
93469341
return -EROFS;
93479342

9348-
INIT_LIST_HEAD(&splice);
9349-
93509343
mutex_lock(&fs_info->delalloc_root_mutex);
93519344
spin_lock(&fs_info->delalloc_root_lock);
93529345
list_splice_init(&fs_info->delalloc_roots, &splice);

fs/btrfs/ordered-data.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,9 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
740740
const u64 range_start, const u64 range_len)
741741
{
742742
struct btrfs_root *root;
743-
struct list_head splice;
743+
LIST_HEAD(splice);
744744
u64 done;
745745

746-
INIT_LIST_HEAD(&splice);
747-
748746
mutex_lock(&fs_info->ordered_operations_mutex);
749747
spin_lock(&fs_info->ordered_root_lock);
750748
list_splice_init(&fs_info->ordered_roots, &splice);

fs/btrfs/send.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,15 +3685,14 @@ static void tail_append_pending_moves(struct send_ctx *sctx,
36853685
static int apply_children_dir_moves(struct send_ctx *sctx)
36863686
{
36873687
struct pending_dir_move *pm;
3688-
struct list_head stack;
3688+
LIST_HEAD(stack);
36893689
u64 parent_ino = sctx->cur_ino;
36903690
int ret = 0;
36913691

36923692
pm = get_pending_dir_moves(sctx, parent_ino);
36933693
if (!pm)
36943694
return 0;
36953695

3696-
INIT_LIST_HEAD(&stack);
36973696
tail_append_pending_moves(sctx, pm, &stack);
36983697

36993698
while (!list_empty(&stack)) {
@@ -4165,7 +4164,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
41654164
int ret = 0;
41664165
struct recorded_ref *cur;
41674166
struct recorded_ref *cur2;
4168-
struct list_head check_dirs;
4167+
LIST_HEAD(check_dirs);
41694168
struct fs_path *valid_path = NULL;
41704169
u64 ow_inode = 0;
41714170
u64 ow_gen;
@@ -4184,7 +4183,6 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
41844183
* which is always '..'
41854184
*/
41864185
BUG_ON(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID);
4187-
INIT_LIST_HEAD(&check_dirs);
41884186

41894187
valid_path = fs_path_alloc();
41904188
if (!valid_path) {

fs/btrfs/tree-log.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4841,13 +4841,11 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
48414841
struct btrfs_ordered_extent *ordered;
48424842
struct btrfs_ordered_extent *tmp;
48434843
struct extent_map *em, *n;
4844-
struct list_head extents;
4844+
LIST_HEAD(extents);
48454845
struct extent_map_tree *tree = &inode->extent_tree;
48464846
int ret = 0;
48474847
int num = 0;
48484848

4849-
INIT_LIST_HEAD(&extents);
4850-
48514849
write_lock(&tree->lock);
48524850

48534851
list_for_each_entry_safe(em, n, &tree->modified_extents, list) {

0 commit comments

Comments
 (0)