diff options
-rw-r--r-- | sys/kern/vfs_syscalls.c | 13 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vfsops.c | 41 |
2 files changed, 10 insertions, 44 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index ff4864b0345..50bb7cba61c 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.59 1999/07/30 18:27:47 deraadt Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.60 1999/12/06 07:28:06 art Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -412,6 +412,10 @@ sys_unmount(p, v, retval) return (EINVAL); } vput(vp); + + if (vfs_busy(mp, 0, NULL, p)) + return (EBUSY); + return (dounmount(mp, SCARG(uap, flags), p)); } @@ -428,13 +432,8 @@ dounmount(mp, flags, p) int error; simple_lock(&mountlist_slock); - if (mp->mnt_flag & MNT_UNMOUNT) { - mp->mnt_flag |= MNT_MWAIT; - simple_unlock(&mountlist_slock); - sleep(mp, PVFS); - return ENOENT; - } mp->mnt_flag |= MNT_UNMOUNT; + vfs_unbusy(mp, p); lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock, p); mp->mnt_flag &=~ MNT_ASYNC; #if !defined(UVM) diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index 36989eab1fb..9f784417eb0 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.10 1999/10/15 15:16:13 art Exp $ */ +/* $OpenBSD: mfs_vfsops.c,v 1.11 1999/12/06 07:28:06 art Exp $ */ /* $NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $ */ /* @@ -66,9 +66,6 @@ static int mfs_minor; /* used for building internal dev_t */ extern int (**mfs_vnodeop_p) __P((void *)); -int mfs_dounmount __P((struct mount *)); -void mfs_dounmount1 __P((void *)); - /* * mfs vfs operations. */ @@ -276,8 +273,9 @@ mfs_start(mp, flags, p) * EINTR/ERESTART. */ if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0)) { - mfs_dounmount(mp); - CLRSIG(p, CURSIG(p)); + if (vfs_busy(mp, LK_NOWAIT, NULL, p) || + dounmount(mp, 0, p)) + CLRSIG(p, CURSIG(p)); } } return (0); @@ -301,34 +299,3 @@ mfs_statfs(mp, sbp, p) &sbp->mount_info.mfs_args, sizeof(struct mfs_args)); return (error); } - -/* - * Spawn off a kernel thread to do the unmounting to avoid all deadlocks. - * XXX - this is horrible, but it was the only sane thing to do. - */ -int -mfs_dounmount(mp) - struct mount *mp; -{ - if (kthread_create(mfs_dounmount1, (void *)mp, NULL, "mfs_unmount")) - return 1; - - return 0; -} - -void -mfs_dounmount1(v) - void *v; -{ - struct mount *mp = v; - - /* - * Don't try to do the unmount if someone else is trying to do that. - * XXX - should be done with vfs_busy, but the problem is that - * we can't pass a locked mp into dounmount. - */ - if (!(mp->mnt_flag & MNT_UNMOUNT)) - dounmount(mp, 0, curproc); - - kthread_exit(0); -} |