Skip to content

Commit 904dad4

Browse files
andyleisersontytso
authored andcommitted
[PATCH] fix calculation of meta_bg descriptor backups
"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 the backup block group descriptors in groups 1 and (desc_per_block-1). 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 Signed-off-by: Andy Leiserson <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 6934da9 commit 904dad4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/ext4/resize.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
10391039
* do not copy the full number of backups at this time. The resize
10401040
* which changed s_groups_count will backup again.
10411041
*/
1042-
static void update_backups(struct super_block *sb, int blk_off, char *data,
1042+
static void update_backups(struct super_block *sb, sector_t blk_off, char *data,
10431043
int size, int meta_bg)
10441044
{
10451045
struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -1064,7 +1064,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
10641064
group = ext4_list_backups(sb, &three, &five, &seven);
10651065
last = sbi->s_groups_count;
10661066
} else {
1067-
group = ext4_meta_bg_first_group(sb, group) + 1;
1067+
group = ext4_get_group_number(sb, blk_off) + 1;
10681068
last = (ext4_group_t)(group + EXT4_DESC_PER_BLOCK(sb) - 2);
10691069
}
10701070

0 commit comments

Comments
 (0)