Skip to content

Commit b450159

Browse files
Ye Binjankara
authored andcommitted
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>
1 parent 2445a8a commit b450159

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

fs/ext2/balloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
11951195
* @goal: given target block(filesystem wide)
11961196
* @count: target number of blocks to allocate
11971197
* @errp: error code
1198+
* @flags: allocate flags
11981199
*
11991200
* ext2_new_blocks uses a goal block to assist allocation. If the goal is
12001201
* 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,
12041205
* This function also updates quota and i_blocks field.
12051206
*/
12061207
ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
1207-
unsigned long *count, int *errp)
1208+
unsigned long *count, int *errp, unsigned int flags)
12081209
{
12091210
struct buffer_head *bitmap_bh = NULL;
12101211
struct buffer_head *gdp_bh;

fs/ext2/ext2.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ struct ext2_inode {
398398
#define EXT2_ERRORS_PANIC 3 /* Panic */
399399
#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
400400

401+
/*
402+
* Allocation flags
403+
*/
404+
#define EXT2_ALLOC_NORESERVE 0x1 /* Do not use reservation
405+
* window for allocation */
406+
401407
/*
402408
* Structure of the super block
403409
*/
@@ -696,7 +702,7 @@ static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
696702
extern int ext2_bg_has_super(struct super_block *sb, int group);
697703
extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
698704
extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
699-
unsigned long *, int *);
705+
unsigned long *, int *, unsigned int);
700706
extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
701707
unsigned int count);
702708
extern void ext2_free_blocks (struct inode *, unsigned long,

fs/ext2/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static int ext2_alloc_blocks(struct inode *inode,
415415
while (1) {
416416
count = target;
417417
/* allocating blocks for indirect blocks and direct blocks */
418-
current_block = ext2_new_blocks(inode,goal,&count,err);
418+
current_block = ext2_new_blocks(inode, goal, &count, err, 0);
419419
if (*err)
420420
goto failed_out;
421421

fs/ext2/xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
744744
EXT2_I(inode)->i_block_group);
745745
unsigned long count = 1;
746746
ext2_fsblk_t block = ext2_new_blocks(inode, goal,
747-
&count, &error);
747+
&count, &error, 0);
748748
if (error)
749749
goto cleanup;
750750
ea_idebug(inode, "creating block %lu", block);

0 commit comments

Comments
 (0)