All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 28/25] e2fsck: ignore badblocks if it says badblocks inode is bad
Date: Thu, 11 Sep 2014 12:44:49 -0700	[thread overview]
Message-ID: <20140911194449.GT10351@birch.djwong.org> (raw)
In-Reply-To: <20140908231135.25904.66591.stgit@birch.djwong.org>

If the badblocks list says that the badblocks inode is bad, it's quite
likely that badblocks is broken.  Worse yet, if the root inode is in
the same block as the badblocks inode (likely since they're adjacent),
the filesystem becomes unfixable because pass3 notices the bad root
inode and exits.

So... if we encounter this case, just kill the badblocks inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c            |   31 +++++++++++++++++++++++++++++++
 e2fsck/problem.c          |    5 +++++
 e2fsck/problem.h          |    3 +++
 tests/f_bb_in_bb/expect.1 |   17 +++++++++++++++++
 tests/f_bb_in_bb/expect.2 |    7 +++++++
 tests/f_bb_in_bb/image.gz |  Bin
 tests/f_bb_in_bb/name     |    1 +
 7 files changed, 64 insertions(+)
 create mode 100644 tests/f_bb_in_bb/expect.1
 create mode 100644 tests/f_bb_in_bb/expect.2
 create mode 100644 tests/f_bb_in_bb/image.gz
 create mode 100644 tests/f_bb_in_bb/name

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index f09cddb..7dfb1bd 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1141,6 +1141,37 @@ void e2fsck_pass1(e2fsck_t ctx)
 		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
 			return;
 		if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
+			/*
+			 * If badblocks says badblocks is bad, offer to clear
+			 * the list, update the in-core bb list, and restart
+			 * the inode scan.
+			 */
+			if (ino == EXT2_BAD_INO &&
+			    fix_problem(ctx, PR_1_BADBLOCKS_IN_BADBLOCKS,
+					&pctx)) {
+				errcode_t err;
+
+				e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
+				ext2fs_badblocks_list_free(ctx->fs->badblocks);
+				ctx->fs->badblocks = NULL;
+				err = ext2fs_read_bb_inode(ctx->fs,
+							&ctx->fs->badblocks);
+				if (err) {
+					fix_problem(ctx, PR_1_ISCAN_ERROR,
+						    &pctx);
+					ctx->flags |= E2F_FLAG_ABORT;
+					goto endit;
+				}
+				err = ext2fs_inode_scan_goto_blockgroup(scan,
+									0);
+				if (err) {
+					fix_problem(ctx, PR_1_ISCAN_ERROR,
+						    &pctx);
+					ctx->flags |= E2F_FLAG_ABORT;
+					goto endit;
+				}
+				continue;
+			}
 			if (!ctx->inode_bb_map)
 				alloc_bb_map(ctx);
 			ext2fs_mark_inode_bitmap2(ctx->inode_bb_map, ino);
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 4b41a21..79bba1a 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1086,6 +1086,11 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@i %i has inline data and @x flags set but i_block contains junk.\n"),
 	  PROMPT_CLEAR_INODE, 0 },
 
+	/* Bad block list says the bad block list inode is bad */
+	{ PR_1_BADBLOCKS_IN_BADBLOCKS,
+	  N_("Bad block list says the bad block list @i is bad.  "),
+	  PROMPT_CLEAR_INODE, 0 },
+
 	/* Pass 1b errors */
 
 	/* Pass 1B: Rescan for duplicate/bad blocks */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index f86c531..5b32aeb 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -632,6 +632,9 @@ struct problem_context {
 /* inlinedata/extent set, clear inode */
 #define PR_1_CLEAR_EXTENT_INLINE_DATA_INODE	0x01007A
 
+/* badblocks is in badblocks */
+#define PR_1_BADBLOCKS_IN_BADBLOCKS		0x01007B
+
 /*
  * Pass 1b errors
  */
diff --git a/tests/f_bb_in_bb/expect.1 b/tests/f_bb_in_bb/expect.1
new file mode 100644
index 0000000..1d719e5
--- /dev/null
+++ b/tests/f_bb_in_bb/expect.1
@@ -0,0 +1,17 @@
+Pass 1: Checking inodes, blocks, and sizes
+Bad block list says the bad block list inode is bad.  Clear inode? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Free blocks count wrong for group #0 (493, counted=494).
+Fix? yes
+
+Free blocks count wrong (493, counted=494).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_bb_in_bb/expect.2 b/tests/f_bb_in_bb/expect.2
new file mode 100644
index 0000000..411e656
--- /dev/null
+++ b/tests/f_bb_in_bb/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bb_in_bb/image.gz b/tests/f_bb_in_bb/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..e2c46c09ed2f92070579537d0b03faf9796970dd
GIT binary patch
literal 2414
zcmb2|=3ubDE)c@R{Pxzy>|jR;h7a%K<RfM|G(S)Xo8s3r;pWOCM?DKNVp+@!g}O7A
z=@ni)dGY_DgN_F`mJ}Afd+<mjqwqpghk$<Ndet_KBwgRf@5SHsy}!5jfb7E`@1D9c
z{9k=<ftHfr^E7qWlGpzh=^bX=TNSfy)7_}<7vIC}mwNmzRK1$Jm{0F%ns)t3w>)|K
zoxd_3-<`^T-v4gR*3z=_?;6jl9v_<Be}7(__2);gPe0pv_4@aql0}g{=U(5BIyK*9
z;r=sEcg>e$U~o^E@NeFk)XEwE%Zp>)#lJpwJ3Wkpfq|iK|Gyf^`_K6b?13DEuWbMS
zn=6aHU2%^!!!2;j?W@*%-iwQOS-<`+AG2rgy}i|^HwyvPS*(*ve*Ry-`|3}5Aa91D
zt~ZckIQJh&G<*gbL@bb5_pfuK1W@%1%XtmNYQm!K!|^CV?b~a&?%j0V*4`+k(rx*^
z;-BH4=dXSqf0cWF@D%0mOCNSLM@x0PUzdMi@Kx?v)@I|x|K9d*|JN@z6jT2#?=$tR
z<G;%@r~DTw{Ad2tKT`ZBKNf37g+@bQGz3ONU^E0qLtr!ns1gE~pRg}xmOQ|~puhkC
D<cZO-

literal 0
HcmV?d00001

diff --git a/tests/f_bb_in_bb/name b/tests/f_bb_in_bb/name
new file mode 100644
index 0000000..88727e1
--- /dev/null
+++ b/tests/f_bb_in_bb/name
@@ -0,0 +1 @@
+bad block inode table block in bad block list

  parent reply	other threads:[~2014-09-11 19:44 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-08 23:11 [PATCH 00/25] e2fsprogs Summer 2014 patchbomb, part 5.2 Darrick J. Wong
2014-09-08 23:11 ` [PATCH 01/25] e2fsck/debugfs: fix descriptor block size handling errors with journal_csum Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:11 ` [PATCH 02/25] libext2fs: report bad magic over bad sb checksum Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:11 ` [PATCH 03/25] misc: don't return ENOMEM if we run out of disk space Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 04/25] libext2fs: write_journal_inode should check iterate return value Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 05/25] mke2fs: allow creation of journal device with superblock checksum Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 06/25] e2fsck: detect and repair external journal superblock checksum errors Darrick J. Wong
2014-09-11 16:43   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 07/25] tune2fs: explicitly disallow tuning of journal devices Darrick J. Wong
2014-09-11 16:44   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 08/25] dumpe2fs: display external journal feature flags Darrick J. Wong
2014-09-11 16:44   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 09/25] misc: zero s_jnl_blocks when removing internal journal Darrick J. Wong
2014-09-11 16:44   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 10/25] debugfs: create journal handling routines Darrick J. Wong
2014-09-11 18:53   ` Theodore Ts'o
2014-09-11 19:03     ` Darrick J. Wong
2014-09-11 20:14       ` Theodore Ts'o
2014-09-11 20:25         ` Darrick J. Wong
2014-09-08 23:12 ` [PATCH 11/25] e2fsck: fix minor errors in journal handling Darrick J. Wong
2014-09-11 20:58   ` Theodore Ts'o
2014-09-08 23:12 ` [PATCH 12/25] debugfs: add the ability to write transactions to the journal Darrick J. Wong
2014-09-11 20:58   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 13/25] tests: test writing and recovering checksum-free 32/64bit journals Darrick J. Wong
2014-09-11 20:59   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 14/25] tests: test writing and recovering 64bit csum_v3 journals Darrick J. Wong
2014-09-11 20:59   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 15/25] tests: test writing and recovering 32bit " Darrick J. Wong
2014-09-11 20:59   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 16/25] tests: write and replay blocks with the old journal checksum Darrick J. Wong
2014-09-11 20:59   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 17/25] tests: test recovery of 32 and 64-bit journals with checksum v2 Darrick J. Wong
2014-09-11 20:59   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 18/25] tests: test how e2fsck recovers from corrupt journal superblocks Darrick J. Wong
2014-09-11 21:04   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 19/25] tests: test e2fsck recovery of corrupt revoke blocks Darrick J. Wong
2014-09-11 21:04   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 20/25] tests: test e2fsck recovery with broken commit blocks Darrick J. Wong
2014-09-11 21:04   ` Theodore Ts'o
2014-09-08 23:13 ` [PATCH 21/25] tests: test e2fsck recovery of corrupt descriptor blocks Darrick J. Wong
2014-09-10  1:15   ` Darrick J. Wong
2014-09-11 17:33     ` Darrick J. Wong
2014-09-11 18:18       ` Theodore Ts'o
2014-09-11 18:40         ` Darrick J. Wong
2014-09-11 19:31   ` [PATCH 21/25 v2] " Darrick J. Wong
2014-09-11 22:34     ` Theodore Ts'o
2014-09-08 23:14 ` [PATCH 22/25] tests: test recovery from an external journal Darrick J. Wong
2014-09-11 21:04   ` Theodore Ts'o
2014-09-08 23:14 ` [PATCH 23/25] ext2fs: add readahead method to improve scanning Darrick J. Wong
2014-09-11 21:10   ` Theodore Ts'o
2014-09-11 21:29     ` [PATCH 23/25 v2] " Darrick J. Wong
2014-09-08 23:14 ` [PATCH 24/25] libext2fs/e2fsck: provide routines to read-ahead metadata Darrick J. Wong
2014-09-08 23:14 ` [PATCH 25/25] e2fsck: read-ahead metadata during passes 1, 2, and 4 Darrick J. Wong
2014-09-09 22:53 ` [PATCH 00/25] e2fsprogs Summer 2014 patchbomb, part 5.2 Andreas Dilger
2014-09-10  1:13   ` Darrick J. Wong
2014-09-11 19:41 ` [PATCH 26/25] libext2fs: call get_alloc_block hook when allocating blocks Darrick J. Wong
2014-09-11 22:05   ` Theodore Ts'o
2014-09-11 22:34     ` Darrick J. Wong
2014-09-12 17:35       ` Theodore Ts'o
2014-09-12 17:57         ` Darrick J. Wong
2014-09-12 22:17           ` Theodore Ts'o
2014-09-13  0:13             ` Darrick J. Wong
2014-09-11 19:43 ` [PATCH 27/25] tune2fs: always check disable_uninit_bg() return code Darrick J. Wong
2014-09-11 22:07   ` Theodore Ts'o
2014-09-11 19:44 ` Darrick J. Wong [this message]
2014-09-11 22:09   ` [PATCH 28/25] e2fsck: ignore badblocks if it says badblocks inode is bad Theodore Ts'o
2014-09-11 19:48 ` [PATCH 29/25] e2fsck: expand root dir if linking l+f fails Darrick J. Wong
2014-09-11 22:10   ` Theodore Ts'o
2014-09-11 20:17 ` [PATCH 30/25] libext2fs: check ea value offset when loading Darrick J. Wong
2014-09-11 22:11   ` Theodore Ts'o
2014-09-11 22:33 ` [PATCH 00/25] e2fsprogs Summer 2014 patchbomb, part 5.2 Theodore Ts'o
2014-09-11 22:50   ` Darrick J. Wong
2014-09-11 22:52     ` Theodore Ts'o
2014-09-11 23:07       ` Darrick J. Wong
2014-09-11 23:14         ` Theodore Ts'o
2014-09-11 23:30           ` Darrick J. Wong

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=20140911194449.GT10351@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.