Patchwork [1/2,bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end

login
register
mail settings
Submitter Robin Dong
Date Aug. 4, 2011, 3:48 a.m.
Message ID <1312429682-16970-2-git-send-email-hao.bigrat@gmail.com>
Download mbox | patch
Permalink /patch/108344/
State New
Headers show

Comments

Robin Dong - Aug. 4, 2011, 3:48 a.m.
From: Robin Dong <sanbai@taobao.com>

The argument "save_blocks_count" and the block bitmap has the unit of cluster,
so it don't need EXT2FS_C2B to convert argument "i".

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

Signed-off-by: Robin Dong <sanbai@taobao.com>
Cc: Ted Ts'o <tytso@mit.edu>
---
 e2fsck/pass5.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
Theodore Ts'o - Aug. 11, 2011, 2:49 a.m.
On Thu, Aug 04, 2011 at 11:48:02AM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> The argument "save_blocks_count" and the block bitmap has the unit of cluster,
> so it don't need EXT2FS_C2B to convert argument "i".
> 
> This patch is based on "next" branch of e2fsprogs.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> Cc: Ted Ts'o <tytso@mit.edu>

No, I don't think this is right.  Regardless of whether the unit of
the block bitmap is cluster- or block- (only while mke2fs is running,
and only initially) based, the argument to
ext2fs_{test,mark,unmark}_block_bitmap is always in blocks.

That's why the EXT2FS_C2B is necessary.

					- 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
Robin Dong - Aug. 12, 2011, 3:44 a.m.
2011/8/11 Ted Ts'o <tytso@mit.edu>:
> On Thu, Aug 04, 2011 at 11:48:02AM +0800, Robin Dong wrote:
>> From: Robin Dong <sanbai@taobao.com>
>>
>> The argument "save_blocks_count" and the block bitmap has the unit of cluster,
>> so it don't need EXT2FS_C2B to convert argument "i".
>>
>> This patch is based on "next" branch of e2fsprogs.
>>
>> Signed-off-by: Robin Dong <sanbai@taobao.com>
>> Cc: Ted Ts'o <tytso@mit.edu>
>
> No, I don't think this is right.  Regardless of whether the unit of
> the block bitmap is cluster- or block- (only while mke2fs is running,
> and only initially) based, the argument to
> ext2fs_{test,mark,unmark}_block_bitmap is always in blocks.
>
> That's why the EXT2FS_C2B is necessary.
>
>                                        - Ted
>

Hi, Ted

Last week I did some wrecking-case to test e2fsck ("next" branch) and
find a error in it:

1. misc/mke2fs -m 0 -O
^has_journal,^resize_inode,^uninit_bg,bigalloc,extent,meta_bg,flex_bg
/dev/sda4
2. copy some file into /dev/sda4
3. set an inode's mode to zero
4. e2fsck -f /dev/sda4

it report something like:

e2fsck 1.42-WIP (02-Jul-2011)
Pass 1: Checking inodes, blocks, and sizes
Inode 314, i_blocks is 128, should be 0.  Fix<y>? yes

Pass 2: Checking directory structure
Inode 314 (/c/3) has invalid mode (00).
Clear<y>? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  -529632
Fix<y>? yes

Free blocks count wrong for group #1 (32267, counted=32268).
Fix<y>? yes

Free blocks count wrong (13838736, counted=13838752).
Fix<y>? yes

Illegal block number passed to ext2fs_test_block_bitmap #13874128 for
converted cluster bitmap
Padding at end of block bitmap is not set. Fix<y>? yes

Illegal block number passed to ext2fs_mark_block_bitmap #13874128 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874144 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874160 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874176 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874192 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874208 for
converted cluster bitmap
Illegal block number passed to ext2fs_mark_block_bitmap #13874224 for
converted cluster bitmap
.......

my disk has just 13874128 4k-blocks, so the block number must have
some problems.
So I doubt at the check_block_end in pass5.c.
Could you please shed some light on it?

Patch

diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index f9d746c..bb2a4dd 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -763,12 +763,10 @@  static void check_block_end(e2fsck_t ctx)
 
 	/* Protect loop from wrap-around if end is maxed */
 	for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
-		if (!ext2fs_test_block_bitmap2(fs->block_map,
-					       EXT2FS_C2B(fs, i))) {
+		if (!ext2fs_test_block_bitmap2(fs->block_map, i)) {
 			if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
 				for (; i <= end; i++)
-					ext2fs_mark_block_bitmap2(fs->block_map,
-							EXT2FS_C2B(fs, i));
+					ext2fs_mark_block_bitmap2(fs->block_map, i);
 				ext2fs_mark_bb_dirty(fs);
 			} else
 				ext2fs_unmark_valid(fs);