linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] dumpe2fs: print journal's s_errno field if it is non-zero
@ 2012-06-01  0:14 Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 2/4] e2fsck: handle an already recovered journal with a non-zero s_error field Theodore Ts'o
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Theodore Ts'o @ 2012-06-01  0:14 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 misc/dumpe2fs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 8f4f2e4..8be5764 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -382,6 +382,9 @@ static void print_inline_journal_information(ext2_filsys fs)
 	       (unsigned int)ntohl(jsb->s_maxlen),
 	       (unsigned int)ntohl(jsb->s_sequence),
 	       (unsigned int)ntohl(jsb->s_start));
+	if (jsb->s_errno != 0)
+		printf(_("Journal errno:            %d\n"),
+		       (int) ntohl(jsb->s_errno));
 }
 
 static void print_journal_information(ext2_filsys fs)
-- 
1.7.10.2.552.gaa3bb87


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

* [PATCH 2/4] e2fsck: handle an already recovered journal with a non-zero s_error field
  2012-06-01  0:14 [PATCH 1/4] dumpe2fs: print journal's s_errno field if it is non-zero Theodore Ts'o
@ 2012-06-01  0:14 ` Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 3/4] tests: add new test to validate errno handling in the journal superblock Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 4/4] tests: fix the e2fsck test script to handle a missing test name Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2012-06-01  0:14 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

If a file system was remounted read-only after a file system
corruption is detected, and then that file system is mounted and
unmounted by the kernel, the journal would have been recovered, but
the kernel currently leaves the s_errno field still set.  This is
arguably a bug, since it has already propgated the non-zero s_errno
field to the file system superblock, where it will be retained until
e2fsck has been run.

However, e2fsck should handle this case for existing kernel by
checking the journal superblock's s_errno field even if journal
recovery is not required.

Without this commit, e2fsck would not notice anything wrong with the
file system, but a subsequent mount of the file system by the kernel
would mark the file system's superblock as needing checking (since the
journal's s_errno field would still be set), resulting an full e2fsck
run at the next reboot, which would find nothing wrong --- and then
when the file system was mounted, the whole cycle would repeat again.

I had seen reports of this in the past, but it wasn't until recently
that I realized exactly how this had come about, since normally e2fsck
would be run automatically before the file system is mounted again,
thus avoiding this problem.  However, a user using a rescue CD who
didn't run e2fsck before mounting the a file system in this condition
could trigger this situation, and unfortunately, with previous
versions of e2fsprogs and the kernel, there would be no way out no
matter what the user tried to do.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 e2fsck/journal.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index bada028..74b506b 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -803,6 +803,19 @@ no_has_journal:
 		 */
 	}
 
+	/*
+	 * If we don't need to do replay the journal, check to see if
+	 * the journal's errno is set; if so, we need to mark the file
+	 * system as being corrupt and clear the journal's s_errno.
+	 */
+	if (!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) &&
+	    journal->j_superblock->s_errno) {
+		ctx->fs->super->s_state |= EXT2_ERROR_FS;
+		ext2fs_mark_super_dirty(ctx->fs);
+		journal->j_superblock->s_errno = 0;
+		mark_buffer_dirty(journal->j_sb_buffer);
+	}
+
 	e2fsck_journal_release(ctx, journal, reset, 0);
 	return retval;
 }
-- 
1.7.10.2.552.gaa3bb87


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

* [PATCH 3/4] tests: add new test to validate errno handling in the journal superblock
  2012-06-01  0:14 [PATCH 1/4] dumpe2fs: print journal's s_errno field if it is non-zero Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 2/4] e2fsck: handle an already recovered journal with a non-zero s_error field Theodore Ts'o
@ 2012-06-01  0:14 ` Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 4/4] tests: fix the e2fsck test script to handle a missing test name Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2012-06-01  0:14 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Add a new regression test f_jnl_errno

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 tests/f_jnl_errno/expect.0 |  48 +++++++++++++++++++++++++++++++++++++++++++++
 tests/f_jnl_errno/expect.1 |   9 +++++++++
 tests/f_jnl_errno/expect.2 |   7 +++++++
 tests/f_jnl_errno/image.gz | Bin 0 -> 8822 bytes
 tests/f_jnl_errno/name     |   1 +
 tests/f_jnl_errno/script   |   4 ++++
 6 files changed, 69 insertions(+)
 create mode 100644 tests/f_jnl_errno/expect.0
 create mode 100644 tests/f_jnl_errno/expect.1
 create mode 100644 tests/f_jnl_errno/expect.2
 create mode 100644 tests/f_jnl_errno/image.gz
 create mode 100644 tests/f_jnl_errno/name
 create mode 100644 tests/f_jnl_errno/script

diff --git a/tests/f_jnl_errno/expect.0 b/tests/f_jnl_errno/expect.0
new file mode 100644
index 0000000..7dae17d
--- /dev/null
+++ b/tests/f_jnl_errno/expect.0
@@ -0,0 +1,48 @@
+
+Filesystem volume name:   <none>
+Last mounted on:          <not available>
+Filesystem magic number:  0xEF53
+Filesystem revision #:    1 (dynamic)
+Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
+Default mount options:    user_xattr acl
+Filesystem state:         clean
+Errors behavior:          Remount read-only
+Filesystem OS type:       Linux
+Inode count:              2048
+Block count:              8192
+Reserved block count:     409
+Free blocks:              6862
+Free inodes:              2037
+First block:              1
+Block size:               1024
+Fragment size:            1024
+Reserved GDT blocks:      31
+Blocks per group:         8192
+Fragments per group:      8192
+Inodes per group:         2048
+Inode blocks per group:   256
+Flex block group size:    16
+Mount count:              0
+Check interval:           0 (<none>)
+Reserved blocks uid:      0
+Reserved blocks gid:      0
+First inode:              11
+Inode size:	          128
+Journal inode:            8
+Default directory hash:   half_md4
+Journal backup:           inode blocks
+Journal features:         (none)
+Journal size:             1024k
+Journal length:           1024
+Journal sequence:         0x00000005
+Journal start:            0
+
+
+Group 0: (Blocks 1-8191) [ITABLE_ZEROED]
+  Primary superblock at 1, Group descriptors at 2-2
+  Reserved GDT blocks at 3-33
+  Block bitmap at 34 (+33), Inode bitmap at 50 (+49)
+  Inode table at 66-321 (+65)
+  6862 free blocks, 2037 free inodes, 2 directories, 2037 unused inodes
+  Free blocks: 1330-8191
+  Free inodes: 12-2048
diff --git a/tests/f_jnl_errno/expect.1 b/tests/f_jnl_errno/expect.1
new file mode 100644
index 0000000..c572951
--- /dev/null
+++ b/tests/f_jnl_errno/expect.1
@@ -0,0 +1,9 @@
+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: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/2048 files (9.1% non-contiguous), 1330/8192 blocks
+Exit status is 1
diff --git a/tests/f_jnl_errno/expect.2 b/tests/f_jnl_errno/expect.2
new file mode 100644
index 0000000..db16a75
--- /dev/null
+++ b/tests/f_jnl_errno/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/2048 files (9.1% non-contiguous), 1330/8192 blocks
+Exit status is 0
diff --git a/tests/f_jnl_errno/image.gz b/tests/f_jnl_errno/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..c55c775d165fe024592a33fe52e873fbab599459
GIT binary patch
literal 8822
zc-oWi=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`300FAMMcmMzZ

literal 0
Hc-jL100001

diff --git a/tests/f_jnl_errno/name b/tests/f_jnl_errno/name
new file mode 100644
index 0000000..e5f64d6
--- /dev/null
+++ b/tests/f_jnl_errno/name
@@ -0,0 +1 @@
+journal s_errno handling
diff --git a/tests/f_jnl_errno/script b/tests/f_jnl_errno/script
new file mode 100644
index 0000000..dd1ffd6
--- /dev/null
+++ b/tests/f_jnl_errno/script
@@ -0,0 +1,4 @@
+AFTER_CMD='$DUMPE2FS $TMPFILE 2>&1 | sed -f $cmd_dir/filter_dumpe2fs > $test_name.0.log'
+PASS_ZERO=true
+
+. $cmd_dir/run_e2fsck
-- 
1.7.10.2.552.gaa3bb87


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

* [PATCH 4/4] tests: fix the e2fsck test script to handle a missing test name
  2012-06-01  0:14 [PATCH 1/4] dumpe2fs: print journal's s_errno field if it is non-zero Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 2/4] e2fsck: handle an already recovered journal with a non-zero s_error field Theodore Ts'o
  2012-06-01  0:14 ` [PATCH 3/4] tests: add new test to validate errno handling in the journal superblock Theodore Ts'o
@ 2012-06-01  0:14 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2012-06-01  0:14 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 tests/run_e2fsck | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tests/run_e2fsck b/tests/run_e2fsck
index 937a171..ab623e8 100644
--- a/tests/run_e2fsck
+++ b/tests/run_e2fsck
@@ -82,12 +82,23 @@ if [ "$SKIP_VERIFY" != "true" ] ; then
 		status3=0
 	fi
 
+	if [ -z "$test_description" ] ; then
+		description="$test_name"
+	else
+		description="$test_name: $test_description"
+	fi
+
 	if [ "$status1" -eq 0 -a "$status2" -eq 0 -a "$status3" -eq 0 ] ; then
-		echo "$test_name: $test_description: ok"
+		echo "$description: ok"
 		touch $test_name.ok
 	else
-		echo "$test_name: $test_description: failed"
-		diff $DIFF_OPTS $EXP1 $OUT1 > $test_name.failed
+		echo "$description: failed"
+		rm -f $test_name.failed
+		if [ "$PASS_ZERO" = "true" ]; then
+			diff $DIFF_OPTS $test_dir/expect.0 \
+				$test_name.0.log >> $test_name.failed
+		fi
+		diff $DIFF_OPTS $EXP1 $OUT1 >> $test_name.failed
 		if [ "$ONE_PASS_ONLY" != "true" ]; then
 			diff $DIFF_OPTS $EXP2 $OUT2 >> $test_name.failed
 		fi
-- 
1.7.10.2.552.gaa3bb87


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

end of thread, other threads:[~2012-06-01  0:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-01  0:14 [PATCH 1/4] dumpe2fs: print journal's s_errno field if it is non-zero Theodore Ts'o
2012-06-01  0:14 ` [PATCH 2/4] e2fsck: handle an already recovered journal with a non-zero s_error field Theodore Ts'o
2012-06-01  0:14 ` [PATCH 3/4] tests: add new test to validate errno handling in the journal superblock Theodore Ts'o
2012-06-01  0:14 ` [PATCH 4/4] tests: fix the e2fsck test script to handle a missing test name Theodore 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).