ext2: Retry block allocation if new blocks are allocated from system zone.
Subsystems (2)
RFC PATCH 1/1 ext2: Retry block allocation if new blocks are allocated from system zone.
If the block allocator gets blocks out of system zone ext2 calls ext2_error. But if the file system is mounted with errors=continue retry block allocation. We need to mark the system zone blocks as in use to make sure retry don't pick them again
System zone is the block range mapping block bitmap, inode bitmap and inode table.
--- fs/ext2/balloc.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
fs/ext2/balloc.c +11 -5
@@ -149,11 +149,12 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) block_group, le32_to_cpu(desc->bg_block_bitmap));return NULL ; } -if (!ext2_valid_block_bitmap (sb, desc, block_group, bh)) { -brelse (bh); -return NULL ; - } +ext2_valid_block_bitmap (sb, desc, block_group, bh); +/* +* file system mounted not to panic on error, +* continue with corrput bitmap +*/ return bh; }
@@ -1381,7 +1382,12 @@ allocated:"Allocating block in system zone - " "blocks from " E2FSBLK ", length %lu" , ret_block, num); - goto out; +/* +* ext2_try_to_allocate marked the blocks we allocated +* as in use. So we may want to selectively +* mark some of the blocks as free +*/ + goto retry_alloc; } performed_allocation =1 ;
Signature · 1 line
1.5.5.rc0.16.g02b00.dirty
RFC PATCH 1/1 ext3: Retry block allocation if new blocks are allocated from system zone.
If the block allocator gets blocks out of system zone ext3 calls ext3_error. But if the file system is mounted with errors=continue retry block allocation. We need to mark the system zone blocks as in use to make sure retry don't pick them again
System zone is the block range mapping block bitmap, inode bitmap and inode table.
--- fs/ext3/balloc.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
fs/ext3/balloc.c +11 -5
@@ -164,10 +164,11 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) block_group, le32_to_cpu(desc->bg_block_bitmap));return NULL ; } -if (!ext3_valid_block_bitmap (sb, desc, block_group, bh)) { -brelse (bh); -return NULL ; - } +ext3_valid_block_bitmap (sb, desc, block_group, bh); +/* +* file system mounted not to panic on error, +* continue with corrput bitmap +*/ return bh; }/*
@@ -1642,7 +1643,12 @@ allocated:"Allocating block in system zone - " "blocks from " E3FSBLK ", length %lu" , ret_block, num); - goto out; +/* +* claim_block marked the blocks we allocated +* as in use. So we may want to selectively +* mark some of the blocks as free +*/ + goto retry_alloc; } performed_allocation =1 ;
Signature · 1 line
1.5.5.rc0.16.g02b00.dirty
RFC PATCH 1/1 ext4: Retry block allocation if new blocks are allocated from system zone.
If the block allocator gets blocks out of system zone ext4 calls ext4_error. But if the file system is mounted with errors=continue retry block allocation. We need to mark the system zone blocks as in use to make sure retry don't pick them again
System zone is the block range mapping block bitmap, inode bitmap and inode table.
--- fs/ext4/balloc.c | 17 +++++++++++------ fs/ext4/mballoc.c | 47 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 17 deletions(-)
fs/ext4/balloc.c +11 -6
@@ -289,11 +289,11 @@ read_block_bitmap(struct super_block *sb, ext4_group_t block_group) (int)block_group, (unsigned long long)bitmap_blk);return NULL ; } -if (!ext4_valid_block_bitmap (sb, desc, block_group, bh)) { -put_bh (bh); -return NULL ; - } - +ext4_valid_block_bitmap (sb, desc, block_group, bh); +/* +* file system mounted not to panic on error, +* continue with corrput bitmap +*/ return bh; }/*
@@ -1779,7 +1779,12 @@ allocated:"Allocating block in system zone - " "blocks from %llu, length %lu" , ret_block, num); - goto out; +/* +* claim_block marked the blocks we allocated +* as in use. So we may want to selectively +* mark some of the blocks as free +*/ + goto retry_alloc; } performed_allocation =1 ;
fs/ext4/mballoc.c +36 -11
80 lines not on this page · raw message
Signature · 1 line
1.5.5.rc0.16.g02b00.dirty
Quoted 7 lines · Aneesh Kumar K.V
If the block allocator gets blocks out of system zone ext2 calls
ext2_error. But if the file system is mounted with errors=continue retry block allocation. We need to mark the system zone blocks as in use to make sure retry don't pick them againSystem zone is the block range mapping block bitmap, inode bitmap and inode table.
Nack * 3. It appears that this will spin in a loop, because retry_alloc:
will not change the group that is being used, and extN_valid_block_bitmap() does nothing to fix up the bitmap to avoid re-allocating the same blocks.
Instead, it seems safest that extN_new_blocks() should skip the group entirely after marking the group as having no free blocks, so the allocator will no longer choose it. This also means that when freeing blocks it needs to watch out for underflow of the ->bg_free_blocks_count value, which is itself a good safety measure.
Quoted 42 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>--- fs/ext2/balloc.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)fs/ext2/balloc.c +11
-5@@ -149,11 +149,12 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) block_group, le32_to_cpu(desc->bg_block_bitmap));return NULL ; } -if (!ext2_valid_block_bitmap (sb, desc, block_group, bh)) { -brelse (bh); -return NULL ; - } +ext2_valid_block_bitmap (sb, desc, block_group, bh); +/* +* file system mounted not to panic on error, +* continue with corrput bitmap +*/ return bh; }@@ -1381,7 +1382,12 @@ allocated:"Allocating block in system zone - " "blocks from " E2FSBLK ", length %lu" , ret_block, num); - goto out; +/* +* ext2_try_to_allocate marked the blocks we allocated +* as in use. So we may want to selectively +* mark some of the blocks as free +*/ + goto retry_alloc; } performed_allocation =1 ;Signature · 1 line
1.5.5.rc0.16.g02b00.dirty
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Quoted 6 lines · Andreas Dilger
Quoted 5 lines · Aneesh Kumar K.V
If the block allocator gets blocks out of system zone ext2 calls
ext2_error. But if the file system is mounted with errors=continue retry block allocation. We need to mark the system zone blocks as in use to make sure retry don't pick them again
Quoted 6 lines
Quoted 2 lines
System zone is the block range mapping block bitmap, inode bitmap and inode table.
Nack * 3. It appears that this will spin in a loop, because
retry_alloc:
will not change the group that is being used, andextN_valid_block_bitmap()does nothing to fix up the bitmap to avoid re-allocating the same blocks.
As also discussed on irc, ext2_try_to_allocate(fs/ext2/balloc.c:738) marks the blocks allocated as in use. So we will not really spin in loop here. Same is true for ext3 and ext4. (fs/ext4/balloc.c:1066) for mballoc it is done as a part of patch.
Quoted 6 lines
Instead, it seems safest that
extN_new_blocks()should skip the group entirely after marking the group as having no free blocks, so the allocator will no longer choose it. This also means that when freeing blocks it needs to watch out for underflow of the ->bg_free_blocks_count value, which is itself a good safety measure.
Agreed. As you suggested on irc, i will try to introduce EXT4_BG_CORRUPT and ignore the group which has EXT4_BG_CORRUPT set in block allocation. I would also try to do e2fsck changes that will clear this flag after fixing the bitmap corruption.
-aneesh