add patch fix-calculation-of-meta_bg-descriptor-backups
[ext4-patch-queue.git] / fix-calculation-of-meta_bg-descriptor-backups
blobb4f76606052d22c8b55d26b54d52189e30a8e204
1 Subject: [PATCH] fix calculation of meta_bg descriptor backups
3 From: Andy Leiserson <andy@leiserson.org>
5 "group" is the group where the backup will be placed, and is
6 initialized to zero in the declaration. This meant that backups for
7 meta_bg descriptors were erroneously written to the backup block group
8 descriptors in groups 1 and (desc_per_block-1).
10 Reproduction information:
11   mke2fs -Fq -t ext4 -b 1024 -O ^resize_inode /tmp/foo.img 16G
12   truncate -s 24G /tmp/foo.img
13   losetup /dev/loop0 /tmp/foo.img
14   mount /dev/loop0 /mnt
15   resize2fs /dev/loop0
16   umount /dev/loop0
17   dd if=/dev/zero of=/dev/loop0 bs=1024 count=2
18   e2fsck -fy /dev/loop0
19   losetup -d /dev/loop0
21 Signed-off-by: Andy Leiserson <andy@leiserson.org>
22 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
23 Cc: stable@vger.kernel.org
24 ---
25  fs/ext4/resize.c | 4 ++--
26  1 file changed, 2 insertions(+), 2 deletions(-)
28 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
29 index cf0c472..c7c53fd 100644
30 --- a/fs/ext4/resize.c
31 +++ b/fs/ext4/resize.c
32 @@ -1040,7 +1040,7 @@ exit_free:
33   * do not copy the full number of backups at this time.  The resize
34   * which changed s_groups_count will backup again.
35   */
36 -static void update_backups(struct super_block *sb, int blk_off, char *data,
37 +static void update_backups(struct super_block *sb, sector_t blk_off, char *data,
38                            int size, int meta_bg)
39  {
40         struct ext4_sb_info *sbi = EXT4_SB(sb);
41 @@ -1065,7 +1065,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
42                 group = ext4_list_backups(sb, &three, &five, &seven);
43                 last = sbi->s_groups_count;
44         } else {
45 -               group = ext4_meta_bg_first_group(sb, group) + 1;
46 +               group = ext4_get_group_number(sb, blk_off) + 1;
47                 last = (ext4_group_t)(group + EXT4_DESC_PER_BLOCK(sb) - 2);
48         }
50 -- 
51 2.5.3
54 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
55 the body of a message to majordomo@vger.kernel.org
56 More majordomo info at  http://vger.kernel.org/majordomo-info.html