Skip to content

Commit 6a28b5c

Browse files
LiBaokun96tytso
authored andcommitted
ext4: support large block size in ext4_calculate_overhead()
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 kvmalloc() to allocate memory of the filesystem block size, to properly support BS > PS. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Message-ID: <20251121090654.631996-8-libaokun@huaweicloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 8611e60 commit 6a28b5c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

fs/ext4/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,7 +4191,7 @@ int ext4_calculate_overhead(struct super_block *sb)
41914191
unsigned int j_blocks, j_inum = le32_to_cpu(es->s_journal_inum);
41924192
ext4_group_t i, ngroups = ext4_get_groups_count(sb);
41934193
ext4_fsblk_t overhead = 0;
4194-
char *buf = (char *) get_zeroed_page(GFP_NOFS);
4194+
char *buf = kvmalloc(sb->s_blocksize, GFP_NOFS | __GFP_ZERO);
41954195

41964196
if (!buf)
41974197
return -ENOMEM;
@@ -4216,7 +4216,7 @@ int ext4_calculate_overhead(struct super_block *sb)
42164216
blks = count_overhead(sb, i, buf);
42174217
overhead += blks;
42184218
if (blks)
4219-
memset(buf, 0, PAGE_SIZE);
4219+
memset(buf, 0, sb->s_blocksize);
42204220
cond_resched();
42214221
}
42224222

@@ -4239,7 +4239,7 @@ int ext4_calculate_overhead(struct super_block *sb)
42394239
}
42404240
sbi->s_overhead = overhead;
42414241
smp_wmb();
4242-
free_page((unsigned long) buf);
4242+
kvfree(buf);
42434243
return 0;
42444244
}
42454245

0 commit comments

Comments
 (0)