ext2: introduce new flags argument for ext2_new_blocks()

This patch introduces a new flags argument for ext2_new_blocks() and also
a new EXT2_ALLOC_NORESERVE flag.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Message-Id: <20230815112612.221145-3-yebin10@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Ye Bin 2023-08-15 19:26:10 +08:00 committed by Jan Kara
parent 2445a8a192
commit b450159d09
4 changed files with 11 additions and 4 deletions

View file

@ -1195,6 +1195,7 @@ int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
* @goal: given target block(filesystem wide) * @goal: given target block(filesystem wide)
* @count: target number of blocks to allocate * @count: target number of blocks to allocate
* @errp: error code * @errp: error code
* @flags: allocate flags
* *
* ext2_new_blocks uses a goal block to assist allocation. If the goal is * ext2_new_blocks uses a goal block to assist allocation. If the goal is
* free, or there is a free block within 32 blocks of the goal, that block * free, or there is a free block within 32 blocks of the goal, that block
@ -1204,7 +1205,7 @@ int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
* This function also updates quota and i_blocks field. * This function also updates quota and i_blocks field.
*/ */
ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
unsigned long *count, int *errp) unsigned long *count, int *errp, unsigned int flags)
{ {
struct buffer_head *bitmap_bh = NULL; struct buffer_head *bitmap_bh = NULL;
struct buffer_head *gdp_bh; struct buffer_head *gdp_bh;

View file

@ -398,6 +398,12 @@ struct ext2_inode {
#define EXT2_ERRORS_PANIC 3 /* Panic */ #define EXT2_ERRORS_PANIC 3 /* Panic */
#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
/*
* Allocation flags
*/
#define EXT2_ALLOC_NORESERVE 0x1 /* Do not use reservation
* window for allocation */
/* /*
* Structure of the super block * Structure of the super block
*/ */
@ -696,7 +702,7 @@ static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
extern int ext2_bg_has_super(struct super_block *sb, int group); extern int ext2_bg_has_super(struct super_block *sb, int group);
extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group); extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long, extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
unsigned long *, int *); unsigned long *, int *, unsigned int);
extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk, extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
unsigned int count); unsigned int count);
extern void ext2_free_blocks (struct inode *, unsigned long, extern void ext2_free_blocks (struct inode *, unsigned long,

View file

@ -415,7 +415,7 @@ static int ext2_alloc_blocks(struct inode *inode,
while (1) { while (1) {
count = target; count = target;
/* allocating blocks for indirect blocks and direct blocks */ /* allocating blocks for indirect blocks and direct blocks */
current_block = ext2_new_blocks(inode,goal,&count,err); current_block = ext2_new_blocks(inode, goal, &count, err, 0);
if (*err) if (*err)
goto failed_out; goto failed_out;

View file

@ -744,7 +744,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
EXT2_I(inode)->i_block_group); EXT2_I(inode)->i_block_group);
unsigned long count = 1; unsigned long count = 1;
ext2_fsblk_t block = ext2_new_blocks(inode, goal, ext2_fsblk_t block = ext2_new_blocks(inode, goal,
&count, &error); &count, &error, 0);
if (error) if (error)
goto cleanup; goto cleanup;
ea_idebug(inode, "creating block %lu", block); ea_idebug(inode, "creating block %lu", block);