ext4: fold ext4_free_blocks() and ext4_mb_free_blocks()
ext4_mb_free_blocks() is only called by ext4_free_blocks(), and the latter function doesn't really do much. So merge the two functions together, such that ext4_free_blocks() is now found in fs/ext4/mballoc.c. This saves about 200 bytes of compiled text space. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
b7e57e7c2a
commit
4433871130
@ -498,44 +498,6 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* ext4_free_blocks() -- Free given blocks and update quota
|
||||
* @handle: handle for this transaction
|
||||
* @inode: inode
|
||||
* @block: start physical block to free
|
||||
* @count: number of blocks to count
|
||||
* @metadata: Are these metadata blocks
|
||||
*/
|
||||
void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t block, unsigned long count,
|
||||
int metadata)
|
||||
{
|
||||
struct super_block *sb;
|
||||
unsigned long dquot_freed_blocks;
|
||||
|
||||
/* this isn't the right place to decide whether block is metadata
|
||||
* inode.c/extents.c knows better, but for safety ... */
|
||||
if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
|
||||
metadata = 1;
|
||||
|
||||
/* We need to make sure we don't reuse
|
||||
* block released untill the transaction commit.
|
||||
* writeback mode have weak data consistency so
|
||||
* don't force data as metadata when freeing block
|
||||
* for writeback mode.
|
||||
*/
|
||||
if (metadata == 0 && !ext4_should_writeback_data(inode))
|
||||
metadata = 1;
|
||||
|
||||
sb = inode->i_sb;
|
||||
|
||||
ext4_mb_free_blocks(handle, inode, block, count,
|
||||
metadata, &dquot_freed_blocks);
|
||||
if (dquot_freed_blocks)
|
||||
vfs_dq_free_block(inode, dquot_freed_blocks);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* ext4_has_free_blocks()
|
||||
* @sbi: in-core super block structure.
|
||||
|
@ -1325,8 +1325,6 @@ extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t goal, unsigned long *count, int *errp);
|
||||
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
|
||||
extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
|
||||
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t block, unsigned long count, int metadata);
|
||||
extern void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
|
||||
ext4_fsblk_t block, unsigned long count);
|
||||
extern ext4_fsblk_t ext4_count_free_blocks(struct super_block *);
|
||||
@ -1385,8 +1383,9 @@ extern int ext4_mb_reserve_blocks(struct super_block *, int);
|
||||
extern void ext4_discard_preallocations(struct inode *);
|
||||
extern int __init init_ext4_mballoc(void);
|
||||
extern void exit_ext4_mballoc(void);
|
||||
extern void ext4_mb_free_blocks(handle_t *, struct inode *,
|
||||
ext4_fsblk_t, unsigned long, int, unsigned long *);
|
||||
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t block, unsigned long count,
|
||||
int metadata);
|
||||
extern int ext4_mb_add_groupinfo(struct super_block *sb,
|
||||
ext4_group_t i, struct ext4_group_desc *desc);
|
||||
extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
|
||||
|
@ -4427,18 +4427,24 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Main entry point into mballoc to free blocks
|
||||
/**
|
||||
* ext4_free_blocks() -- Free given blocks and update quota
|
||||
* @handle: handle for this transaction
|
||||
* @inode: inode
|
||||
* @block: start physical block to free
|
||||
* @count: number of blocks to count
|
||||
* @metadata: Are these metadata blocks
|
||||
*/
|
||||
void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t block, unsigned long count,
|
||||
int metadata, unsigned long *freed)
|
||||
void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t block, unsigned long count,
|
||||
int metadata)
|
||||
{
|
||||
struct buffer_head *bitmap_bh = NULL;
|
||||
struct super_block *sb = inode->i_sb;
|
||||
struct ext4_allocation_context *ac = NULL;
|
||||
struct ext4_group_desc *gdp;
|
||||
struct ext4_super_block *es;
|
||||
unsigned long freed = 0;
|
||||
unsigned int overflow;
|
||||
ext4_grpblk_t bit;
|
||||
struct buffer_head *gd_bh;
|
||||
@ -4448,7 +4454,15 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
|
||||
int err = 0;
|
||||
int ret;
|
||||
|
||||
*freed = 0;
|
||||
/*
|
||||
* We need to make sure we don't reuse the freed block until
|
||||
* after the transaction is committed, which we can do by
|
||||
* treating the block as metadata, below. We make an
|
||||
* exception if the inode is to be written in writeback mode
|
||||
* since writeback mode has weak data consistency guarantees.
|
||||
*/
|
||||
if (!ext4_should_writeback_data(inode))
|
||||
metadata = 1;
|
||||
|
||||
sbi = EXT4_SB(sb);
|
||||
es = EXT4_SB(sb)->s_es;
|
||||
@ -4577,7 +4591,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
|
||||
|
||||
ext4_mb_release_desc(&e4b);
|
||||
|
||||
*freed += count;
|
||||
freed += count;
|
||||
|
||||
/* We dirtied the bitmap block */
|
||||
BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
|
||||
@ -4597,6 +4611,8 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
|
||||
}
|
||||
sb->s_dirt = 1;
|
||||
error_return:
|
||||
if (freed)
|
||||
vfs_dq_free_block(inode, freed);
|
||||
brelse(bitmap_bh);
|
||||
ext4_std_error(sb, err);
|
||||
if (ac)
|
||||
|
Loading…
Reference in New Issue
Block a user