summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Natano <natano@cvs.openbsd.org>2016-06-19 11:54:35 +0000
committerMartin Natano <natano@cvs.openbsd.org>2016-06-19 11:54:35 +0000
commitb70123aec90044d17f9882033c3f3ac7a1fb78f6 (patch)
tree84f74dc221b666238a94c4435ab5d31c75d67428
parentdf2ea89c9faeef8fb93ba702e7841560708f8a61 (diff)
Remove the lockmgr() API. It is only used by filesystems, where it is a
trivial change to use rrw locks instead. All it needs is LK_* defines for the RW_* flags. tested by naddy and sthen on package building infrastructure input and ok jmc mpi tedu
-rw-r--r--distrib/sets/lists/comp/mi1
-rw-r--r--share/man/man9/Makefile4
-rw-r--r--share/man/man9/VOP_LOOKUP.955
-rw-r--r--share/man/man9/lock.9173
-rw-r--r--share/man/man9/mutex.95
-rw-r--r--share/man/man9/rwlock.98
-rw-r--r--share/man/man9/vnsubr.932
-rw-r--r--sys/isofs/cd9660/cd9660_node.c4
-rw-r--r--sys/isofs/cd9660/cd9660_node.h4
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c4
-rw-r--r--sys/isofs/cd9660/cd9660_vnops.c9
-rw-r--r--sys/isofs/udf/udf.h4
-rw-r--r--sys/isofs/udf/udf_vfsops.c4
-rw-r--r--sys/isofs/udf/udf_vnops.c11
-rw-r--r--sys/kern/kern_lock.c59
-rw-r--r--sys/kern/vfs_subr.c4
-rw-r--r--sys/kern/vfs_vnops.c5
-rw-r--r--sys/miscfs/fuse/fuse_vfsops.c4
-rw-r--r--sys/miscfs/fuse/fuse_vnops.c9
-rw-r--r--sys/msdosfs/denode.h4
-rw-r--r--sys/msdosfs/msdosfs_denode.c4
-rw-r--r--sys/msdosfs/msdosfs_vnops.c9
-rw-r--r--sys/ntfs/ntfs_vfsops.c4
-rw-r--r--sys/sys/lock.h33
-rw-r--r--sys/tmpfs/tmpfs.h4
-rw-r--r--sys/tmpfs/tmpfs_subr.c4
-rw-r--r--sys/tmpfs/tmpfs_vnops.c9
-rw-r--r--sys/ufs/ext2fs/ext2fs_vfsops.c4
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c4
-rw-r--r--sys/ufs/ufs/inode.h4
-rw-r--r--sys/ufs/ufs/ufs_ihash.c6
-rw-r--r--sys/ufs/ufs/ufs_vnops.c9
32 files changed, 146 insertions, 351 deletions
diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi
index 9bc84811cc2..82fcddd22f0 100644
--- a/distrib/sets/lists/comp/mi
+++ b/distrib/sets/lists/comp/mi
@@ -2715,7 +2715,6 @@
./usr/share/man/man9/kthread.9
./usr/share/man/man9/ktrace.9
./usr/share/man/man9/loadfirmware.9
-./usr/share/man/man9/lock.9
./usr/share/man/man9/log.9
./usr/share/man/man9/malloc.9
./usr/share/man/man9/mbuf.9
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index a580ae1d73a..20cfd3248db 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.277 2016/06/17 13:23:21 mglocker Exp $
+# $OpenBSD: Makefile,v 1.278 2016/06/19 11:54:33 natano Exp $
# $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $
# Makefile for section 9 (kernel function and variable) manual pages.
@@ -20,7 +20,7 @@ MAN= aml_evalnode.9 atomic_add_int.9 atomic_cas_uint.9 \
ieee80211_radiotap.9 if_get.9 if_rxr_init.9 ifq_enqueue.9 \
ifq_deq_begin.9 iic.9 intro.9 inittodr.9 intr_barrier.9 \
kern.9 km_alloc.9 knote.9 kthread.9 ktrace.9 \
- loadfirmware.9 lock.9 log.9 \
+ loadfirmware.9 log.9 \
malloc.9 membar_sync.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 \
microtime.9 ml_init.9 mq_init.9 mutex.9 \
namei.9 \
diff --git a/share/man/man9/VOP_LOOKUP.9 b/share/man/man9/VOP_LOOKUP.9
index 773ed80b0b3..b9dfdefc04c 100644
--- a/share/man/man9/VOP_LOOKUP.9
+++ b/share/man/man9/VOP_LOOKUP.9
@@ -1,6 +1,7 @@
-.\" $OpenBSD: VOP_LOOKUP.9,v 1.35 2016/05/23 09:31:28 natano Exp $
+.\" $OpenBSD: VOP_LOOKUP.9,v 1.36 2016/06/19 11:54:33 natano Exp $
.\"
.\" Copyright (c) 2003 Ted Unangst
+.\" Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: May 23 2016 $
+.Dd $Mdocdate: June 19 2016 $
.Dt VOP_LOOKUP 9
.Os
.Sh NAME
@@ -565,17 +566,55 @@ to lock a vnode.
It should not be used by other file system code.
.Fn VOP_UNLOCK
unlocks a vnode.
-.Fn VOP_ISLOCKED
-returns 1 if
-.Fa vp
-is locked and 0 if not.
-It should be used cautiously, as not all file systems implement locks
-effectively.
Note the asymmetry between
.Xr vn_lock 9
and
.Fn VOP_UNLOCK .
.Pp
+.Fa flags
+may contain the following flags:
+.Pp
+.Bl -tag -width LK_RECURSEFAIL -compact -offset indent
+.It Dv LK_EXCLUSIVE
+Acquire an exclusive lock.
+.It Dv LK_SHARED
+Acquire a shared lock.
+.It Dv LK_NOWAIT
+Don't wait if the vnode lock is held by someone else
+(may still wait on reclamation lock).
+.It Dv LK_RECURSEFAIL
+Attempt at recursive lock fails.
+.It Dv LK_DRAIN
+Wait for all activity on the lock to end, then mark it decommissioned.
+This feature is used to ensure that no other activity can occur while the
+underlying object of a vnode is being cleaned out.
+Must be used in combination with
+.Dv LK_EXCLUSIVE .
+.El
+.Pp
+.Fn VOP_ISLOCKED
+returns one of the following values:
+.Pp
+.Bl -tag -width LK_EXCLUSIVE -compact -offset indent
+.It Dv LK_EXCLUSIVE
+.Fa vp
+is locked for exclusive access by the calling thread.
+.It Dv LK_EXCLOTHER
+.Fa vp
+is locked for exclusive access by a different thread.
+.It Dv LK_SHARED
+.Fa vp
+is locked for shared access.
+The current thread may be one of the threads that have it locked.
+.It 0
+.Fa vp
+is not locked.
+.El
+.Pp
+.Fn VOP_ISLOCKED
+should be used cautiously, as not all file systems implement locks
+effectively.
+.Pp
.It Fn VOP_KQFILTER vp kn
Register the
.Xr knote 9
diff --git a/share/man/man9/lock.9 b/share/man/man9/lock.9
deleted file mode 100644
index b22dd54e6bc..00000000000
--- a/share/man/man9/lock.9
+++ /dev/null
@@ -1,173 +0,0 @@
-.\" $OpenBSD: lock.9,v 1.23 2015/01/11 19:34:52 guenther Exp $
-.\" $NetBSD: lock.9,v 1.12 2001/11/01 01:13:43 wiz Exp $
-.\"
-.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd $Mdocdate: January 11 2015 $
-.Dt LOCK 9
-.Os
-.Sh NAME
-.Nm lock ,
-.Nm lockinit ,
-.Nm lockmgr ,
-.Nm lockstatus
-.Nd kernel lock functions
-.Sh SYNOPSIS
-.In sys/lock.h
-.Ft void
-.Fn lockinit "struct lock *lock" "int prio" "const char *wmesg" \
-"int timo" "int flags"
-.Ft int
-.Fn lockmgr "struct lock *lock" "u_int flags" "struct simplelock *slock"
-.Ft int
-.Fn lockstatus "struct lock *lock"
-.Sh DESCRIPTION
-The
-.Nm
-functions provide synchronisation in the kernel by preventing multiple
-processes from simultaneously executing critical sections of code
-accessing shared data.
-.Pp
-struct lock supports sleeping until the lock can be acquired.
-The lock manager supplies both exclusive-access and
-shared-access locks, with recursive exclusive-access locks within a
-single process.
-It also allows upgrading a shared-access lock to an
-exclusive-access lock, as well as downgrading an exclusive-access lock
-to a shared-access lock.
-.Sh FUNCTIONS
-The functions which operate on locks are:
-.Bl -tag -width Ds
-.It Fn lockinit "lock" "prio" "wmesg" "timo" "flags"
-The lock
-.Fa lock
-is initialised according to the parameters provided.
-Arguments are as follows:
-.Pp
-.Bl -tag -width Ds -compact
-.It Fa lock
-The lock.
-.It Fa prio
-The process priority when it is woken up after sleeping on the lock.
-.It Fa wmesg
-A sleep message used when a process goes to sleep waiting for the lock, so
-that the exact reason it is sleeping can easily be identified.
-.It Fa timo
-The maximum sleep time.
-Used by
-.Xr tsleep 9 .
-.It Fa flags
-Flags to specify the lock behaviour permanently over the lifetime of
-the lock.
-Valid lock flags are:
-.Pp
-.Bl -tag -width "LK_CANRECURSEXX" -compact
-.It LK_NOWAIT
-Processes should not sleep when attempting to acquire the lock.
-.It LK_CANRECURSE
-Processes can acquire the lock recursively.
-.El
-.El
-.It Fn lockmgr "lock" "flags" "slock"
-Set, change or release a lock according to the parameters provided.
-Arguments are as follows:
-.Pp
-.Bl -tag -width Ds -compact
-.It Fa lock
-The lock.
-.It Fa flags
-Flags to specify the lock request type.
-In addition to the flags specified above, the following flags are valid:
-.Bl -tag -width Ds
-.It LK_SHARED
-Get one of many possible shared-access locks.
-If a process holding an exclusive-access lock requests a shared-access lock,
-the exclusive-access lock is downgraded to a shared-access lock.
-.It LK_EXCLUSIVE
-Stop further shared-access locks, when they are cleared, grant a
-pending upgrade if it exists, then grant an exclusive-access lock.
-Only one exclusive-access lock may exist at a time, except that a
-process holding an exclusive-access lock may get additional
-exclusive-access locks if it explicitly sets the LK_CANRECURSE flag in
-the lock request, or if the LK_CANRECURSE flag was set when the lock
-was initialised.
-.It LK_RELEASE
-Release one instance of a lock.
-.It LK_DRAIN
-Wait for all activity on the lock to end, then mark it decommissioned.
-This feature is used before freeing a lock that is part of a piece of
-memory that is about to be freed.
-.It LK_RECURSEFAIL
-Attempt at recursive lock fails.
-.El
-.Pp
-.It Fa slock
-This argument exists for legacy reasons, it is now ignored.
-.El
-.It Fn lockstatus "lock"
-Returns the current state of lock
-.Fa lock .
-.Pp
-.Bl -tag -width "LK_EXCLUSIVE" -offset indent -compact
-.It Dv LK_EXCLUSIVE
-Lock is locked for exclusive-access by the calling thread.
-.It Dv LK_EXCLOTHER
-Lock is locked for exclusive-access by a different thread.
-.It Dv LK_SHARED
-Lock is locked for shared-access.
-The current thread may be one of the threads that has it locked.
-.It 0
-Lock is not locked.
-.El
-.El
-.Sh RETURN VALUES
-Successfully acquired locks return 0.
-A failed lock attempt always returns a non-zero error value.
-No lock is held after an error return.
-Locks will always succeed unless one of the following is true:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-LK_NOWAIT is set and a sleep would be required.
-.It Bq Er EINTR
-PCATCH is set in lock priority and a signal arrives to interrupt
-a system call.
-.It Bq Er ERESTART
-PCATCH is set in lock priority and a signal arrives so that
-the system call is restarted.
-.It Bq Er EWOULDBLOCK
-Non-null lock timeout and timeout expires.
-.El
-.Sh SEE ALSO
-.Xr mutex 9 ,
-.Xr pmap 9 ,
-.Xr rwlock 9 ,
-.Xr spl 9 ,
-.Xr tsleep 9 ,
-.Xr uvm 9
-.Sh HISTORY
-The kernel locking API first appeared in
-.Bx 4.4 lite2 .
-It was progressively deprecated in favor of
-.Xr rwlock 9 .
diff --git a/share/man/man9/mutex.9 b/share/man/man9/mutex.9
index 661a74d2e52..abbaac9e91b 100644
--- a/share/man/man9/mutex.9
+++ b/share/man/man9/mutex.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mutex.9,v 1.22 2014/02/13 14:23:05 jmc Exp $
+.\" $OpenBSD: mutex.9,v 1.23 2016/06/19 11:54:33 natano Exp $
.\"
.\" Copyright (c) 2005 Pedro Martelletto <pedro@ambientworks.net>
.\" All rights reserved.
@@ -15,7 +15,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: February 13 2014 $
+.Dd $Mdocdate: June 19 2016 $
.Dt MUTEX 9
.Os
.Sh NAME
@@ -104,7 +104,6 @@ function will return non-zero if it succeeds in acquiring the mutex
.Fa mtxp ,
otherwise it will return 0.
.Sh SEE ALSO
-.Xr lockmgr 9 ,
.Xr msleep 9 ,
.Xr rwlock 9 ,
.Xr spl 9
diff --git a/share/man/man9/rwlock.9 b/share/man/man9/rwlock.9
index 57680476300..46080d7486c 100644
--- a/share/man/man9/rwlock.9
+++ b/share/man/man9/rwlock.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rwlock.9,v 1.17 2014/07/09 18:00:09 jmc Exp $
+.\" $OpenBSD: rwlock.9,v 1.18 2016/06/19 11:54:33 natano Exp $
.\"
.\" Copyright (c) 2006 Pedro Martelletto <pedro@ambientworks.net>
.\" All rights reserved.
@@ -15,7 +15,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: July 9 2014 $
+.Dd $Mdocdate: June 19 2016 $
.Dt RWLOCK 9
.Os
.Sh NAME
@@ -183,8 +183,8 @@ can be called during autoconf, from process context, or from interrupt context.
.Pp
All other functions can be called during autoconf or from process context.
.Sh SEE ALSO
-.Xr lockmgr 9 ,
-.Xr mutex 9
+.Xr mutex 9 ,
+.Xr spl 9
.Sh HISTORY
The
.Nm
diff --git a/share/man/man9/vnsubr.9 b/share/man/man9/vnsubr.9
index 97e54cd9b81..805aeb3c683 100644
--- a/share/man/man9/vnsubr.9
+++ b/share/man/man9/vnsubr.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vnsubr.9,v 1.11 2011/09/03 22:59:07 jmc Exp $
+.\" $OpenBSD: vnsubr.9,v 1.12 2016/06/19 11:54:33 natano Exp $
.\" $NetBSD: vnsubr.9,v 1.21 2004/05/25 14:54:56 hannken Exp $
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: September 3 2011 $
+.Dd $Mdocdate: June 19 2016 $
.Dt VNSUBR 9
.Os
.Sh NAME
@@ -125,23 +125,19 @@ Instead, the
.Xr vget 9
function should be used.
.Pp
-The
+In addition to the
.Fa flags
-argument may contain the following flags:
-.Pp
-.Bl -tag -width LK_EXCLUSIVE -offset indent -compact
-.It Dv LK_RETRY
-Return the vnode even if it has been reclaimed.
-.It Dv LK_NOWAIT
-Don't wait if the vnode lock is held by someone else
-(may still wait on reclamation lock).
-Must not be used with
-.Dv LK_RETRY .
-.It Dv LK_EXCLUSIVE
-Acquire an exclusive lock.
-.It Dv LK_SHARED
-Acquire a shared lock.
-.El
+accepted by
+.Xr VOP_LOCK 9 ,
+the
+.Dv LK_RETRY
+flag may be used.
+.Dv LK_RETRY
+causes
+.Fn vn_lock
+to return the vnode even if it has been reclaimed.
+It must not be used with
+.Dv LK_NOWAIT .
.Pp
The
.Fn vn_lock
diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c
index 5d08d12a5e5..72469a3c77f 100644
--- a/sys/isofs/cd9660/cd9660_node.c
+++ b/sys/isofs/cd9660/cd9660_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_node.c,v 1.30 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: cd9660_node.c,v 1.31 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: cd9660_node.c,v 1.17 1997/05/05 07:13:57 mycroft Exp $ */
/*-
@@ -146,7 +146,7 @@ cd9660_ihashins(ip)
*ipp = ip;
/* XXX locking unlock hash list? */
- lockmgr(&ip->i_lock, LK_EXCLUSIVE, NULL);
+ rrw_enter(&ip->i_lock, RW_WRITE);
return (0);
}
diff --git a/sys/isofs/cd9660/cd9660_node.h b/sys/isofs/cd9660/cd9660_node.h
index 7cec607ed85..b20beb6ddc9 100644
--- a/sys/isofs/cd9660/cd9660_node.h
+++ b/sys/isofs/cd9660/cd9660_node.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_node.h,v 1.19 2013/06/02 01:07:39 deraadt Exp $ */
+/* $OpenBSD: cd9660_node.h,v 1.20 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: cd9660_node.h,v 1.15 1997/04/11 21:52:01 kleink Exp $ */
/*-
@@ -66,7 +66,7 @@ struct iso_node {
doff_t i_diroff; /* offset in dir, where we found last entry */
doff_t i_offset; /* offset of free space in directory */
cdino_t i_ino; /* inode number of found directory */
- struct lock i_lock; /* node lock */
+ struct rrwlock i_lock; /* node lock */
doff_t iso_extent; /* extent of file */
doff_t i_size;
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 2997ffbf4f9..98531665816 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vfsops.c,v 1.79 2016/05/22 20:27:04 bluhm Exp $ */
+/* $OpenBSD: cd9660_vfsops.c,v 1.80 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */
/*-
@@ -771,7 +771,7 @@ retry:
return (error);
}
ip = malloc(sizeof(*ip), M_ISOFSNODE, M_WAITOK | M_ZERO);
- lockinit(&ip->i_lock, PINOD, "isoinode", 0, 0);
+ rrw_init(&ip->i_lock, "isoinode");
vp->v_data = ip;
ip->i_vnode = vp;
ip->i_dev = dev;
diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c
index 771d399633d..99baef6c811 100644
--- a/sys/isofs/cd9660/cd9660_vnops.c
+++ b/sys/isofs/cd9660/cd9660_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vnops.c,v 1.75 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: cd9660_vnops.c,v 1.76 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */
/*-
@@ -696,7 +696,7 @@ cd9660_lock(void *v)
struct vop_lock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, NULL));
+ return rrw_enter(&VTOI(vp)->i_lock, ap->a_flags & LK_RWFLAGS);
}
/*
@@ -708,7 +708,8 @@ cd9660_unlock(void *v)
struct vop_unlock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->i_lock, LK_RELEASE, NULL));
+ rrw_exit(&VTOI(vp)->i_lock);
+ return 0;
}
/*
@@ -772,7 +773,7 @@ cd9660_islocked(void *v)
{
struct vop_islocked_args *ap = v;
- return (lockstatus(&VTOI(ap->a_vp)->i_lock));
+ return rrw_status(&VTOI(ap->a_vp)->i_lock);
}
/*
diff --git a/sys/isofs/udf/udf.h b/sys/isofs/udf/udf.h
index d65d7cdb1b2..f6dc2adc294 100644
--- a/sys/isofs/udf/udf.h
+++ b/sys/isofs/udf/udf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf.h,v 1.20 2014/11/18 10:42:15 dlg Exp $ */
+/* $OpenBSD: udf.h,v 1.21 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -41,7 +41,7 @@ struct unode {
struct vnode *u_vnode;
struct vnode *u_devvp;
struct umount *u_ump;
- struct lock u_lock;
+ struct rrwlock u_lock;
dev_t u_dev;
udfino_t u_ino;
union {
diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c
index c4e2524047b..d776a67a5b5 100644
--- a/sys/isofs/udf/udf_vfsops.c
+++ b/sys/isofs/udf/udf_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf_vfsops.c,v 1.51 2016/05/22 20:27:04 bluhm Exp $ */
+/* $OpenBSD: udf_vfsops.c,v 1.52 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -653,7 +653,7 @@ udf_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
vp->v_data = up;
vref(ump->um_devvp);
- lockinit(&up->u_lock, PINOD, "unode", 0, 0);
+ rrw_init(&up->u_lock, "unode");
/*
* udf_hashins() will lock the vnode for us.
diff --git a/sys/isofs/udf/udf_vnops.c b/sys/isofs/udf/udf_vnops.c
index 926ec8bd792..95fcb12c10e 100644
--- a/sys/isofs/udf/udf_vnops.c
+++ b/sys/isofs/udf/udf_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf_vnops.c,v 1.63 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: udf_vnops.c,v 1.64 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -898,20 +898,19 @@ int
udf_lock(void *v)
{
struct vop_lock_args *ap = v;
-
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOU(vp)->u_lock, ap->a_flags, NULL));
+ return rrw_enter(&VTOU(vp)->u_lock, ap->a_flags & LK_RWFLAGS);
}
int
udf_unlock(void *v)
{
struct vop_unlock_args *ap = v;
-
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOU(vp)->u_lock, LK_RELEASE, NULL));
+ rrw_exit(&VTOU(vp)->u_lock);
+ return 0;
}
int
@@ -919,7 +918,7 @@ udf_islocked(void *v)
{
struct vop_islocked_args *ap = v;
- return (lockstatus(&VTOU(ap->a_vp)->u_lock));
+ return rrw_status(&VTOU(ap->a_vp)->u_lock);
}
int
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index a2f62a1aea6..7edc1b6511c 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.46 2014/09/14 14:17:25 jsg Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.47 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 1995
@@ -45,63 +45,6 @@
int __mp_lock_spinout = 200000000;
#endif
-/*
- * Initialize a lock; required before use.
- */
-void
-lockinit(struct lock *lkp, int prio, char *wmesg, int timo, int flags)
-{
- KASSERT(flags == 0);
-
- memset(lkp, 0, sizeof(struct lock));
- rrw_init(&lkp->lk_lck, wmesg);
-}
-
-int
-lockstatus(struct lock *lkp)
-{
- switch (rrw_status(&lkp->lk_lck)) {
- case RW_WRITE:
- return (LK_EXCLUSIVE);
- case RW_WRITE_OTHER:
- return (LK_EXCLOTHER);
- case RW_READ:
- return (LK_SHARED);
- case 0:
- default:
- return (0);
- }
-}
-
-int
-lockmgr(struct lock *lkp, u_int flags, void *notused)
-{
- int rwflags = 0;
-
- KASSERT(!((flags & (LK_SHARED|LK_EXCLUSIVE)) ==
- (LK_SHARED|LK_EXCLUSIVE)));
- KASSERT(!((flags & (LK_CANRECURSE|LK_RECURSEFAIL)) ==
- (LK_CANRECURSE|LK_RECURSEFAIL)));
- KASSERT((flags & LK_RELEASE) ||
- (flags & (LK_SHARED|LK_EXCLUSIVE|LK_DRAIN)));
-
- if (flags & LK_RELEASE) {
- rrw_exit(&lkp->lk_lck);
- return (0);
- }
- if (flags & LK_SHARED)
- rwflags |= RW_READ;
- if (flags & (LK_EXCLUSIVE|LK_DRAIN))
- rwflags |= RW_WRITE;
- if (flags & LK_RECURSEFAIL)
- rwflags |= RW_RECURSEFAIL;
- if (flags & LK_NOWAIT)
- rwflags |= RW_NOSLEEP;
-
- return (rrw_enter(&lkp->lk_lck, rwflags));
-
-}
-
#if defined(MULTIPROCESSOR)
/*
* Functions for manipulating the kernel_lock. We put them here
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index f81751ca651..7411a924724 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.247 2016/05/26 16:03:29 natano Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.248 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -957,7 +957,7 @@ vclean(struct vnode *vp, int flags, struct proc *p)
* For active vnodes, it ensures that no other activity can
* occur while the underlying object is being cleaned out.
*/
- VOP_LOCK(vp, LK_DRAIN, p);
+ VOP_LOCK(vp, LK_DRAIN | LK_EXCLUSIVE, p);
/*
* Clean out any VM data associated with the vnode.
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 08f5f998d32..374c069cbc2 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.84 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.85 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -513,9 +513,6 @@ vn_lock(struct vnode *vp, int flags, struct proc *p)
{
int error;
- if ((flags & LK_RECURSEFAIL) == 0)
- flags |= LK_CANRECURSE;
-
do {
if (vp->v_flag & VXLOCK) {
vp->v_flag |= VXWANT;
diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c
index dd3b4c9355c..60073bbd0d9 100644
--- a/sys/miscfs/fuse/fuse_vfsops.c
+++ b/sys/miscfs/fuse/fuse_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vfsops.c,v 1.22 2016/05/26 16:03:29 natano Exp $ */
+/* $OpenBSD: fuse_vfsops.c,v 1.23 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -270,7 +270,7 @@ retry:
}
ip = malloc(sizeof(*ip), M_FUSEFS, M_WAITOK | M_ZERO);
- lockinit(&ip->ufs_ino.i_lock, PINOD, "fuseinode", 0, 0);
+ rrw_init(&ip->ufs_ino.i_lock, "fuseinode");
nvp->v_data = ip;
ip->ufs_ino.i_vnode = nvp;
ip->ufs_ino.i_dev = fmp->dev;
diff --git a/sys/miscfs/fuse/fuse_vnops.c b/sys/miscfs/fuse/fuse_vnops.c
index 9f19cc6ebc2..904081da58a 100644
--- a/sys/miscfs/fuse/fuse_vnops.c
+++ b/sys/miscfs/fuse/fuse_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vnops.c,v 1.27 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: fuse_vnops.c,v 1.28 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -1473,7 +1473,7 @@ fusefs_lock(void *v)
struct vop_lock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->ufs_ino.i_lock, ap->a_flags, NULL));
+ return rrw_enter(&VTOI(vp)->ufs_ino.i_lock, ap->a_flags & LK_RWFLAGS);
}
int
@@ -1482,7 +1482,8 @@ fusefs_unlock(void *v)
struct vop_unlock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->ufs_ino.i_lock, LK_RELEASE, NULL));
+ rrw_exit(&VTOI(vp)->ufs_ino.i_lock);
+ return 0;
}
int
@@ -1490,7 +1491,7 @@ fusefs_islocked(void *v)
{
struct vop_islocked_args *ap = v;
- return (lockstatus(&VTOI(ap->a_vp)->ufs_ino.i_lock));
+ return rrw_status(&VTOI(ap->a_vp)->ufs_ino.i_lock);
}
int
diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h
index 0844e7e8c60..e9a142f8834 100644
--- a/sys/msdosfs/denode.h
+++ b/sys/msdosfs/denode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: denode.h,v 1.28 2016/01/13 10:00:55 mpi Exp $ */
+/* $OpenBSD: denode.h,v 1.29 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: denode.h,v 1.24 1997/10/17 11:23:39 ws Exp $ */
/*-
@@ -149,7 +149,7 @@ struct denode {
long de_refcnt; /* reference count */
struct msdosfsmount *de_pmp; /* addr of our mount struct */
struct lockf *de_lockf; /* byte level lock list */
- struct lock de_lock; /* denode lock */
+ struct rrwlock de_lock; /* denode lock */
u_char de_Name[11]; /* name, from DOS directory entry */
u_char de_Attributes; /* attributes, from directory entry */
u_char de_CTimeHundredth; /* creation time, 1/100th of a sec */
diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c
index 1009a8a6795..b3515e6ee54 100644
--- a/sys/msdosfs/msdosfs_denode.c
+++ b/sys/msdosfs/msdosfs_denode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_denode.c,v 1.56 2016/03/19 12:04:16 natano Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.57 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.23 1997/10/17 11:23:58 ws Exp $ */
/*-
@@ -233,7 +233,7 @@ retry:
return (error);
}
ldep = malloc(sizeof(*ldep), M_MSDOSFSNODE, M_WAITOK | M_ZERO);
- lockinit(&ldep->de_lock, PINOD, "denode", 0, 0);
+ rrw_init(&ldep->de_lock, "denode");
nvp->v_data = ldep;
ldep->de_vnode = nvp;
ldep->de_flag = 0;
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index b681887a31f..45a479fb646 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.111 2016/05/21 18:11:36 natano Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.112 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
/*-
@@ -1721,7 +1721,7 @@ msdosfs_lock(void *v)
struct vop_lock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags, NULL));
+ return rrw_enter(&VTODE(vp)->de_lock, ap->a_flags & LK_RWFLAGS);
}
int
@@ -1730,7 +1730,8 @@ msdosfs_unlock(void *v)
struct vop_unlock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTODE(vp)->de_lock, LK_RELEASE, NULL));
+ rrw_exit(&VTODE(vp)->de_lock);
+ return 0;
}
int
@@ -1738,7 +1739,7 @@ msdosfs_islocked(void *v)
{
struct vop_islocked_args *ap = v;
- return (lockstatus(&VTODE(ap->a_vp)->de_lock));
+ return rrw_status(&VTODE(ap->a_vp)->de_lock);
}
/*
diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c
index fedc49d3983..bae57b58da8 100644
--- a/sys/ntfs/ntfs_vfsops.c
+++ b/sys/ntfs/ntfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_vfsops.c,v 1.51 2016/05/22 20:27:04 bluhm Exp $ */
+/* $OpenBSD: ntfs_vfsops.c,v 1.52 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */
/*-
@@ -522,7 +522,7 @@ ntfs_unmount(struct mount *mp, int mntflags, struct proc *p)
ntmp->ntm_devvp->v_specmountpoint = NULL;
/* lock the device vnode before calling VOP_CLOSE() */
- VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY, p);
+ vn_lock(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY, p);
vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
(void)VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
NOCRED, p);
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index f6167c712eb..2388b5955dc 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock.h,v 1.26 2015/09/23 15:37:26 tedu Exp $ */
+/* $OpenBSD: lock.h,v 1.27 2016/06/19 11:54:33 natano Exp $ */
/*
* Copyright (c) 1995
@@ -40,25 +40,16 @@
#include <sys/rwlock.h>
-struct lock {
- struct rrwlock lk_lck;
-};
-
-#define LK_SHARED 0x01 /* shared lock */
-#define LK_EXCLUSIVE 0x02 /* exclusive lock */
-#define LK_TYPE_MASK 0x03 /* type of lock sought */
-#define LK_DRAIN 0x04 /* wait for all lock activity to end */
-#define LK_RELEASE 0x08 /* release any type of lock */
-#define LK_NOWAIT 0x10 /* do not sleep to await lock */
-#define LK_CANRECURSE 0x20 /* allow recursive exclusive lock */
-#define LK_RECURSEFAIL 0x40 /* fail if recursive exclusive lock */
-#define LK_RETRY 0x80 /* vn_lock: retry until locked */
-
-/* for lockstatus() only */
-#define LK_EXCLOTHER 0x100 /* exclusive lock held by some other thread */
-
-void lockinit(struct lock *, int, char *, int, int);
-int lockmgr(struct lock *, u_int flags, void *);
-int lockstatus(struct lock *);
+#define LK_EXCLUSIVE RW_WRITE /* exclusive lock */
+#define LK_SHARED RW_READ /* shared lock */
+#define LK_TYPE_MASK (RW_WRITE|RW_READ) /* type of lock sought */
+#define LK_NOWAIT RW_NOSLEEP /* do not sleep to await lock */
+#define LK_RECURSEFAIL RW_RECURSEFAIL /* fail if recursive exclusive lock */
+#define LK_EXCLOTHER RW_WRITE_OTHER /* exclusive lock held by some other thread */
+#define LK_RWFLAGS (RW_WRITE|RW_READ|RW_NOSLEEP|RW_RECURSEFAIL|RW_WRITE_OTHER)
+
+/* LK_ specific */
+#define LK_DRAIN 0x1000UL /* wait for all lock activity to end */
+#define LK_RETRY 0x2000UL /* vn_lock: retry until locked */
#endif /* !_LOCK_H_ */
diff --git a/sys/tmpfs/tmpfs.h b/sys/tmpfs/tmpfs.h
index 5a98ec48894..8646ca36446 100644
--- a/sys/tmpfs/tmpfs.h
+++ b/sys/tmpfs/tmpfs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs.h,v 1.7 2014/12/17 19:42:15 tedu Exp $ */
+/* $OpenBSD: tmpfs.h,v 1.8 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: tmpfs.h,v 1.45 2011/09/27 01:10:43 christos Exp $ */
/*
@@ -94,7 +94,7 @@ typedef struct tmpfs_node {
* no vnode has been allocated or it has been reclaimed).
*/
struct rwlock tn_nlock; /* node lock */
- struct lock tn_vlock; /* vnode lock */
+ struct rrwlock tn_vlock; /* vnode lock */
struct vnode * tn_vnode;
/* Directory entry. Only a hint, since hard link can have multiple. */
diff --git a/sys/tmpfs/tmpfs_subr.c b/sys/tmpfs/tmpfs_subr.c
index bcbad5ed2b6..9db2a35729e 100644
--- a/sys/tmpfs/tmpfs_subr.c
+++ b/sys/tmpfs/tmpfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_subr.c,v 1.15 2016/02/06 16:10:23 stefan Exp $ */
+/* $OpenBSD: tmpfs_subr.c,v 1.16 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $ */
/*
@@ -314,7 +314,7 @@ again:
return error;
}
- lockinit(&node->tn_vlock, PINOD, "tnode", 0, 0);
+ rrw_init(&node->tn_vlock, "tnode");
vp->v_type = node->tn_type;
/* Type-specific initialization. */
diff --git a/sys/tmpfs/tmpfs_vnops.c b/sys/tmpfs/tmpfs_vnops.c
index 77bed57242e..53408ef281d 100644
--- a/sys/tmpfs/tmpfs_vnops.c
+++ b/sys/tmpfs/tmpfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_vnops.c,v 1.26 2016/05/02 20:06:58 natano Exp $ */
+/* $OpenBSD: tmpfs_vnops.c,v 1.27 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */
/*
@@ -1194,7 +1194,7 @@ tmpfs_lock(void *v)
struct vop_lock_args *ap = v;
tmpfs_node_t *tnp = VP_TO_TMPFS_NODE(ap->a_vp);
- return lockmgr(&tnp->tn_vlock, ap->a_flags, NULL);
+ return rrw_enter(&tnp->tn_vlock, ap->a_flags & LK_RWFLAGS);
}
int
@@ -1203,7 +1203,8 @@ tmpfs_unlock(void *v)
struct vop_unlock_args *ap = v;
tmpfs_node_t *tnp = VP_TO_TMPFS_NODE(ap->a_vp);
- return lockmgr(&tnp->tn_vlock, LK_RELEASE, NULL);
+ rrw_exit(&tnp->tn_vlock);
+ return 0;
}
int
@@ -1212,7 +1213,7 @@ tmpfs_islocked(void *v)
struct vop_islocked_args *ap = v;
tmpfs_node_t *tnp = VP_TO_TMPFS_NODE(ap->a_vp);
- return lockstatus(&tnp->tn_vlock);
+ return rrw_status(&tnp->tn_vlock);
}
/*
diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c
index 12a09b23565..28755660bbe 100644
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_vfsops.c,v 1.92 2016/06/19 10:21:56 dlg Exp $ */
+/* $OpenBSD: ext2fs_vfsops.c,v 1.93 2016/06/19 11:54:33 natano Exp $ */
/* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */
/*
@@ -845,7 +845,7 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
}
ip = pool_get(&ext2fs_inode_pool, PR_WAITOK|PR_ZERO);
- lockinit(&ip->i_lock, PINOD, "inode", 0, 0);
+ rrw_init(&ip->i_lock, "inode");
vp->v_data = ip;
ip->i_vnode = vp;
ip->i_ump = ump;
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 74fac9eed37..20fee3d9773 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vfsops.c,v 1.159 2016/06/19 10:21:56 dlg Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.160 2016/06/19 11:54:34 natano Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
@@ -1295,7 +1295,7 @@ retry:
vp->v_flag |= VLOCKSWORK;
#endif
ip = pool_get(&ffs_ino_pool, PR_WAITOK|PR_ZERO);
- lockinit(&ip->i_lock, PINOD, "inode", 0, 0);
+ rrw_init(&ip->i_lock, "inode");
ip->i_ump = ump;
vref(ip->i_devvp);
vp->v_data = ip;
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index ffa0e5fa4a5..3f2c7081d3c 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.h,v 1.49 2014/07/14 08:54:13 pelikan Exp $ */
+/* $OpenBSD: inode.h,v 1.50 2016/06/19 11:54:34 natano Exp $ */
/* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */
/*
@@ -86,7 +86,7 @@ struct inode {
struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
u_quad_t i_modrev; /* Revision level for NFS lease. */
struct lockf *i_lockf;/* Head of byte-level lock list. */
- struct lock i_lock; /* Inode lock */
+ struct rrwlock i_lock;/* Inode lock */
/*
* Side effects; used during directory lookup.
diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c
index 6b26309fe9a..2421916a58a 100644
--- a/sys/ufs/ufs/ufs_ihash.c
+++ b/sys/ufs/ufs/ufs_ihash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_ihash.c,v 1.22 2015/03/14 03:38:53 jsg Exp $ */
+/* $OpenBSD: ufs_ihash.c,v 1.23 2016/06/19 11:54:34 natano Exp $ */
/* $NetBSD: ufs_ihash.c,v 1.3 1996/02/09 22:36:04 christos Exp $ */
/*
@@ -138,7 +138,7 @@ ufs_ihashins(struct inode *ip)
ufsino_t inum = ip->i_number;
/* lock the inode, then put it on the appropriate hash list */
- lockmgr(&ip->i_lock, LK_EXCLUSIVE, NULL);
+ rrw_enter(&ip->i_lock, RW_WRITE);
/* XXXLOCKING lock hash list */
@@ -146,7 +146,7 @@ ufs_ihashins(struct inode *ip)
LIST_FOREACH(curip, ipp, i_hash) {
if (inum == curip->i_number && dev == curip->i_dev) {
/* XXXLOCKING unlock hash list? */
- lockmgr(&ip->i_lock, LK_RELEASE, NULL);
+ rrw_exit(&ip->i_lock);
return (EEXIST);
}
}
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 7117e6901f4..81c2132e60d 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.127 2016/03/19 12:04:16 natano Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.128 2016/06/19 11:54:34 natano Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -1538,7 +1538,7 @@ ufs_lock(void *v)
struct vop_lock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, NULL));
+ return rrw_enter(&VTOI(vp)->i_lock, ap->a_flags & LK_RWFLAGS);
}
/*
@@ -1550,7 +1550,8 @@ ufs_unlock(void *v)
struct vop_unlock_args *ap = v;
struct vnode *vp = ap->a_vp;
- return (lockmgr(&VTOI(vp)->i_lock, LK_RELEASE, NULL));
+ rrw_exit(&VTOI(vp)->i_lock);
+ return 0;
}
/*
@@ -1561,7 +1562,7 @@ ufs_islocked(void *v)
{
struct vop_islocked_args *ap = v;
- return (lockstatus(&VTOI(ap->a_vp)->i_lock));
+ return rrw_status(&VTOI(ap->a_vp)->i_lock);
}
/*