All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Sander Eikelenboom <linux@eikelenboom.it>
Cc: Kees Cook <keescook@chromium.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	dm-devel@redhat.com, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: EXT4-fs error (device dm-42): ext4_mb_generate_buddy:741: group 1904, 32254 clusters in bitmap, 32258 in gd
Date: Thu, 7 Jun 2012 00:27:56 -0400	[thread overview]
Message-ID: <20120607042756.GA30776@thunk.org> (raw)
In-Reply-To: <1482118647.20120606164012@eikelenboom.it>

I think this patch should fix things.  Could you give it a try (after
re-enabling uninit_bg and then running e2fsck on the file systems)?

Many thanks,

						- Ted

commit b6b218940d47f20fc14e4d203930c575be0c65bf
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Thu Jun 7 00:26:56 2012 -0400

    ext4: fix the free blocks calculation for ext3 file systems w/ uninit_bg
    
    Ext3 filesystems that are converted to use as many ext4 file systems
    as possible will enable uninit_bg to speed up e2fsck times.  File
    systems with an native ext3 layout of inode tables and block
    allocation bitmaps (as opposed to ext4's flex_bg layout), ext4 would
    sometimes incorrectly calculate the number of free blocks in an
    uninitialized block group.  As a result, when first allocating a block
    in block group marked uninitalized, ext4 would incorrectly report that
    the file system was corrupt:
    
    EXT4-fs error (device dm-42): ext4_mb_generate_buddy:741: group 1699, 32254 clusters in bitmap, 32258 in gd
    
    Fix the calculation in ext4_num_overhead_clusters() to avoid this
    problem.
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 99b6324..cee7812 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -90,8 +90,8 @@ unsigned ext4_num_overhead_clusters(struct super_block *sb,
 	 * unusual file system layouts.
 	 */
 	if (ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp), block_group)) {
-		block_cluster = EXT4_B2C(sbi, (start -
-					       ext4_block_bitmap(sb, gdp)));
+		block_cluster = EXT4_B2C(sbi,
+					 ext4_block_bitmap(sb, gdp) - start);
 		if (block_cluster < num_clusters)
 			block_cluster = -1;
 		else if (block_cluster == num_clusters) {
@@ -102,7 +102,7 @@ unsigned ext4_num_overhead_clusters(struct super_block *sb,
 
 	if (ext4_block_in_group(sb, ext4_inode_bitmap(sb, gdp), block_group)) {
 		inode_cluster = EXT4_B2C(sbi,
-					 start - ext4_inode_bitmap(sb, gdp));
+					 ext4_inode_bitmap(sb, gdp) - start);
 		if (inode_cluster < num_clusters)
 			inode_cluster = -1;
 		else if (inode_cluster == num_clusters) {
@@ -114,7 +114,7 @@ unsigned ext4_num_overhead_clusters(struct super_block *sb,
 	itbl_blk = ext4_inode_table(sb, gdp);
 	for (i = 0; i < sbi->s_itb_per_group; i++) {
 		if (ext4_block_in_group(sb, itbl_blk + i, block_group)) {
-			c = EXT4_B2C(sbi, start - itbl_blk + i);
+			c = EXT4_B2C(sbi, itbl_blk + i - start);
 			if ((c < num_clusters) || (c == inode_cluster) ||
 			    (c == block_cluster) || (c == itbl_cluster))
 				continue;

  reply	other threads:[~2012-06-07  4:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04 21:49 EXT4-fs error (device dm-42): ext4_mb_generate_buddy:741: group 1904, 32254 clusters in bitmap, 32258 in gd Sander Eikelenboom
2012-06-04 21:49 ` Sander Eikelenboom
2012-06-04 22:26 ` Ted Ts'o
2012-06-05  0:03 ` Kees Cook
2012-06-05 20:41   ` Sander Eikelenboom
2012-06-05 20:41     ` Sander Eikelenboom
2012-06-05 21:08     ` Ted Ts'o
2012-06-05 21:35       ` Sander Eikelenboom
2012-06-05 21:35         ` Sander Eikelenboom
2012-06-06  7:01       ` Sander Eikelenboom
2012-06-06  7:01         ` Sander Eikelenboom
2012-06-06 14:32         ` Kees Cook
2012-06-06 14:40           ` Sander Eikelenboom
2012-06-06 14:40             ` Sander Eikelenboom
2012-06-07  4:27             ` Ted Ts'o [this message]
2012-06-07 22:27               ` [dm-devel] " djwong
2012-06-07 22:40                 ` Kees Cook
2012-06-07 22:54                   ` Ted Ts'o
2012-06-07 23:38                     ` Kees Cook
2012-06-07 23:38                       ` Kees Cook
2012-06-08  4:43                       ` Andreas Dilger
2012-06-05 23:37     ` Andi Kleen
2012-06-05 23:37       ` Andi Kleen
     [not found] <17610219749.20120604192048@eikelenboom.it>
2012-06-04 23:04 ` Ted Ts'o
2012-06-05  6:56   ` Sander Eikelenboom
2012-06-05  6:56     ` Sander Eikelenboom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120607042756.GA30776@thunk.org \
    --to=tytso@mit.edu \
    --cc=dm-devel@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@eikelenboom.it \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.