The group descriptors are stored as an array of buffer_heads s_group_desc in struct ext2_sb_info. Replace these buffer heads with the new ext2_buffer and update the buffer functions accordingly. Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx> --- fs/ext2/balloc.c | 24 ++++++++++++------------ fs/ext2/ext2.h | 4 ++-- fs/ext2/ialloc.c | 12 ++++++------ fs/ext2/super.c | 10 +++++----- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index b8cfab8f98b9..21dafa9ae2ea 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -38,7 +38,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, unsigned int block_group, - struct buffer_head ** bh) + struct ext2_buffer ** buf) { unsigned long group_desc; unsigned long offset; @@ -63,8 +63,8 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, } desc = (struct ext2_group_desc *) sbi->s_group_desc[group_desc]->b_data; - if (bh) - *bh = sbi->s_group_desc[group_desc]; + if (buf) + *buf = sbi->s_group_desc[group_desc]; return desc + offset; } @@ -166,7 +166,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) } static void group_adjust_blocks(struct super_block *sb, int group_no, - struct ext2_group_desc *desc, struct buffer_head *bh, int count) + struct ext2_group_desc *desc, struct ext2_buffer *buf, int count) { if (count) { struct ext2_sb_info *sbi = EXT2_SB(sb); @@ -176,7 +176,7 @@ static void group_adjust_blocks(struct super_block *sb, int group_no, free_blocks = le16_to_cpu(desc->bg_free_blocks_count); desc->bg_free_blocks_count = cpu_to_le16(free_blocks + count); spin_unlock(sb_bgl_lock(sbi, group_no)); - mark_buffer_dirty(bh); + ext2_buffer_set_dirty(buf); } } @@ -483,7 +483,7 @@ void ext2_free_blocks(struct inode * inode, ext2_fsblk_t block, unsigned long count) { struct buffer_head *bitmap_bh = NULL; - struct buffer_head * bh2; + struct ext2_buffer * buf2; unsigned long block_group; unsigned long bit; unsigned long i; @@ -522,7 +522,7 @@ void ext2_free_blocks(struct inode * inode, ext2_fsblk_t block, if (!bitmap_bh) goto error_return; - desc = ext2_get_group_desc (sb, block_group, &bh2); + desc = ext2_get_group_desc (sb, block_group, &buf2); if (!desc) goto error_return; @@ -553,7 +553,7 @@ void ext2_free_blocks(struct inode * inode, ext2_fsblk_t block, if (sb->s_flags & SB_SYNCHRONOUS) sync_dirty_buffer(bitmap_bh); - group_adjust_blocks(sb, block_group, desc, bh2, group_freed); + group_adjust_blocks(sb, block_group, desc, buf2, group_freed); freed += group_freed; if (overflow) { @@ -1209,7 +1209,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, unsigned long *count, int *errp, unsigned int flags) { struct buffer_head *bitmap_bh = NULL; - struct buffer_head *gdp_bh; + struct ext2_buffer *gdp_buf; int group_no; int goal_group; ext2_grpblk_t grp_target_blk; /* blockgroup relative goal block */ @@ -1274,7 +1274,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, EXT2_BLOCKS_PER_GROUP(sb); goal_group = group_no; retry_alloc: - gdp = ext2_get_group_desc(sb, group_no, &gdp_bh); + gdp = ext2_get_group_desc(sb, group_no, &gdp_buf); if (!gdp) goto io_error; @@ -1319,7 +1319,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, group_no++; if (group_no >= ngroups) group_no = 0; - gdp = ext2_get_group_desc(sb, group_no, &gdp_bh); + gdp = ext2_get_group_desc(sb, group_no, &gdp_buf); if (!gdp) goto io_error; @@ -1403,7 +1403,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, goto out; } - group_adjust_blocks(sb, group_no, gdp, gdp_bh, -num); + group_adjust_blocks(sb, group_no, gdp, gdp_buf, -num); percpu_counter_sub(&sbi->s_freeblocks_counter, num); mark_buffer_dirty(bitmap_bh); diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index bfed70fd6430..5857d5ce7641 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -105,7 +105,7 @@ struct ext2_sb_info { unsigned long s_blocks_last; /* Last seen block count */ struct ext2_buffer * s_sbuf; /* Buffer containing the super block */ struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ - struct buffer_head ** s_group_desc; + struct ext2_buffer ** s_group_desc; unsigned long s_mount_opt; unsigned long s_sb_block; kuid_t s_resuid; @@ -735,7 +735,7 @@ extern unsigned long ext2_count_free_blocks (struct super_block *); extern unsigned long ext2_count_dirs (struct super_block *); extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, unsigned int block_group, - struct buffer_head ** bh); + struct ext2_buffer ** buf); extern void ext2_discard_reservation (struct inode *); extern int ext2_should_retry_alloc(struct super_block *sb, int *retries); extern void ext2_init_block_alloc_info(struct inode *); diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index fdf63e9c6e7c..36fe7975b2d6 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -66,9 +66,9 @@ read_inode_bitmap(struct super_block * sb, unsigned long block_group) static void ext2_release_inode(struct super_block *sb, int group, int dir) { struct ext2_group_desc * desc; - struct buffer_head *bh; + struct ext2_buffer *buf; - desc = ext2_get_group_desc(sb, group, &bh); + desc = ext2_get_group_desc(sb, group, &buf); if (!desc) { ext2_error(sb, "ext2_release_inode", "can't get descriptor for group %d", group); @@ -83,7 +83,7 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir) percpu_counter_inc(&EXT2_SB(sb)->s_freeinodes_counter); if (dir) percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter); - mark_buffer_dirty(bh); + ext2_buffer_set_dirty(buf); } /* @@ -421,7 +421,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode, { struct super_block *sb; struct buffer_head *bitmap_bh = NULL; - struct buffer_head *bh2; + struct ext2_buffer *buf2; int group, i; ino_t ino = 0; struct inode * inode; @@ -453,7 +453,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode, } for (i = 0; i < sbi->s_groups_count; i++) { - gdp = ext2_get_group_desc(sb, group, &bh2); + gdp = ext2_get_group_desc(sb, group, &buf2); if (!gdp) { if (++group == sbi->s_groups_count) group = 0; @@ -536,7 +536,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode, } spin_unlock(sb_bgl_lock(sbi, group)); - mark_buffer_dirty(bh2); + ext2_buffer_set_dirty(buf2); if (test_opt(sb, GRPID)) { inode->i_mode = mode; inode->i_uid = current_fsuid(); diff --git a/fs/ext2/super.c b/fs/ext2/super.c index ac53f587d140..4323448bf64b 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -162,7 +162,7 @@ static void ext2_put_super (struct super_block * sb) } db_count = sbi->s_gdb_count; for (i = 0; i < db_count; i++) - brelse(sbi->s_group_desc[i]); + ext2_put_buffer(sb, sbi->s_group_desc[i]); kvfree(sbi->s_group_desc); kfree(sbi->s_debts); percpu_counter_destroy(&sbi->s_freeblocks_counter); @@ -1093,7 +1093,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / EXT2_DESC_PER_BLOCK(sb); sbi->s_group_desc = kvmalloc_array(db_count, - sizeof(struct buffer_head *), + sizeof(struct ext2_buffer *), GFP_KERNEL); if (sbi->s_group_desc == NULL) { ret = -ENOMEM; @@ -1109,10 +1109,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) } for (i = 0; i < db_count; i++) { block = descriptor_loc(sb, logic_sb_block, i); - sbi->s_group_desc[i] = sb_bread(sb, block); + sbi->s_group_desc[i] = ext2_read_buffer(sb, block); if (!sbi->s_group_desc[i]) { for (j = 0; j < i; j++) - brelse (sbi->s_group_desc[j]); + ext2_put_buffer (sb, sbi->s_group_desc[j]); ext2_msg(sb, KERN_ERR, "error: unable to read group descriptors"); goto failed_mount_group_desc; @@ -1216,7 +1216,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) percpu_counter_destroy(&sbi->s_dirs_counter); failed_mount2: for (i = 0; i < db_count; i++) - brelse(sbi->s_group_desc[i]); + ext2_put_buffer(sb, sbi->s_group_desc[i]); failed_mount_group_desc: kvfree(sbi->s_group_desc); kfree(sbi->s_debts); -- 2.43.0