Skip to content

Commit 0f6bc57

Browse files
Ruan Jinjietytso
authored andcommitted
ext4: use LIST_HEAD() to initialize the list_head in mballoc.c
Use LIST_HEAD() to initialize the list_head instead of open-coding it. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230812071839.3481909-1-ruanjinjie@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 03de20b commit 0f6bc57

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

fs/ext4/mballoc.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,11 +3504,10 @@ static void ext4_discard_work(struct work_struct *work)
35043504
struct super_block *sb = sbi->s_sb;
35053505
struct ext4_free_data *fd, *nfd;
35063506
struct ext4_buddy e4b;
3507-
struct list_head discard_list;
3507+
LIST_HEAD(discard_list);
35083508
ext4_group_t grp, load_grp;
35093509
int err = 0;
35103510

3511-
INIT_LIST_HEAD(&discard_list);
35123511
spin_lock(&sbi->s_md_lock);
35133512
list_splice_init(&sbi->s_discard_list, &discard_list);
35143513
spin_unlock(&sbi->s_md_lock);
@@ -3882,12 +3881,10 @@ void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid)
38823881
{
38833882
struct ext4_sb_info *sbi = EXT4_SB(sb);
38843883
struct ext4_free_data *entry, *tmp;
3885-
struct list_head freed_data_list;
3884+
LIST_HEAD(freed_data_list);
38863885
struct list_head *cut_pos = NULL;
38873886
bool wake;
38883887

3889-
INIT_LIST_HEAD(&freed_data_list);
3890-
38913888
spin_lock(&sbi->s_md_lock);
38923889
list_for_each_entry(entry, &sbi->s_freed_data_list, efd_list) {
38933890
if (entry->efd_tid != commit_tid)
@@ -5414,7 +5411,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
54145411
struct ext4_group_info *grp = ext4_get_group_info(sb, group);
54155412
struct buffer_head *bitmap_bh = NULL;
54165413
struct ext4_prealloc_space *pa, *tmp;
5417-
struct list_head list;
5414+
LIST_HEAD(list);
54185415
struct ext4_buddy e4b;
54195416
struct ext4_inode_info *ei;
54205417
int err;
@@ -5443,7 +5440,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
54435440
goto out_dbg;
54445441
}
54455442

5446-
INIT_LIST_HEAD(&list);
54475443
ext4_lock_group(sb, group);
54485444
list_for_each_entry_safe(pa, tmp,
54495445
&grp->bb_prealloc_list, pa_group_list) {
@@ -5524,7 +5520,7 @@ void ext4_discard_preallocations(struct inode *inode, unsigned int needed)
55245520
struct buffer_head *bitmap_bh = NULL;
55255521
struct ext4_prealloc_space *pa, *tmp;
55265522
ext4_group_t group = 0;
5527-
struct list_head list;
5523+
LIST_HEAD(list);
55285524
struct ext4_buddy e4b;
55295525
struct rb_node *iter;
55305526
int err;
@@ -5541,8 +5537,6 @@ void ext4_discard_preallocations(struct inode *inode, unsigned int needed)
55415537
trace_ext4_discard_preallocations(inode,
55425538
atomic_read(&ei->i_prealloc_active), needed);
55435539

5544-
INIT_LIST_HEAD(&list);
5545-
55465540
if (needed == 0)
55475541
needed = UINT_MAX;
55485542

@@ -5858,13 +5852,11 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
58585852
{
58595853
ext4_group_t group = 0;
58605854
struct ext4_buddy e4b;
5861-
struct list_head discard_list;
5855+
LIST_HEAD(discard_list);
58625856
struct ext4_prealloc_space *pa, *tmp;
58635857

58645858
mb_debug(sb, "discard locality group preallocation\n");
58655859

5866-
INIT_LIST_HEAD(&discard_list);
5867-
58685860
spin_lock(&lg->lg_prealloc_lock);
58695861
list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[order],
58705862
pa_node.lg_list,

0 commit comments

Comments
 (0)