ext4: Use high 16 bits of the block group descriptor's free counts fields
PATCH 1/1 ext4: Use high 16 bits of the block group descriptor's free counts fields
Rename the lower bits with suffix _lo and add helper to access the values. Also rename bg_itable_unused_hi to bg_pad as in e2fsprogs.
FILENAME: use-high-16-bits-of-bg-free-counts
Signed-off-by Aneesh Kumar K.V <[email protected]>
--- fs/ext4/balloc.c | 13 ++++---- fs/ext4/ext4.h | 26 +++++++++++++--- fs/ext4/ialloc.c | 83 ++++++++++++++++++++++++++++------------------------- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 15 +++++---- fs/ext4/resize.c | 4 +- fs/ext4/super.c | 68 ++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 149 insertions(+), 62 deletions(-)
fs/ext4/balloc.c +7 -6
@@ -102,9 +102,9 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,if (!ext4_group_desc_csum_verify (sbi, block_group, gdp)) {ext4_error (sb, __func__,"Checksum bad for group %u\n" , block_group); - gdp->bg_free_blocks_count =0 ; - gdp->bg_free_inodes_count =0 ; - gdp->bg_itable_unused =0 ; +ext4_free_blks_set (sb, gdp,0 ); +ext4_free_inodes_set (sb, gdp,0 ); +ext4_itable_unused_set (sb, gdp,0 );memset (bh->b_data,0xff , sb->s_blocksize);return 0 ; }
@@ -372,7 +372,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,struct ext4_group_desc *desc;struct ext4_super_block *es;struct ext4_sb_info *sbi; -int err =0 , ret; +int err =0 , ret, blk_free_count;ext4_grpblk_t blocks_freed;struct ext4_group_info *grp;
@@ -444,7 +444,8 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, } }spin_lock (sb_bgl_lock (sbi, block_group)); -le16_add_cpu (&desc->bg_free_blocks_count, blocks_freed); + blk_free_count = blocks_freed +ext4_free_blks_count (sb, desc); +ext4_free_blks_set (sb, desc, blk_free_count); desc->bg_checksum =ext4_group_desc_csum (sbi, block_group, desc);spin_unlock (sb_bgl_lock (sbi, block_group));percpu_counter_add (&sbi->s_freeblocks_counter, blocks_freed);
@@ -741,7 +742,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb) gdp =ext4_get_group_desc (sb, i,NULL );if (!gdp)continue ; - desc_count +=le16_to_cpu (gdp->bg_free_blocks_count); + desc_count +=ext4_free_blks_count (sb, gdp); }return desc_count;
fs/ext4/ext4.h +21 -5
@@ -156,12 +156,12 @@ struct ext4_group_desc__le32 bg_block_bitmap_lo;/* Blocks bitmap block */ __le32 bg_inode_bitmap_lo;/* Inodes bitmap block */ __le32 bg_inode_table_lo;/* Inodes table block */ -__le16 bg_free_blocks_count;/* Free blocks count */ -__le16 bg_free_inodes_count;/* Free inodes count */ -__le16 bg_used_dirs_count;/* Directories count */ +__le16 bg_free_blocks_count_lo;/* Free blocks count */ +__le16 bg_free_inodes_count_lo;/* Free inodes count */ +__le16 bg_used_dirs_count_lo;/* Directories count */ __le16 bg_flags;/* EXT4_BG_flags (INODE_UNINIT, etc) */ __u32 bg_reserved[2 ];/* Likely block/inode bitmap checksum */ -__le16 bg_itable_unused;/* Unused inodes count */ +__le16 bg_itable_unused_lo;/* Unused inodes count */ __le16 bg_checksum;/* crc16(sb_uuid+group+desc) */ __le32 bg_block_bitmap_hi;/* Blocks bitmap block MSB */ __le32 bg_inode_bitmap_hi;/* Inodes bitmap block MSB */
@@ -169,7 +169,7 @@ struct ext4_group_desc__le16 bg_free_blocks_count_hi;/* Free blocks count MSB */ __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */ __le16 bg_used_dirs_count_hi;/* Directories count MSB */ -__le16 bg_itable_unused_hi;/* Unused inodes count MSB */ +__le16 bg_itable_unused_hi;/* Unused inodes count MSB */ __u32 bg_reserved2[3 ]; };
@@ -1139,12 +1139,28 @@ extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg);extern ext4_fsblk_t ext4_inode_table (struct super_block *sb,struct ext4_group_desc *bg); +extern __u32 ext4_free_blks_count (struct super_block *sb, +struct ext4_group_desc *bg); +extern __u32 ext4_free_inodes_count (struct super_block *sb, +struct ext4_group_desc *bg); +extern __u32 ext4_used_dirs_count (struct super_block *sb, +struct ext4_group_desc *bg); +extern __u32 ext4_itable_unused_count (struct super_block *sb, +struct ext4_group_desc *bg);extern void ext4_block_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk);extern void ext4_inode_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk);extern void ext4_inode_table_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk); +extern void ext4_free_blks_set (struct super_block *sb, +struct ext4_group_desc *bg,__u32 count); +extern void ext4_free_inodes_set (struct super_block *sb, +struct ext4_group_desc *bg,__u32 count); +extern void ext4_used_dirs_set (struct super_block *sb, +struct ext4_group_desc *bg,__u32 count); +extern void ext4_itable_unused_set (struct super_block *sb, +struct ext4_group_desc *bg,__u32 count);static inline ext4_fsblk_t ext4_blocks_count (struct ext4_super_block *es) {
fs/ext4/ialloc.c +44 -39
212 lines not on this page · raw message
fs/ext4/inode.c +1 -1
@@ -3987,7 +3987,7 @@ static int __ext4_get_inode_loc(struct inode *inode, num =EXT4_INODES_PER_GROUP (sb);if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_GDT_CSUM )) - num -=le16_to_cpu (gdp->bg_itable_unused); + num -=ext4_itable_unused_count (sb, gdp); table += num / inodes_per_block;if (end > table) end = table;
fs/ext4/mballoc.c +8 -7
@@ -2474,7 +2474,7 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,ext4_free_blocks_after_init (sb, group, desc); }else { meta_group_info[i]->bb_free = -le16_to_cpu (desc->bg_free_blocks_count); +ext4_free_blks_count (sb, desc); }INIT_LIST_HEAD (&meta_group_info[i]->bb_prealloc_list);
@@ -3002,12 +3002,12 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, ac->ac_b_ex.fe_start, ac->ac_b_ex.fe_len);if (gdp->bg_flags &cpu_to_le16 (EXT4_BG_BLOCK_UNINIT )) { gdp->bg_flags &=cpu_to_le16 (~EXT4_BG_BLOCK_UNINIT ); - gdp->bg_free_blocks_count = -cpu_to_le16 (ext4_free_blocks_after_init (sb, - ac->ac_b_ex.fe_group, - gdp)); +ext4_free_blks_set (sb, gdp, +ext4_free_blocks_after_init (sb, + ac->ac_b_ex.fe_group, gdp)); } -le16_add_cpu (&gdp->bg_free_blocks_count, -ac->ac_b_ex.fe_len); + len =ext4_free_blks_count (sb, gdp) - ac->ac_b_ex.fe_len; +ext4_free_blks_set (sb, gdp, len); gdp->bg_checksum =ext4_group_desc_csum (sbi, ac->ac_b_ex.fe_group, gdp);spin_unlock (sb_bgl_lock (sbi, ac->ac_b_ex.fe_group));percpu_counter_sub (&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len);
@@ -4783,7 +4783,8 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, }spin_lock (sb_bgl_lock (sbi, block_group)); -le16_add_cpu (&gdp->bg_free_blocks_count, count); + ret =ext4_free_blks_count (sb, gdp) + count; +ext4_free_blks_set (sb, gdp, ret); gdp->bg_checksum =ext4_group_desc_csum (sbi, block_group, gdp);spin_unlock (sb_bgl_lock (sbi, block_group));percpu_counter_add (&sbi->s_freeblocks_counter, count);
fs/ext4/resize.c +2 -2
@@ -862,8 +862,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)ext4_block_bitmap_set (sb, gdp, input->block_bitmap);/* LV FIXME */ ext4_inode_bitmap_set (sb, gdp, input->inode_bitmap);/* LV FIXME */ ext4_inode_table_set (sb, gdp, input->inode_table);/* LV FIXME */ - gdp->bg_free_blocks_count =cpu_to_le16 (input->free_blocks_count); - gdp->bg_free_inodes_count =cpu_to_le16 (EXT4_INODES_PER_GROUP (sb)); +ext4_free_blks_set (sb, gdp, input->free_blocks_count); +ext4_free_inodes_set (sb, gdp,EXT4_INODES_PER_GROUP (sb)); gdp->bg_checksum =ext4_group_desc_csum (sbi, input->group, gdp);/*
fs/ext4/super.c +66 -2
87 lines not on this page · raw message
Signature · 1 line
1.6.0.4.735.gea4f