Subject: CVS commit: syssrc
To: None <>
From: Bill Sommerfeld <>
List: source-changes
Date: 07/04/1999 09:20:15
Module Name:	syssrc
Committed By:	sommerfeld
Date:		Sun Jul  4 16:20:14 UTC 1999

Modified Files:
	syssrc/sys/kern: vfs_subr.c vfs_syscalls.c
	syssrc/sys/sys: mount.h

Log Message:
Fix kern/7906: race between unmount and getnewvnode()

mp->mnt_flags & MNT_MWAIT is replaced by mp->mnt_wcnt, and a new mount
flag MNT_GONE is created (reusing the same bit).

In insmntque(), add DIAGNOSTIC check to fail if the filesystem vnode
is being moved to is in the process of being unmounted.

getnewvnode() now protects the list of vnodes active on mp with

To avoid generating spurious errors during a doomed unmount, change
the "wait for unmount to finish" protocol between dounmount() and
vfs_busy().  In vfs_busy(), instead of only sleeping once, sleep until
either MNT_UNMOUNT is clear or MNT_GONE is set; also, maintain a count
of waiters in mp->mnt_wcnt so that dounmount() knows when it's safe to
free mp.

tested by running a "while :; do mount /d1; umount -f /d1; done" loop
against multiple find(1) processes.

To generate a diff of this commit:
cvs rdiff -r1.102 -r1.103 syssrc/sys/kern/vfs_subr.c
cvs rdiff -r1.141 -r1.142 syssrc/sys/kern/vfs_syscalls.c
cvs rdiff -r1.76 -r1.77 syssrc/sys/sys/mount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.