Subject: kern/22797: Downgrading from read-write to read-only causes fs corruption
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jmmv@menta.net>
List: netbsd-bugs
Date: 09/14/2003 23:57:46
>Number:         22797
>Category:       kern
>Synopsis:       Downgrading from read-write to read-only causes fs corruption
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 14 21:59:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Julio M. Merino Vidal
>Release:        NetBSD 1.6ZB
>Organization:
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/
>Environment:
	
	
System: NetBSD dawn.local 1.6ZB NetBSD 1.6ZB (DAWN) #1: Sun Sep 14 18:20:15 CEST 2003 jmmv@dawn.local:/home/NetBSD/obj/home/NetBSD/src/sys/arch/i386/compile/DAWN i386
Architecture: i386
Machine: i386
>Description:
	Downgrading a FFS partition which has softdeps enabled from read-write
	to read-only causes fs corruption after it has had intensive write
	activity.  I haven't tested without softdeps, but I've been pointed
	that there could be the problem.

	Unmounting the partition after the same actions works fine.  I can
	notice how it takes a bit more of time to flush all caches.

>How-To-Repeat:
	Take a FFS partition that has softdeps enabled.

	First, make sure that the filesystem is really clean (i.e, with
	fsck -fy).

	Issue lots of writes to it; I did this building a package from pkgsrc,
	as the partition is holding pkgsrc itself and object directories.

	Inmediately after this, execute "mount -u -o /mount/point".  See how
	the operation finishes inmediately, and the kernel emits a message
	similar to this: /home/NetBSD: update error: blocks 94 files 1

	Now, umount the partition.  You will get this message:
	/home/NetBSD: unmount pending error: blocks -94 files -1

	Run fsck -fy again to cleanup the partition.  Notice how fsck barks
	about filesystem inconsistent state.

	Repeat the same process, but instead of using "mount -u -o ...",
	unmount the partition.  See how it takes a bit more of time and it
	finishes successfully.

>Fix:
	My guess: the kernel should flush all caches before switching the
	filesystem to read only.
>Release-Note:
>Audit-Trail:
>Unformatted: