[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ext4
Subject:    Re: [Ext2-devel] [Fwd: VFS error in dmesg with ext3 htree]
From:       "Theodore Ts'o" <tytso () mit ! edu>
Date:       2002-11-07 21:44:46
[Download RAW message or body]

On Mon, Nov 04, 2002 at 03:24:03PM -0500, Theodore Ts'o wrote:
> On Mon, Nov 04, 2002 at 11:23:43AM -0700, adilger@clusterfs.com wrote:
> > One last question - does reindexing cause e2fsck to exit with a return
> > code of "2", to force a reboot?  Otherwise, the corruption could be
> > caused by dirty in-core directory pages overwriting the on-disk directory
> > that was changed by the reindexing.  Alternately, we could add an ioctl
> > to the ext3 code which forces a full flush of all directory pages in-core
> > so that the kernel is forced to re-read the directories from disk.
> 
> *Any* changes to the root filesystem will result 2 to be logically
> or'ed into the exit code.  (Remember the fsck return codes are a
> bitfield, where FSCK_REBOOT is 2, etc.)  

On further investigation, it turns out I was wrong.  E2fsck isn't
returning exit status 2 at all, due to bug introduced a while back
when checks for mounted filesystems and root filesystems was moved to
a library routine.

Since it may be related to some problems that people have found with
the root filesystem being reindexed, I'll be accelerating the release
of e2fsprogs 1.31, in the meantime I've attached the patch below.

I've checked Debian Woody and Red Hat 7.1, and in both cases, the boot
scripts drop you into single-user mode if fsck returns an exit code >
2.  What they really should do is to automatically reboot if the exit
code is 2 or 3 (i.e. if bit #1 is set, and no higher-order bits
indicating errors are set).  

I'm also thinking, though that the right thing to do is to force a
call to invalidate_buffers() on a read-only->read_write remount, just
as a safety measure. 

						- Ted

# This is a BitKeeper generated patch for the following project:
# Project Name: Ext2 filesystem utilities
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1058  -> 1.1059 
#	    e2fsck/ChangeLog	1.294   -> 1.295  
#	       e2fsck/unix.c	1.69    -> 1.70   
#	     e2fsck/e2fsck.h	1.55    -> 1.56   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/11/07	tytso@think.thunk.org	1.1059
# e2fsck.h, unix.c (main, check_mount): Fix e2fsck so that it
# 	returns the appropriate exit code, so that the boot
# 	scripts will be told that they need to automatically
# 	reboot.
# --------------------------------------------
#
diff -Nru a/e2fsck/ChangeLog b/e2fsck/ChangeLog
--- a/e2fsck/ChangeLog	Thu Nov  7 16:17:07 2002
+++ b/e2fsck/ChangeLog	Thu Nov  7 16:17:07 2002
@@ -1,3 +1,10 @@
+2002-11-07  Theodore Ts'o  <tytso@mit.edu>
+
+	* e2fsck.h, unix.c (main, check_mount): Fix e2fsck so that it
+		returns the appropriate exit code, so that the boot
+		scripts will be told that they need to automatically
+		reboot.
+
 2002-10-31  Theodore Ts'o  <tytso@mit.edu>
 
 	* Release of E2fsprogs 1.30
diff -Nru a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
--- a/e2fsck/e2fsck.h	Thu Nov  7 16:17:07 2002
+++ b/e2fsck/e2fsck.h	Thu Nov  7 16:17:07 2002
@@ -188,6 +188,7 @@
 	blk_t	superblock;	/* sb used to open fs */
 	int	blocksize;	/* blocksize */
 	blk_t	num_blocks;	/* Total number of blocks */
+	int	mount_flags;
 
 #ifdef HAVE_SETJMP_H
 	jmp_buf	abort_loc;
diff -Nru a/e2fsck/unix.c b/e2fsck/unix.c
--- a/e2fsck/unix.c	Thu Nov  7 16:17:07 2002
+++ b/e2fsck/unix.c	Thu Nov  7 16:17:07 2002
@@ -51,9 +51,6 @@
 static int replace_bad_blocks = 0;
 static char *bad_blocks_file = 0;
 
-static int root_filesystem = 0;
-static int read_only_root = 0;
-
 e2fsck_t e2fsck_global_ctx;	/* Try your very best not to use this! */
 
 static void usage(e2fsck_t ctx)
@@ -201,9 +198,10 @@
 static void check_mount(e2fsck_t ctx)
 {
 	errcode_t	retval;
-	int		mount_flags, cont;
+	int		cont;
 
-	retval = ext2fs_check_if_mounted(ctx->filesystem_name, &mount_flags);
+	retval = ext2fs_check_if_mounted(ctx->filesystem_name,
+					 &ctx->mount_flags);
 	if (retval) {
 		com_err("ext2fs_check_if_mount", retval,
 			_("while determining whether %s is mounted."),
@@ -215,9 +213,9 @@
 	 * If the filesystem isn't mounted, or it's the root filesystem
 	 * and it's mounted read-only, then everything's fine.
 	 */
-	if ((!(mount_flags & EXT2_MF_MOUNTED)) ||
-	    ((mount_flags & EXT2_MF_ISROOT) &&
-	     (mount_flags & EXT2_MF_READONLY)))
+	if ((!(ctx->mount_flags & EXT2_MF_MOUNTED)) ||
+	    ((ctx->mount_flags & EXT2_MF_ISROOT) &&
+	     (ctx->mount_flags & EXT2_MF_READONLY)))
 		return;
 
 	if (ctx->options & E2F_OPT_READONLY) {
@@ -1055,7 +1053,7 @@
 		if (!(ctx->options & E2F_OPT_PREEN))
 		    printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
 			       ctx->device_name);
-		if (root_filesystem && !read_only_root) {
+		if (ctx->mount_flags & EXT2_MF_ISROOT) {
 			printf(_("%s: ***** REBOOT LINUX *****\n"),
 			       ctx->device_name);
 			exit_value |= FSCK_REBOOT;


-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Ext2-devel mailing list
Ext2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ext2-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic