| Message ID | 20251025032221.2905818-8-libaokun@huaweicloud.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series | ext4: enable block size larger than page size | expand |
On Sat 25-10-25 11:22:03, libaokun@huaweicloud.com wrote: > From: Baokun Li <libaokun1@huawei.com> > > ext4_calculate_overhead() used a single page for its bitmap buffer, which > worked fine when PAGE_SIZE >= block size. However, with block size greater > than page size (BS > PS) support, the bitmap can exceed a single page. > > To address this, we now use __get_free_pages() to allocate multiple pages, > sized to the block size, to properly support BS > PS. > > Signed-off-by: Baokun Li <libaokun1@huawei.com> > Reviewed-by: Zhang Yi <yi.zhang@huawei.com> One comment below: > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index d353e25a5b92..7338c708ea1d 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -4182,7 +4182,8 @@ int ext4_calculate_overhead(struct super_block *sb) > unsigned int j_blocks, j_inum = le32_to_cpu(es->s_journal_inum); > ext4_group_t i, ngroups = ext4_get_groups_count(sb); > ext4_fsblk_t overhead = 0; > - char *buf = (char *) get_zeroed_page(GFP_NOFS); > + gfp_t gfp = GFP_NOFS | __GFP_ZERO; > + char *buf = (char *)__get_free_pages(gfp, sbi->s_min_folio_order); I think this should be using kvmalloc(). There's no reason to require physically contiguous pages for this... Honza
On 2025-11-03 16:14, Jan Kara wrote: > On Sat 25-10-25 11:22:03, libaokun@huaweicloud.com wrote: >> From: Baokun Li <libaokun1@huawei.com> >> >> ext4_calculate_overhead() used a single page for its bitmap buffer, which >> worked fine when PAGE_SIZE >= block size. However, with block size greater >> than page size (BS > PS) support, the bitmap can exceed a single page. >> >> To address this, we now use __get_free_pages() to allocate multiple pages, >> sized to the block size, to properly support BS > PS. >> >> Signed-off-by: Baokun Li <libaokun1@huawei.com> >> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> > One comment below: > >> diff --git a/fs/ext4/super.c b/fs/ext4/super.c >> index d353e25a5b92..7338c708ea1d 100644 >> --- a/fs/ext4/super.c >> +++ b/fs/ext4/super.c >> @@ -4182,7 +4182,8 @@ int ext4_calculate_overhead(struct super_block *sb) >> unsigned int j_blocks, j_inum = le32_to_cpu(es->s_journal_inum); >> ext4_group_t i, ngroups = ext4_get_groups_count(sb); >> ext4_fsblk_t overhead = 0; >> - char *buf = (char *) get_zeroed_page(GFP_NOFS); >> + gfp_t gfp = GFP_NOFS | __GFP_ZERO; >> + char *buf = (char *)__get_free_pages(gfp, sbi->s_min_folio_order); > I think this should be using kvmalloc(). There's no reason to require > physically contiguous pages for this... > > Honza Makes sense, I will use kvmalloc() in the next version. Thanks, Baokun
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index d353e25a5b92..7338c708ea1d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4182,7 +4182,8 @@ int ext4_calculate_overhead(struct super_block *sb) unsigned int j_blocks, j_inum = le32_to_cpu(es->s_journal_inum); ext4_group_t i, ngroups = ext4_get_groups_count(sb); ext4_fsblk_t overhead = 0; - char *buf = (char *) get_zeroed_page(GFP_NOFS); + gfp_t gfp = GFP_NOFS | __GFP_ZERO; + char *buf = (char *)__get_free_pages(gfp, sbi->s_min_folio_order); if (!buf) return -ENOMEM; @@ -4207,7 +4208,7 @@ int ext4_calculate_overhead(struct super_block *sb) blks = count_overhead(sb, i, buf); overhead += blks; if (blks) - memset(buf, 0, PAGE_SIZE); + memset(buf, 0, sb->s_blocksize); cond_resched(); } @@ -4230,7 +4231,7 @@ int ext4_calculate_overhead(struct super_block *sb) } sbi->s_overhead = overhead; smp_wmb(); - free_page((unsigned long) buf); + free_pages((unsigned long)buf, sbi->s_min_folio_order); return 0; }