All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: Add correct group descriptors and reserved GDT blocks to system zone
@ 2023-06-03 16:33 Wang Jianjian
  2023-06-03 17:59 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wang Jianjian @ 2023-06-03 16:33 UTC (permalink / raw)
  To: linux-ext4, tytso; +Cc: wangjianjian0

When setup_system_zone, flex_bg is not initialzied so it is always 1.
and when meta_bg enabled, group descriptors are located in the first,
second, and the last group of meta group.
And this patch also adds reserved GDT blocks to system zone.

Signed-off-by: Wang Jianjian <wangjianjian0@foxmail.com>
---
 fs/ext4/block_validity.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 5504f72bbbbe..5df357763975 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -215,7 +215,6 @@ int ext4_setup_system_zone(struct super_block *sb)
 	struct ext4_system_blocks *system_blks;
 	struct ext4_group_desc *gdp;
 	ext4_group_t i;
-	int flex_size = ext4_flex_bg_size(sbi);
 	int ret;
 
 	system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
@@ -224,11 +223,14 @@ int ext4_setup_system_zone(struct super_block *sb)
 
 	for (i=0; i < ngroups; i++) {
 		cond_resched();
-		if (ext4_bg_has_super(sb, i) &&
-		    ((i < 5) || ((i % flex_size) == 0))) {
+		unsigned int sb_num = ext4_bg_has_super(sb, i);
+		unsigned long gdb_num = ext4_bg_num_gdb(sb, i);
+		unsigned int rsvd_gdt = le16_to_cpu(sbi->es->s_reserved_gdt_blocks);
+
+		if (sb_num != 0 || gdb_num != 0) {
 			ret = add_system_zone(system_blks,
 					ext4_group_first_block_no(sb, i),
-					ext4_bg_num_gdb(sb, i) + 1, 0);
+					sb_num + gdb_num + rsvd_gdt, 0);
 			if (ret)
 				goto err;
 		}
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-02 16:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-03 16:33 [PATCH] ext4: Add correct group descriptors and reserved GDT blocks to system zone Wang Jianjian
2023-06-03 17:59 ` kernel test robot
2023-06-03 18:10 ` kernel test robot
2023-06-04  3:45 ` Theodore Ts'o
2023-08-02 16:29   ` Wang Jianjian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.