summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-06-04 04:57:09 +0000
committerguenther <guenther@openbsd.org>2018-06-04 04:57:09 +0000
commit55a0321d8c4376228903e66f1234c4e4ecd1f9b6 (patch)
tree132ff03ec64cf6a93a7e4beb9939508d7b2fc34c
parent...and correct the count at which warning normally occurs (diff)
downloadwireguard-openbsd-55a0321d8c4376228903e66f1234c4e4ecd1f9b6.tar.xz
wireguard-openbsd-55a0321d8c4376228903e66f1234c4e4ecd1f9b6.zip
Add VB_DUPOK to suppress witness(4) warning of concurrent mount locks.
Use that in three places: - vfs_stall() - sys_mount() - dounmount()'s MNT_FORCE-does-recursive-unmounts case ok deraadt@ visa@
-rw-r--r--share/man/man9/vfs_busy.99
-rw-r--r--sys/kern/vfs_subr.c9
-rw-r--r--sys/kern/vfs_syscalls.c6
-rw-r--r--sys/sys/mount.h3
4 files changed, 19 insertions, 8 deletions
diff --git a/share/man/man9/vfs_busy.9 b/share/man/man9/vfs_busy.9
index a468452e26e..1b6536ea7af 100644
--- a/share/man/man9/vfs_busy.9
+++ b/share/man/man9/vfs_busy.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vfs_busy.9,v 1.2 2007/05/31 19:20:01 jmc Exp $
+.\" $OpenBSD: vfs_busy.9,v 1.3 2018/06/04 04:57:09 guenther Exp $
.\"
.\" Copyright (c) 2006 Nikolay Sturm <sturm@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: June 4 2018 $
.Dt VFS_BUSY 9
.Os
.Sh NAME
@@ -58,6 +58,10 @@ Acquire a write lock.
Return immediately; do not wait for the conflicting lock to be released.
.It VB_WAIT
Wait for the conflicting lock to be released.
+.It VB_DUPOK
+Prevent
+.Xr witness 4
+from logging when this thread already has a mount point locked.
.El
.Pp
If a conflicting lock was encountered,
@@ -76,5 +80,6 @@ The
API is implemented in the file
.Pa sys/kern/vfs_subr.c .
.Sh SEE ALSO
+.Xr witness 4 ,
.Xr rwlock 9 ,
.Xr vfs 9
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index ac6231d0b5f..30e763399cc 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.273 2018/05/27 06:02:14 visa Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.274 2018/06/04 04:57:09 guenther Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
else
rwflags |= RW_NOSLEEP;
+#ifdef WITNESS
+ if (flags & VB_DUPOK)
+ rwflags |= RW_DUPOK;
+#endif
+
if (rw_enter(&mp->mnt_lock, rwflags))
return (EBUSY);
@@ -1602,7 +1607,7 @@ vfs_stall(struct proc *p, int stall)
*/
TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) {
if (stall) {
- error = vfs_busy(mp, VB_WRITE|VB_WAIT);
+ error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
if (error) {
printf("%s: busy\n", mp->mnt_stat.f_mntonname);
allerror = error;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 7a0571e1353..3c1e28e196a 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.284 2018/06/02 10:27:43 mpi Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.285 2018/06/04 04:57:09 guenther Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -230,7 +230,7 @@ sys_mount(struct proc *p, void *v, register_t *retval)
update:
/* Ensure that the parent mountpoint does not get unmounted. */
- error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT);
+ error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT|VB_DUPOK);
if (error) {
if (mp->mnt_flag & MNT_UPDATE) {
mp->mnt_flag = mntflag;
@@ -439,7 +439,7 @@ dounmount(struct mount *mp, int flags, struct proc *p)
error = EBUSY;
goto err;
}
- error = vfs_busy(mp, VB_WRITE|VB_WAIT);
+ error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
if (error) {
if ((flags & MNT_DOOMED)) {
/*
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index 942cb8c8924..2148f7c0449 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount.h,v 1.136 2018/05/08 08:58:49 mpi Exp $ */
+/* $OpenBSD: mount.h,v 1.137 2018/06/04 04:57:09 guenther Exp $ */
/* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */
/*
@@ -564,6 +564,7 @@ int vfs_busy(struct mount *, int);
#define VB_WRITE 0x02
#define VB_NOWAIT 0x04 /* immediately fail on busy lock */
#define VB_WAIT 0x08 /* sleep fail on busy lock */
+#define VB_DUPOK 0x10 /* permit duplicate mount busying */
int vfs_isbusy(struct mount *);
int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,