diff mbox

ext4: Fixed corruption when online resizing a fs with 1K block size

Message ID 1367856367-15924-1-git-send-email-maarten@treewalker.org
State Accepted, archived
Headers show

Commit Message

Maarten ter Huurne May 6, 2013, 4:06 p.m. UTC
Subtracting the number of the first data block places the superblock
backups one block too early, corrupting the file system. When the block
size is larger than 1K, the first data block is 0, so the subtraction
has no effect and no corruption occurs.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
---
 fs/ext4/resize.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Jan Kara May 8, 2013, 1:58 p.m. UTC | #1
On Mon 06-05-13 18:06:07, Maarten ter Huurne wrote:
> Subtracting the number of the first data block places the superblock
> backups one block too early, corrupting the file system. When the block
> size is larger than 1K, the first data block is 0, so the subtraction
> has no effect and no corruption occurs.
  Looking where mke2fs places backup super blocks you are right. You can
add:
Reviewed-by: Jan Kara <jack@suse.cz>

								Honza
> 
> Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
> ---
>  fs/ext4/resize.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index c169477..116c80d 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1654,12 +1654,10 @@ errout:
>  		err = err2;
>  
>  	if (!err) {
> -		ext4_fsblk_t first_block;
> -		first_block = ext4_group_first_block_no(sb, 0);
>  		if (test_opt(sb, DEBUG))
>  			printk(KERN_DEBUG "EXT4-fs: extended group to %llu "
>  			       "blocks\n", ext4_blocks_count(es));
> -		update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr - first_block,
> +		update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr,
>  			       (char *)es, sizeof(struct ext4_super_block), 0);
>  	}
>  	return err;
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o June 17, 2013, 1:07 p.m. UTC | #2
On Wed, May 08, 2013 at 03:58:25PM +0200, Jan Kara wrote:
> On Mon 06-05-13 18:06:07, Maarten ter Huurne wrote:
> > Subtracting the number of the first data block places the superblock
> > backups one block too early, corrupting the file system. When the block
> > size is larger than 1K, the first data block is 0, so the subtraction
> > has no effect and no corruption occurs.
>   Looking where mke2fs places backup super blocks you are right. You can
> add:
> Reviewed-by: Jan Kara <jack@suse.cz>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index c169477..116c80d 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1654,12 +1654,10 @@  errout:
 		err = err2;
 
 	if (!err) {
-		ext4_fsblk_t first_block;
-		first_block = ext4_group_first_block_no(sb, 0);
 		if (test_opt(sb, DEBUG))
 			printk(KERN_DEBUG "EXT4-fs: extended group to %llu "
 			       "blocks\n", ext4_blocks_count(es));
-		update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr - first_block,
+		update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr,
 			       (char *)es, sizeof(struct ext4_super_block), 0);
 	}
 	return err;