Skip to content

Commit f2fec3e

Browse files
gouhao2025tytso
authored andcommitted
ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)', 'pnum' and 'block' are equal in this case. Signed-off-by: Gou Hao <gouhao@uniontech.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20231024035215.29474-1-gouhao@uniontech.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 665d3e0 commit f2fec3e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

fs/ext4/mballoc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,8 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
14561456
return 0;
14571457
}
14581458

1459-
block++;
1460-
pnum = block / blocks_per_page;
1461-
page = find_or_create_page(inode->i_mapping, pnum, gfp);
1459+
/* blocks_per_page == 1, hence we need another page for the buddy */
1460+
page = find_or_create_page(inode->i_mapping, block + 1, gfp);
14621461
if (!page)
14631462
return -ENOMEM;
14641463
BUG_ON(page->mapping != inode->i_mapping);

0 commit comments

Comments
 (0)