ext4: remove unused parameter from ext4_mb_new_blocks_simple()
Two cleanups for ext4_mb_new_blocks_simple: Remove unused parameter handle of ext4_mb_new_blocks_simple. Move ext4_mb_new_blocks_simple definition before ext4_mb_new_blocks to remove unnecessary forward declaration of ext4_mb_new_blocks_simple. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Link: https://lore.kernel.org/r/20230603150327.3596033-10-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
11b6890be0
commit
ad78b5efe4
|
@ -5786,8 +5786,72 @@ out_dbg:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
|
||||
struct ext4_allocation_request *ar, int *errp);
|
||||
/*
|
||||
* Simple allocator for Ext4 fast commit replay path. It searches for blocks
|
||||
* linearly starting at the goal block and also excludes the blocks which
|
||||
* are going to be in use after fast commit replay.
|
||||
*/
|
||||
static ext4_fsblk_t
|
||||
ext4_mb_new_blocks_simple(struct ext4_allocation_request *ar, int *errp)
|
||||
{
|
||||
struct buffer_head *bitmap_bh;
|
||||
struct super_block *sb = ar->inode->i_sb;
|
||||
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||
ext4_group_t group, nr;
|
||||
ext4_grpblk_t blkoff;
|
||||
ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
|
||||
ext4_grpblk_t i = 0;
|
||||
ext4_fsblk_t goal, block;
|
||||
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
|
||||
|
||||
goal = ar->goal;
|
||||
if (goal < le32_to_cpu(es->s_first_data_block) ||
|
||||
goal >= ext4_blocks_count(es))
|
||||
goal = le32_to_cpu(es->s_first_data_block);
|
||||
|
||||
ar->len = 0;
|
||||
ext4_get_group_no_and_offset(sb, goal, &group, &blkoff);
|
||||
for (nr = ext4_get_groups_count(sb); nr > 0; nr--) {
|
||||
bitmap_bh = ext4_read_block_bitmap(sb, group);
|
||||
if (IS_ERR(bitmap_bh)) {
|
||||
*errp = PTR_ERR(bitmap_bh);
|
||||
pr_warn("Failed to read block bitmap\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
i = mb_find_next_zero_bit(bitmap_bh->b_data, max,
|
||||
blkoff);
|
||||
if (i >= max)
|
||||
break;
|
||||
if (ext4_fc_replay_check_excluded(sb,
|
||||
ext4_group_first_block_no(sb, group) +
|
||||
EXT4_C2B(sbi, i))) {
|
||||
blkoff = i + 1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
brelse(bitmap_bh);
|
||||
if (i < max)
|
||||
break;
|
||||
|
||||
if (++group >= ext4_get_groups_count(sb))
|
||||
group = 0;
|
||||
|
||||
blkoff = 0;
|
||||
}
|
||||
|
||||
if (i >= max) {
|
||||
*errp = -ENOSPC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
block = ext4_group_first_block_no(sb, group) + EXT4_C2B(sbi, i);
|
||||
ext4_mb_mark_bb(sb, block, 1, 1);
|
||||
ar->len = 1;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Main entry point into mballoc to allocate blocks
|
||||
|
@ -5812,7 +5876,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
|
|||
|
||||
trace_ext4_request_blocks(ar);
|
||||
if (sbi->s_mount_state & EXT4_FC_REPLAY)
|
||||
return ext4_mb_new_blocks_simple(handle, ar, errp);
|
||||
return ext4_mb_new_blocks_simple(ar, errp);
|
||||
|
||||
/* Allow to use superuser reservation for quota file */
|
||||
if (ext4_is_quota_file(ar->inode))
|
||||
|
@ -6036,73 +6100,6 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
|
|||
spin_unlock(&sbi->s_md_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple allocator for Ext4 fast commit replay path. It searches for blocks
|
||||
* linearly starting at the goal block and also excludes the blocks which
|
||||
* are going to be in use after fast commit replay.
|
||||
*/
|
||||
static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
|
||||
struct ext4_allocation_request *ar, int *errp)
|
||||
{
|
||||
struct buffer_head *bitmap_bh;
|
||||
struct super_block *sb = ar->inode->i_sb;
|
||||
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||
ext4_group_t group, nr;
|
||||
ext4_grpblk_t blkoff;
|
||||
ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
|
||||
ext4_grpblk_t i = 0;
|
||||
ext4_fsblk_t goal, block;
|
||||
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
|
||||
|
||||
goal = ar->goal;
|
||||
if (goal < le32_to_cpu(es->s_first_data_block) ||
|
||||
goal >= ext4_blocks_count(es))
|
||||
goal = le32_to_cpu(es->s_first_data_block);
|
||||
|
||||
ar->len = 0;
|
||||
ext4_get_group_no_and_offset(sb, goal, &group, &blkoff);
|
||||
for (nr = ext4_get_groups_count(sb); nr > 0; nr--) {
|
||||
bitmap_bh = ext4_read_block_bitmap(sb, group);
|
||||
if (IS_ERR(bitmap_bh)) {
|
||||
*errp = PTR_ERR(bitmap_bh);
|
||||
pr_warn("Failed to read block bitmap\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
i = mb_find_next_zero_bit(bitmap_bh->b_data, max,
|
||||
blkoff);
|
||||
if (i >= max)
|
||||
break;
|
||||
if (ext4_fc_replay_check_excluded(sb,
|
||||
ext4_group_first_block_no(sb, group) +
|
||||
EXT4_C2B(sbi, i))) {
|
||||
blkoff = i + 1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
brelse(bitmap_bh);
|
||||
if (i < max)
|
||||
break;
|
||||
|
||||
if (++group >= ext4_get_groups_count(sb))
|
||||
group = 0;
|
||||
|
||||
blkoff = 0;
|
||||
}
|
||||
|
||||
if (i >= max) {
|
||||
*errp = -ENOSPC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
block = ext4_group_first_block_no(sb, group) + EXT4_C2B(sbi, i);
|
||||
ext4_mb_mark_bb(sb, block, 1, 1);
|
||||
ar->len = 1;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
|
||||
unsigned long count)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue