diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-07-12 14:02:24 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-07-12 14:02:24 +0000 |
commit | fc0c3858775ac2805ca1e604eac6b1c34c8f1126 (patch) | |
tree | 27b1a821f0e91305aae45eeffa7af2783a946912 /sys/ufs/mfs | |
parent | 9676a33b97bb57b158d7b6405e512396ad9107d8 (diff) |
Change the locking on the mountpoint slightly. Instead of using mnt_lock
to get shared locks for lookup and get the exclusive lock only with
LK_DRAIN on unmount and do the real exclusive locking with flags in
mnt_flags, we now use shared locks for lookup and an exclusive lock for
unmount.
This is accomplished by slightly changing the semantics of vfs_busy.
Old vfs_busy behavior:
- with LK_NOWAIT set in flags, a shared lock was obtained if the
mountpoint wasn't being unmounted, otherwise we just returned an error.
- with no flags, a shared lock was obtained if the mountpoint was being
unmounted, otherwise we slept until the unmount was done and returned
an error.
LK_NOWAIT was used for sync(2) and some statistics code where it isn't really
critical that we get the correct results.
0 was used in fchdir and lookup where it's critical that we get the right
directory vnode for the filesystem root.
After this change vfs_busy keeps the same behavior for no flags and LK_NOWAIT.
But if some other flags are passed into it, they are passed directly
into lockmgr (actually LK_SLEEPFAIL is always added to those flags because
if we sleep for the lock, that means someone was holding the exclusive lock
and the exclusive lock is only held when the filesystem is being unmounted.
More changes:
dounmount must now be called with the exclusive lock held. (before this
the caller was supposed to hold the vfs_busy lock, but that wasn't always
true).
Zap some (now) unused mount flags.
And the highlight of this change:
Add some vfs_busy calls to match some vfs_unbusy calls, especially in
sys_mount. (lockmgr doesn't detect the case where we release a lock noone
holds (it will do that soon)).
If you've seen hangs on reboot with mfs this should solve it (I repeat this
for the fourth time now, but this time I spent two months fixing and
redesigning this and reading the code so this time I must have gotten
this right).
Diffstat (limited to 'sys/ufs/mfs')
-rw-r--r-- | sys/ufs/mfs/mfs_vfsops.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index 9892a6dbade..e9e6a7013e8 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfs_vfsops.c,v 1.21 2002/06/21 00:40:08 art Exp $ */ +/* $OpenBSD: mfs_vfsops.c,v 1.22 2002/07/12 14:02:23 art Exp $ */ /* $NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $ */ /* @@ -258,10 +258,10 @@ mfs_start(mp, flags, p) int flags; struct proc *p; { - register struct vnode *vp = VFSTOUFS(mp)->um_devvp; - register struct mfsnode *mfsp = VTOMFS(vp); - register struct buf *bp; - register caddr_t base; + struct vnode *vp = VFSTOUFS(mp)->um_devvp; + struct mfsnode *mfsp = VTOMFS(vp); + struct buf *bp; + caddr_t base; int sleepreturn = 0; base = mfsp->mfs_baseoff; @@ -278,7 +278,7 @@ mfs_start(mp, flags, p) * EINTR/ERESTART. */ if (sleepreturn != 0) { - if (vfs_busy(mp, LK_NOWAIT, NULL, p) || + if (vfs_busy(mp, LK_EXCLUSIVE|LK_NOWAIT, NULL, p) || dounmount(mp, 0, p)) CLRSIG(p, CURSIG(p)); sleepreturn = 0; |