diff mbox

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

Message ID 1312518471-30714-2-git-send-email-hao.bigrat@gmail.com
State Rejected, archived
Headers show

Commit Message

Robin Dong Aug. 5, 2011, 4:27 a.m. UTC
From: Robin Dong <sanbai@taobao.com>

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.

Signed-off-by: Robin Dong <sanbai@taobao.com>
---
 lib/ext2fs/initialize.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Theodore Ts'o Aug. 11, 2011, 3:23 a.m. UTC | #1
On Fri, Aug 05, 2011 at 12:27:51PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> 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.

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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index ccc2dee..c2344a0 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -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);