ext4: Use EXT4_GROUP_INFO_NEED_INIT_BIT during resize
PATCH RESEND 1/1 ext4: Use EXT4_GROUP_INFO_NEED_INIT_BIT during resize
The new groups added during resize are flagged as need_init group. Make sure we properly initialize these groups. When we have block size < page size and we are adding new groups the page may still be marked uptodate even though we haven't initialized the group. While forcing the init of buddy cache we need to make sure other groups part of the same page of buddy cache is not using the cache. group_info->alloc_sem is added to ensure the same.
FILENAME: aneesh-3-use_EXT4_GROUP_INFO_NEED_INIT_BIT-during-resize V5 changes:
The change in this version is to make sure we we are adding new groups we don't have a parllel ext4_mb_init_cache happening on other groups which are part of the same page in buddy cache. We do that by taking write lock on the group_info alloc_sem semaphore.
--- fs/ext4/balloc.c | 21 +++-- fs/ext4/ext4.h | 7 +- fs/ext4/mballoc.c | 261 +++++++++++++++++++++++++++++++++++++++++------------ fs/ext4/mballoc.h | 3 + fs/ext4/resize.c | 49 ++--------- 5 files changed, 230 insertions(+), 111 deletions(-)
fs/ext4/balloc.c +13 -8
@@ -381,6 +381,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,ext4_debug ("Adding block(s) %llu-%llu\n" , block, block + count -1 );ext4_get_group_no_and_offset (sb, block, &block_group, &bit); + grp =ext4_get_group_info (sb, block_group);/* * Check to see if we are freeing blocks across a group * boundary.
@@ -425,7 +426,11 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, err =ext4_journal_get_write_access (handle, gd_bh);if (err) goto error_return; - +/* +* make sure we don't allow a parallel init on other groups in the +* same buddy cache +*/ +down_write (&grp->alloc_sem); for (i = 0, blocks_freed = 0; i < count; i++) { BUFFER_TRACE(bitmap_bh, "clear bit"); if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
@@ -450,6 +455,13 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, sbi->s_flex_groups[flex_group].free_blocks += blocks_freed;spin_unlock (sb_bgl_lock (sbi, flex_group)); } +/* +* request to reload the buddy with the +* new bitmap information +*/ +set_bit (EXT4_GROUP_INFO_NEED_INIT_BIT , &(grp->bb_state)); +ext4_mb_update_group_info (grp, blocks_freed); +up_write (&grp->alloc_sem);/* We dirtied the bitmap block */ BUFFER_TRACE (bitmap_bh,"dirtied bitmap block" );
@@ -461,13 +473,6 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,if (!err) err = ret; sb->s_dirt =1 ; -/* -* request to reload the buddy with the -* new bitmap information -*/ - grp =ext4_get_group_info (sb, block_group); -set_bit (EXT4_GROUP_INFO_NEED_INIT_BIT , &(grp->bb_state)); -ext4_mb_update_group_info (grp, blocks_freed); error_return:brelse (bitmap_bh);
fs/ext4/ext4.h +4 -3
@@ -1065,12 +1065,13 @@ extern int __init init_ext4_mballoc(void);extern void exit_ext4_mballoc (void );extern void ext4_mb_free_blocks (handle_t *,struct inode *,unsigned long ,unsigned long ,int ,unsigned long *); -extern int ext4_mb_add_more_groupinfo (struct super_block *sb, +extern int ext4_mb_add_groupinfo (struct super_block *sb,ext4_group_t i,struct ext4_group_desc *desc);extern void ext4_mb_update_group_info (struct ext4_group_info *grp,ext4_grpblk_t add); - - +extern int ext4_mb_get_buddy_cache_lock (struct super_block *,ext4_group_t ); +extern void ext4_mb_put_buddy_cache_lock (struct super_block *, +ext4_group_t ,int );/* inode.c */ int ext4_forget (handle_t *handle,int is_metadata,struct inode *inode,struct buffer_head *bh,ext4_fsblk_t blocknr);
fs/ext4/mballoc.c +202 -59
357 lines not on this page · raw message
fs/ext4/mballoc.h +3 -0
@@ -20,6 +20,7 @@#include <linux/version.h> #include <linux/blkdev.h> #include <linux/marker.h> +#include <linux/mutex.h> #include "ext4_jbd2.h" #include "ext4.h" #include "group.h"
@@ -130,6 +131,7 @@ struct ext4_group_info {#ifdef DOUBLE_CHECK void *bb_bitmap;#endif +struct rw_semaphore alloc_sem;unsigned short bb_counters[]; };
@@ -250,6 +252,7 @@ struct ext4_buddy {struct super_block *bd_sb;__u16 bd_blkbits;ext4_group_t bd_group; +struct rw_semaphore *alloc_semp; };#define EXT4_MB_BITMAP (e4b) ((e4b)->bd_bitmap)#define EXT4_MB_BUDDY (e4b) ((e4b)->bd_buddy)
fs/ext4/resize.c +8 -40
82 lines not on this page · raw message