Subject: Re: install/25138: 2.0: sysinst upgrade broken: fsck_ffs bails out
To: Hubert Feyrer <hubert@feyrer.de>
From: Darrin B. Jewell <dbj@netbsd.org>
List: netbsd-bugs
Date: 04/12/2004 04:18:13
--=-=-=


I'm working on support to downgrade a superblock from fslevel 4 to 3
using fsck.  I include below a lightly tested patch which will do
that.  Before I commit this patch, there needs to be some additional
testing to verify that a filesystem created on 2.0 and downgraded with
this option will work on 1.6.2 and 2.0 without problems.

I also plan to create a simple shell script test for the existence of
the botched superblock problem.

With the addition of this patch and such a shell script, it should be
possible to automate the fix for the botched superblock problem by
adding an rc.d script which checks for the superblock problem and then
which does a "fsck_ffs -b 16 -c 4" followed by a "fsck_ffs -c 3"

This should both solve complaints that a manual intervention
on upgrade is `too complicated' and should also provide a safe upgrade
path for users who need to upgrade their systems without console
access.

Darrin


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=pr25138.diff
Content-Description: patch to downgrade superblock

Index: src/sbin/fsck_ffs/main.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/main.c,v
retrieving revision 1.49
diff -u -u -p -r1.49 main.c
--- src/sbin/fsck_ffs/main.c	17 Jan 2004 22:17:07 -0000	1.49
+++ src/sbin/fsck_ffs/main.c	12 Apr 2004 07:54:21 -0000
@@ -337,7 +337,10 @@ checkfilesys(filesys, mntpt, auxdata, ch
 	muldup = (struct dups *)0;
 	inocleanup();
 	if (fsmodified) {
-		sblock->fs_time = time(NULL);
+		if (!is_ufs2 && (sblock->fs_old_flags & FS_FLAGS_UPDATED) == 0)
+			sblock->fs_old_time = time(NULL);
+		else
+			sblock->fs_time = time(NULL);
 		sbdirty();
 	}
 	if (rerun)
Index: src/sbin/fsck_ffs/setup.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/setup.c,v
retrieving revision 1.70
diff -u -u -p -r1.70 setup.c
--- src/sbin/fsck_ffs/setup.c	21 Mar 2004 20:01:41 -0000	1.70
+++ src/sbin/fsck_ffs/setup.c	12 Apr 2004 07:54:22 -0000
@@ -198,6 +198,16 @@ setup(dev)
 		 */
 		sbdirty();
 	}
+	if (!is_ufs2 && cvtlevel == 3 &&
+	    (sblock->fs_old_flags & FS_FLAGS_UPDATED)) {
+		if (preen)
+			pwarn("DOWNGRADING TO OLD SUPERBLOCK LAYOUT\n");
+		else if (!reply("DOWNGRADE TO OLD SUPERBLOCK LAYOUT"))
+			return(0);
+		sblock->fs_old_flags = sblock->fs_flags;
+		sblock->fs_old_flags &= ~FS_FLAGS_UPDATED; /* just in case */
+		sbdirty();
+	}
 	/*
 	 * Check and potentially fix certain fields in the super block.
 	 */
Index: src/sbin/fsck_ffs/utilities.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/utilities.c,v
retrieving revision 1.45
diff -u -u -p -r1.45 utilities.c
--- src/sbin/fsck_ffs/utilities.c	15 Jan 2004 14:52:04 -0000	1.45
+++ src/sbin/fsck_ffs/utilities.c	12 Apr 2004 07:54:23 -0000
@@ -733,7 +733,8 @@ void
 sb_oldfscompat_write(struct fs *fs, struct fs *fssave)
 {
 	if ((fs->fs_magic != FS_UFS1_MAGIC) ||
-	    (fs->fs_old_flags & FS_FLAGS_UPDATED))
+	    (fs->fs_old_flags & FS_FLAGS_UPDATED) ||
+	    !fssave)
 		return;
 
 	fs->fs_old_flags = fs->fs_flags;

--=-=-=--