Subject: ffs compat problem since ffs2
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 09/06/2003 00:30:26
Hi,
since ffsv2 was introduced, we have a problem where an old NetBSD kernel
fails to use filesystems which have been mounted R/W by a new kernel (PR 21283)
I tracked this down to the new kernel setting the FS_FLAGS_UPDATED flag
in the superblock, which unfortunably happens to be the old FS_SWAPPED flag.
And old kernel will keep this flag after mount, and swap the filesystem
when it shouldn't.

I agree that the (old) kernel should have filtered this flag at mount time,
but unfortunably it doesn't and it's too late to fix it. This is a real
backward-compat problem which can cause damage to users (start a sysinst
boot floppy, start upgrade, change your mind, bummer! now your old
kernel can't use its root any more !).
This needs to be fixed in current.

One obvious way of doing it would be to change FS_FLAGS_UPDATED to 0x40,
but this will likely cause compat problems with the others BSDs.

FS_FLAGS_UPDATED is used to tell the kernel that the superblock has been
updated to the new world. It's used in 3 places:
- ffs_mountfs():
                if ((fsblockloc == sblockloc ||
		     (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0)
		      && sbsize <= MAXBSIZE && sbsize >= sizeof(struct fs))
  If I read it properly, we always have fsblockloc == sblockloc for
  FS_UFS1_MAGIC filesystems, so we could check FS_FLAGS_UPDATED for v2
  filesystems only.
- ffs_oldfscompat_read():
  we could probably move it under the
  if (fs->fs_maxbsize != fs->fs_bsize || fs->fs_time < fs->fs_old_time) 
  check. We probably want to update the flags anyway if the filesystem
  was mounted R/W by an old kernel (maybe fs->fs_flags |= fs->fs_old_flags
  instead of =, and clear any new flags if fs->fs_maxbsize != fs->fs_bsize) ?
- ffs_sbupdate(): update fs_sblockloc. Unless I missed something,
  this should already have been done by ffs_oldfscompat_read() ?

So it looks like we don't need to set FS_FLAGS_UPDATED for v1 filesystem on
NetBSD. But unfortunably, not doing this may cause compatibility problems with
others BSD.

I think we could remove checks of FS_FLAGS_UPDATED in our kernel, and
not set FS_FLAGS_UPDATED if we're not using any of the new features
(basically, if fs->fs_flags contains only FS_UNCLEAN and FS_DOSOFTDEP)

comments ?

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 24 ans d'experience feront toujours la difference
--