
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICN2MB -------------------------------- This reverts commit 0f5fea890fd315f60e80749436a90f9f7e5ce503. This commit reverts our custom-developed solution. This change is a preparatory step to align our codebase with the mainline, making it easier to backport the official mainline solution. Signed-off-by: Baokun Li <libaokun1@huawei.com> --- fs/ext4/ext4.h | 7 +++---- fs/ext4/mballoc.c | 20 +++++++++++--------- fs/ext4/super.c | 2 -- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index a31069001add..885fe1d9a8e9 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1179,10 +1179,6 @@ struct ext4_inode_info { __u32 i_csum_seed; kprojid_t i_projid; - - /* where last allocation was done - for stream allocation */ - ext4_group_t i_mb_last_group; - ext4_grpblk_t i_mb_last_start; }; /* @@ -1615,6 +1611,9 @@ struct ext4_sb_info { unsigned int s_mb_order2_reqs; unsigned int s_mb_group_prealloc; unsigned int s_max_dir_size_kb; + /* where last allocation was done - for stream allocation */ + unsigned long s_mb_last_group; + unsigned long s_mb_last_start; unsigned int s_mb_prefetch; unsigned int s_mb_prefetch_limit; unsigned int s_mb_best_avail_max_trim_order; diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index d7a1fcbdcff6..c33d40acdf16 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2139,6 +2139,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex) static void ext4_mb_use_best_found(struct ext4_allocation_context *ac, struct ext4_buddy *e4b) { + struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); int ret; BUG_ON(ac->ac_b_ex.fe_group != e4b->bd_group); @@ -2169,8 +2170,10 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac, get_page(ac->ac_buddy_page); /* store last allocated for subsequent stream allocation */ if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { - EXT4_I(ac->ac_inode)->i_mb_last_group = ac->ac_f_ex.fe_group; - EXT4_I(ac->ac_inode)->i_mb_last_start = ac->ac_f_ex.fe_start; + spin_lock(&sbi->s_md_lock); + sbi->s_mb_last_group = ac->ac_f_ex.fe_group; + sbi->s_mb_last_start = ac->ac_f_ex.fe_start; + spin_unlock(&sbi->s_md_lock); } /* * As we've just preallocated more space than @@ -2842,14 +2845,13 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) MB_NUM_ORDERS(sb)); } - /* if stream allocation is enabled, use last goal */ + /* if stream allocation is enabled, use global goal */ if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { - struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); - - if (ei->i_mb_last_group || ei->i_mb_last_start) { - ac->ac_g_ex.fe_group = ei->i_mb_last_group; - ac->ac_g_ex.fe_start = ei->i_mb_last_start; - } + /* TBD: may be hot point */ + spin_lock(&sbi->s_md_lock); + ac->ac_g_ex.fe_group = sbi->s_mb_last_group; + ac->ac_g_ex.fe_start = sbi->s_mb_last_start; + spin_unlock(&sbi->s_md_lock); } /* diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f7a301116d59..c45dfcf9ac62 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1517,8 +1517,6 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) INIT_WORK(&ei->i_iomap_ioend_work, ext4_iomap_end_io); ext4_fc_init_inode(&ei->vfs_inode); mutex_init(&ei->i_fc_lock); - ei->i_mb_last_group = 0; - ei->i_mb_last_start = 0; return &ei->vfs_inode; } -- 2.46.1