Commit 4f5baa83 authored by Kemeng Shi's avatar Kemeng Shi Committed by sanglipeng
Browse files

ext4: correct offset of gdb backup in non meta_bg group to update_backups

stable inclusion
from stable-v5.10.202
commit d739a7e38944208d0b937604389c0e9b82a944db
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9DZOS

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d739a7e38944208d0b937604389c0e9b82a944db



--------------------------------

commit 31f13421c004a420c0e9d288859c9ea9259ea0cc upstream.

Commit 0aeaa255 ("ext4: fix corruption when online resizing a 1K
bigalloc fs") found that primary superblock's offset in its group is
not equal to offset of backup superblock in its group when block size
is 1K and bigalloc is enabled. As group descriptor blocks are right
after superblock, we can't pass block number of gdb to update_backups
for the same reason.

The root casue of the issue above is that leading 1K padding block is
count as data block offset for primary block while backup block has no
padding block offset in its group.

Remove padding data block count to fix the issue for gdb backups.

For meta_bg case, update_backups treat blk_off as block number, do no
conversion in this case.

Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20230826174712.4059355-2-shikemeng@huaweicloud.com


Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 52a02f4c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1557,6 +1557,8 @@ static int ext4_flex_group_add(struct super_block *sb,
		int gdb_num_end = ((group + flex_gd->count - 1) /
				   EXT4_DESC_PER_BLOCK(sb));
		int meta_bg = ext4_has_feature_meta_bg(sb);
		sector_t padding_blocks = meta_bg ? 0 : sbi->s_sbh->b_blocknr -
					 ext4_group_first_block_no(sb, 0);
		sector_t old_gdb = 0;

		update_backups(sb, ext4_group_first_block_no(sb, 0),
@@ -1568,8 +1570,8 @@ static int ext4_flex_group_add(struct super_block *sb,
						     gdb_num);
			if (old_gdb == gdb_bh->b_blocknr)
				continue;
			update_backups(sb, gdb_bh->b_blocknr, gdb_bh->b_data,
				       gdb_bh->b_size, meta_bg);
			update_backups(sb, gdb_bh->b_blocknr - padding_blocks,
				       gdb_bh->b_data, gdb_bh->b_size, meta_bg);
			old_gdb = gdb_bh->b_blocknr;
		}
	}