Skip to contentSkip to conversation

e2fsprogs: change "blocks" to "clusters" in dumpe2fs

PATCH In review Robin Dong 3 participants 4 messages Aug 5, 2011 – Aug 11, 2011

lore
Share & tools
lore

Robin Dong

author
#0 lore raw

PATCH 1/2 e2fsprogs: change "blocks" to "clusters" in dumpe2fs

From: Robin Dong <[email protected]>

When using dumpe2fs to display group detail of a bigalloc-fs, it displays like:

Group 413: (Blocks 54132737-54263808)
Block bitmap at 54132737 (+0), Inode bitmap at 54132738 (+1) Inode table at 54132739-54133761 (+2)
8127 free blocks, 8184 free inodes, 0 directories Free blocks: 54133776-54263792
Free inodes: 3379993-3388176

The "8127 free blocks" should be "8127 free clusters".

This patch is based on "next" branch of e2fsprogs.

---
 misc/dumpe2fs.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
misc/dumpe2fs.c +15 -6
index 9a0dd46..bb4eef1 100644
@@ -226,12 +226,21 @@ static void list_desc (ext2_filsys fs)
 			    inode_blocks_per_group - 1);
 		print_bg_rel_offset(fs, ext2fs_inode_table_loc(fs, i), 1,
 				    first_block, last_block);
-		printf (_("\n  %u free blocks, %u free inodes, "
-			  "%u directories%s"),
-			ext2fs_bg_free_blocks_count(fs, i),
-			ext2fs_bg_free_inodes_count(fs, i),
-			ext2fs_bg_used_dirs_count(fs, i),
-			ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
+		if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+					EXT4_FEATURE_RO_COMPAT_BIGALLOC))
+			printf (_("\n  %u free clusters, %u free inodes, "
+				  "%u directories%s"),
+				ext2fs_bg_free_blocks_count(fs, i),
+				ext2fs_bg_free_inodes_count(fs, i),
+				ext2fs_bg_used_dirs_count(fs, i),
+				ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
+		else
+			printf (_("\n  %u free blocks, %u free inodes, "
+				  "%u directories%s"),
+				ext2fs_bg_free_blocks_count(fs, i),
+				ext2fs_bg_free_inodes_count(fs, i),
+				ext2fs_bg_used_dirs_count(fs, i),
+				ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
 		if (ext2fs_bg_itable_unused(fs, i))
 			printf (_(", %u unused inodes\n"),
 				ext2fs_bg_itable_unused(fs, i));
Signature · 1 line
1.7.3.2
author
#1 lore raw

PATCH 2/2 e2fsprogs: use s_log_block_size to decide s_first_data_block in ext2fs_initialize

From: Robin Dong <[email protected]>

After mke2fs with 1024 block size:

#misc/mke2fs -m 0 -O ^resize_inode,extent,meta_bg,bigalloc -b 1024 /dev/sda

kernel reports:

[74687.352702] EXT4-fs (loop0): ext4_check_descriptors: Inode bitmap for group 0 not in group (block 524288)!
[74687.355534] EXT4-fs (loop0): group descriptors corrupted!

when mount /dev/sda.

The reason is mke2fs set s_first_data_block to 0 by mistake just because s_log_cluster_size is 4 when s_log_block_size==0.

This patch is based on "next" branch of e2fsprogs.

---
 lib/ext2fs/initialize.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/ext2fs/initialize.c +1 -1
index ccc2dee..c2344a0 100644
@@ -155,7 +155,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	} else
 		super->s_log_cluster_size = super->s_log_block_size;
 
-	set_field(s_first_data_block, super->s_log_cluster_size ? 0 : 1);
+	set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
 	set_field(s_max_mnt_count, 0);
 	set_field(s_errors, EXT2_ERRORS_DEFAULT);
 	set_field(s_feature_compat, 0);
Signature · 1 line
1.7.3.2
#2 lore raw

Re: [PATCH 2/2 bigalloc] e2fsprogs: use s_log_block_size to decide s_first_data_block in ext2fs_initialize

Quoted 4 lines · Robin Dong

From: Robin Dong <[email protected]>

After mke2fs with 1024 block size:

Quoted 8 lines

#misc/mke2fs -m 0 -O ^resize_inode,extent,meta_bg,bigalloc -b 1024 /dev/sda

kernel reports:

[74687.352702] EXT4-fs (loop0): ext4_check_descriptors: Inode bitmap for group 0 not in group (block 524288)!
[74687.355534] EXT4-fs (loop0): group descriptors corrupted!

when mount /dev/sda.

Wow, out of curiosity, why are you using a 1k block size?

Actually, the bug here is in the kernel (in complaining), not in e2fsprogs. The only time we want s_first_data_block to be 1 is in the case when block size and cluster is 1024.

In the case where the cluster is greater than 1k, we want to keep the clusters aligned (for efficiency with 4k blocksize disks if for no other reason). Since the superblock is located at a 1k offset, cluster #0 will always be reserved, so the first 1k is already reserved for use by the bootloader.

- Ted

#3 lore raw
In reply to Robin Dong
Quoted 4 lines · Robin Dong

From: Robin Dong <[email protected]>

When using dumpe2fs to display group detail of a bigalloc-fs, it displays like:

Quoted 8 lines

Group 413: (Blocks 54132737-54263808)
Block bitmap at 54132737 (+0), Inode bitmap at 54132738 (+1) Inode table at 54132739-54133761 (+2)
8127 free blocks, 8184 free inodes, 0 directories Free blocks: 54133776-54263792
Free inodes: 3379993-3388176

The "8127 free blocks" should be "8127 free clusters".

Perhaps it is good to show both the free clusters and the equivalent free blocks, or maybe even free kB, since having units of e.g. 64kB clusters is hard to understand.

Quoted 46 lines

This patch is based on "next" branch of e2fsprogs.

---
misc/dumpe2fs.c | 21 +++++++++++++++------

1 files changed, 15 insertions(+), 6 deletions(-)
misc/dumpe2fs.c +15 -6
index 9a0dd46..bb4eef1 100644
@@ -226,12 +226,21 @@ static void list_desc (ext2_filsys fs)
 			    inode_blocks_per_group - 1);
 		print_bg_rel_offset(fs, ext2fs_inode_table_loc(fs, i), 1,
 				    first_block, last_block);
-		printf (_("\n  %u free blocks, %u free inodes, "
-			  "%u directories%s"),
-			ext2fs_bg_free_blocks_count(fs, i),
-			ext2fs_bg_free_inodes_count(fs, i),
-			ext2fs_bg_used_dirs_count(fs, i),
-			ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
+		if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+					EXT4_FEATURE_RO_COMPAT_BIGALLOC))
+			printf (_("\n  %u free clusters, %u free inodes, "
+				  "%u directories%s"),
+				ext2fs_bg_free_blocks_count(fs, i),
+				ext2fs_bg_free_inodes_count(fs, i),
+				ext2fs_bg_used_dirs_count(fs, i),
+				ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
+		else
+			printf (_("\n  %u free blocks, %u free inodes, "
+				  "%u directories%s"),
+				ext2fs_bg_free_blocks_count(fs, i),
+				ext2fs_bg_free_inodes_count(fs, i),
+				ext2fs_bg_used_dirs_count(fs, i),
+				ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
 		if (ext2fs_bg_itable_unused(fs, i))
 			printf (_(", %u unused inodes\n"),
 				ext2fs_bg_itable_unused(fs, i));
Signature · 6 lines
1.7.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Cheers, Andreas