diff mbox

fix calculation of meta_bg descriptor backups

Message ID 1444060102-8296-1-git-send-email-andy@leiserson.org
State Accepted, archived
Headers show

Commit Message

Andy Leiserson Oct. 5, 2015, 3:48 p.m. UTC
"group" is the group where the backup will be placed, and is initialized
to zero in the declaration. This meant that backups for meta_bg
descriptors were erroneously written to group 1 and group
(desc_per_block-1).

Signed-off-by: Andy Leiserson <andy@leiserson.org>
---
 fs/ext4/resize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o Oct. 18, 2015, 4:37 a.m. UTC | #1
On Mon, Oct 05, 2015 at 08:48:22AM -0700, Andy Leiserson wrote:
> "group" is the group where the backup will be placed, and is initialized
> to zero in the declaration. This meant that backups for meta_bg
> descriptors were erroneously written to group 1 and group
> (desc_per_block-1).
> 
> Signed-off-by: Andy Leiserson <andy@leiserson.org>

Nice catch!  I added to the commit description the following
reproduction information:

  mke2fs -Fq -t ext4 -b 1024 -O ^resize_inode /tmp/foo.img 16G
  truncate -s 24G /tmp/foo.img
  losetup /dev/loop0 /tmp/foo.img
  mount /dev/loop0 /mnt
  resize2fs /dev/loop0
  umount /dev/loop0
  dd if=/dev/zero of=/dev/loop0 bs=1024 count=2
  e2fsck -fy /dev/loop0
  losetup -d /dev/loop0
		  
Cheers,

					- 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 cf0c472..c7c53fd 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1040,7 +1040,7 @@  exit_free:
  * do not copy the full number of backups at this time.  The resize
  * which changed s_groups_count will backup again.
  */
-static void update_backups(struct super_block *sb, int blk_off, char *data,
+static void update_backups(struct super_block *sb, sector_t blk_off, char *data,
 			   int size, int meta_bg)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -1065,7 +1065,7 @@  static void update_backups(struct super_block *sb, int blk_off, char *data,
 		group = ext4_list_backups(sb, &three, &five, &seven);
 		last = sbi->s_groups_count;
 	} else {
-		group = ext4_meta_bg_first_group(sb, group) + 1;
+		group = ext4_get_group_number(sb, blk_off) + 1;
 		last = (ext4_group_t)(group + EXT4_DESC_PER_BLOCK(sb) - 2);
 	}