linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@MIT.EDU>
To: linux-ext4@vger.kernel.org
Cc: Andreas Dilger <adilger@dilger.ca>, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH, E2FSPROGS] e2fsck: Add check to enforce a valid block bitmap in last block group
Date: Mon, 31 Mar 2008 19:36:30 -0400	[thread overview]
Message-ID: <1207006592-13980-9-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1207006592-13980-8-git-send-email-tytso@mit.edu>

From: Andreas Dilger <adilger@dilger.ca>

Add a check for the UNINIT_BLOCKS flag set in the last group.  The kernel
patch doesn't handle this gracefully, because it assumes there are a full
set of blocks in each group marked UNINIT_BLOCKS.  The kernel should be
fixed up, but in the meantime this avoids hitting the problem, and is
more consistent with lazy_bg not marking the last group UNINIT.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 e2fsck/problem.c |    5 +++++
 e2fsck/problem.h |    3 +++
 e2fsck/super.c   |   25 +++++++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index b6a3a81..828be88 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -371,6 +371,11 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@g descriptor %g has invalid unused inodes count %b.  "),
 	     PROMPT_FIX, PR_PREEN_OK },
 
+	/* Last group block bitmap uninitialized. */
+	{ PR_0_BB_UNINIT_LAST,
+	  N_("Last @g @b @B uninitialized.  "),
+	     PROMPT_FIX, PR_PREEN_OK },
+
 	/* Pass 1 errors */
 
 	/* Pass 1: Checking inodes, blocks, and sizes */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index a2bd2b5..7993203 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -208,6 +208,9 @@ struct problem_context {
 /* Group descriptor N has invalid unused inodes count. */
 #define PR_0_GDT_ITABLE_UNUSED			0x000038
 
+/* Last group block bitmap is uninitialized. */
+#define PR_0_BB_UNINIT_LAST			0x000039
+
 /*
  * Pass 1 errors
  */
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 6753a14..87a0d78 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -631,11 +631,13 @@ void check_super_block(e2fsck_t ctx)
 		    (gd->bg_used_dirs_count > sb->s_inodes_per_group))
 			ext2fs_unmark_valid(fs);
 
+		should_be = 0;
 		if (!ext2fs_group_desc_csum_verify(fs, i)) {
 			if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
 				gd->bg_flags &=	~(EXT2_BG_BLOCK_UNINIT |
 				                  EXT2_BG_INODE_UNINIT);
 				gd->bg_itable_unused = 0;
+				should_be = 1;
 			}
 			ext2fs_unmark_valid(fs);
 		}
@@ -647,23 +649,42 @@ void check_super_block(e2fsck_t ctx)
 				gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT |
 						  EXT2_BG_INODE_UNINIT);
 				gd->bg_itable_unused = 0;
+				should_be = 1;
 			}
 			ext2fs_unmark_valid(fs);
 		}
+
+		if (i == fs->group_desc_count - 1 &&
+		    gd->bg_flags & EXT2_BG_BLOCK_UNINIT) {
+			if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) {
+				gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+				should_be = 1;
+			}
+			ext2fs_unmark_valid(fs);
+		}
+
 		if (gd->bg_flags & EXT2_BG_BLOCK_UNINIT &&
 		    !(gd->bg_flags & EXT2_BG_INODE_UNINIT)) {
-			if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx))
+			if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) {
 				gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+				should_be = 1;
+			}
 			ext2fs_unmark_valid(fs);
 		}
+
 		if (csum_flag &&
 		    (gd->bg_itable_unused > gd->bg_free_inodes_count ||
 		     gd->bg_itable_unused > sb->s_inodes_per_group)) {
 			pctx.blk = gd->bg_itable_unused;
-			if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx))
+			if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx)) {
 				gd->bg_itable_unused = 0;
+				should_be = 1;
+			}
 			ext2fs_unmark_valid(fs);
 		}
+
+		if (should_be)
+			ext2fs_group_desc_csum_set(fs, i);
 	}
 
 	/*
-- 
1.5.4.1.144.gdfee-dirty


  reply	other threads:[~2008-03-31 23:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 13:28 Respin of the uninit_group patches Theodore Ts'o
2008-03-17 13:28 ` [PATCH, REWORKED 01/11] Add initial checksum support for the gdt_checksum/uninit_group feature Theodore Ts'o
2008-03-17 13:28   ` [PATCH, REWORKED 02/11] Add uninit block group support to various libext2fs functions Theodore Ts'o
2008-03-17 13:28     ` [PATCH, REWORKED 03/11] Rename feature name from gdt_checksum to uninit_groups Theodore Ts'o
2008-03-17 13:28       ` [PATCH, REWORKED 04/11] Add support for creating filesystems using uninit block group Theodore Ts'o
2008-03-17 13:28         ` [PATCH, REWORKED 05/11] Make tune2fs uninit block group aware Theodore Ts'o
2008-03-17 13:28           ` [PATCH, REWORKED 06/11] Make dumpe2fs " Theodore Ts'o
2008-03-17 13:28             ` [PATCH, REWORKED 07/11] Make resize2fs " Theodore Ts'o
2008-03-17 13:28               ` [PATCH, REWORKED 08/11] Make debugfs " Theodore Ts'o
2008-03-17 13:28                 ` [PATCH, REWORKED 09/11] Make e2fsck " Theodore Ts'o
2008-03-17 13:28                   ` [PATCH, REWORKED 10/11] Add new m_lazy test case Theodore Ts'o
2008-03-17 13:28                     ` [PATCH, REWORKED 11/11] Add m_uninit " Theodore Ts'o
2008-03-17 17:22   ` [PATCH, REWORKED 01/11] Add initial checksum support for the gdt_checksum/uninit_group feature Andreas Dilger
2008-03-17 18:05     ` Theodore Tso
2008-03-18  0:26       ` Andreas Dilger
2008-03-18 23:33 ` Respin of the uninit_group patches Andreas Dilger
2008-03-25  8:40 ` Andreas Dilger
2008-03-31 23:36   ` [PATCH, E2FSPROGS] Improve ext4 feature descriptions in mke2fs and tune2fs man pages Theodore Ts'o
2008-03-31 23:36     ` [PATCH, E2FSPROGS] Fix the copyright notice in lib/ext2fs/tst_csum.c to be GPLv2 only Theodore Ts'o
2008-03-31 23:36       ` [PATCH, E2FSPROGS] debugfs: Add support for "set_block_group <bg_num> checksum calc" Theodore Ts'o
2008-03-31 23:36         ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling Theodore Ts'o
2008-03-31 23:36           ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap Theodore Ts'o
2008-03-31 23:36             ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Return an error code on errors instead of void Theodore Ts'o
2008-03-31 23:36               ` [PATCH, E2FSPROGS] libext2fs: Micro-optimization in inode scan code Theodore Ts'o
2008-03-31 23:36                 ` [PATCH, E2FSPROGS] Split the m_lazy test case into two cases: m_lazy and m_lazy_resize Theodore Ts'o
2008-03-31 23:36                   ` Theodore Ts'o [this message]
2008-03-31 23:36                     ` [PATCH, E2FSPROGS] Fix trailing whitespace in e2fsck/problem.[ch] Theodore Ts'o
2008-03-31 23:36                       ` [PATCH, E2FSPROGS] Add new regression test: f_uninit_last_uninit Theodore Ts'o
2008-04-01  0:00                       ` [PATCH, E2FSPROGS] Fix trailing whitespace in e2fsck/problem.[ch] Theodore Tso
2008-03-31 23:53               ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Return an error code on errors instead of void Theodore Tso
2008-03-31 23:52             ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap Theodore Tso
2008-03-31 23:47           ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling Theodore Tso
2008-03-31 23:46         ` [PATCH, E2FSPROGS] debugfs: Add support for "set_block_group <bg_num> checksum calc" Theodore Tso
2008-03-25  9:15 ` Respin of the uninit_group patches Andreas Dilger

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=1207006592-13980-9-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.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 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).