linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap
@ 2011-08-04  3:48 Robin Dong
  2011-08-04  3:48 ` [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end Robin Dong
  2011-08-11  2:51 ` [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Ted Ts'o
  0 siblings, 2 replies; 5+ messages in thread
From: Robin Dong @ 2011-08-04  3:48 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong, Ted Ts'o

From: Robin Dong <sanbai@taobao.com>

When I run a test application on ext4 of bigalloc, and also a daemon
which run "echo 3 > /proc/sys/vm/drop_caches" every 2 seconds,
the kernel report:

15319.557145] EXT4-fs error (device sda4): ext4_valid_block_bitmap:324: comm dir_tree: Invalid block bitmap - block_group = 6, block = 3145730

The reason is ext4_valied_block_bitmap has not be modified for cluster.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Cc: Ted Ts'o <tytso@mit.edu>
---
 fs/ext4/balloc.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 23a6375..8b982fc 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -282,6 +282,7 @@ static int ext4_valid_block_bitmap(struct super_block *sb,
 	ext4_grpblk_t next_zero_bit;
 	ext4_fsblk_t bitmap_blk;
 	ext4_fsblk_t group_first_block;
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
 
 	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
 		/* with FLEX_BG, the inode/block bitmaps and itable
@@ -297,14 +298,14 @@ static int ext4_valid_block_bitmap(struct super_block *sb,
 	/* check whether block bitmap block number is set */
 	bitmap_blk = ext4_block_bitmap(sb, desc);
 	offset = bitmap_blk - group_first_block;
-	if (!ext4_test_bit(offset, bh->b_data))
+	if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
 		/* bad block bitmap */
 		goto err_out;
 
 	/* check whether the inode bitmap block number is set */
 	bitmap_blk = ext4_inode_bitmap(sb, desc);
 	offset = bitmap_blk - group_first_block;
-	if (!ext4_test_bit(offset, bh->b_data))
+	if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
 		/* bad block bitmap */
 		goto err_out;
 
@@ -312,9 +313,11 @@ static int ext4_valid_block_bitmap(struct super_block *sb,
 	bitmap_blk = ext4_inode_table(sb, desc);
 	offset = bitmap_blk - group_first_block;
 	next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
-				offset + EXT4_SB(sb)->s_itb_per_group,
-				offset);
-	if (next_zero_bit >= offset + EXT4_SB(sb)->s_itb_per_group)
+			EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group),
+			EXT4_B2C(sbi, offset));
+
+	if (next_zero_bit >=
+			EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group))
 		/* good bitmap for inode tables */
 		return 1;
 
-- 
1.7.3.2


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

* [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end
  2011-08-04  3:48 [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Robin Dong
@ 2011-08-04  3:48 ` Robin Dong
  2011-08-11  2:49   ` Ted Ts'o
  2011-08-11  2:51 ` [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Ted Ts'o
  1 sibling, 1 reply; 5+ messages in thread
From: Robin Dong @ 2011-08-04  3:48 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong, Ted Ts'o

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(-)

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);
-- 
1.7.3.2


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

* Re: [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end
  2011-08-04  3:48 ` [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end Robin Dong
@ 2011-08-11  2:49   ` Ted Ts'o
  2011-08-12  3:44     ` Robin Dong
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Ts'o @ 2011-08-11  2:49 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

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

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

* Re: [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap
  2011-08-04  3:48 [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Robin Dong
  2011-08-04  3:48 ` [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end Robin Dong
@ 2011-08-11  2:51 ` Ted Ts'o
  1 sibling, 0 replies; 5+ messages in thread
From: Ted Ts'o @ 2011-08-11  2:51 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Thu, Aug 04, 2011 at 11:48:01AM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> When I run a test application on ext4 of bigalloc, and also a daemon
> which run "echo 3 > /proc/sys/vm/drop_caches" every 2 seconds,
> the kernel report:
> 
> 15319.557145] EXT4-fs error (device sda4): ext4_valid_block_bitmap:324: comm dir_tree: Invalid block bitmap - block_group = 6, block = 3145730
> 
> The reason is ext4_valied_block_bitmap has not be modified for cluster.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> Cc: Ted Ts'o <tytso@mit.edu>

Yep, this looks like a bug --- I'm curious, though --- this is
something I don't run into because I use mke2fs -t ext4 which sets the
flex_bg feature.  Is there some reason you're not using flex_bg on
your file systems?

					- Ted

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

* Re: [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end
  2011-08-11  2:49   ` Ted Ts'o
@ 2011-08-12  3:44     ` Robin Dong
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Dong @ 2011-08-12  3:44 UTC (permalink / raw)
  To: Ted Ts'o; +Cc: linux-ext4

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?


-- 
--
Best Regard
Robin Dong
--
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

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

end of thread, other threads:[~2011-08-12  3:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-04  3:48 [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Robin Dong
2011-08-04  3:48 ` [PATCH 1/2 bigalloc] e2fsprogs: remove wrong EXT2FS_C2B in check_block_end Robin Dong
2011-08-11  2:49   ` Ted Ts'o
2011-08-12  3:44     ` Robin Dong
2011-08-11  2:51 ` [PATCH 2/2 bigalloc] ext4: modify offset to cluster in ext4_valid_block_bitmap Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).