Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs Tighten some kasserts in ufs_bufio code paths.
details: https://anonhg.NetBSD.org/src/rev/9e8ccd6c46e9
branches: trunk
changeset: 336931:9e8ccd6c46e9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Mar 27 19:47:14 2015 +0000
description:
Tighten some kasserts in ufs_bufio code paths.
diffstat:
sys/ufs/lfs/ulfs_readwrite.c | 5 +++--
sys/ufs/lfs/ulfs_vnops.c | 18 +++++++-----------
sys/ufs/ufs/ufs_readwrite.c | 9 +++++----
sys/ufs/ufs/ufs_vnops.c | 20 +++++++++-----------
4 files changed, 24 insertions(+), 28 deletions(-)
diffs (159 lines):
diff -r 38d7e1ea5ed9 -r 9e8ccd6c46e9 sys/ufs/lfs/ulfs_readwrite.c
--- a/sys/ufs/lfs/ulfs_readwrite.c Fri Mar 27 18:53:15 2015 +0000
+++ b/sys/ufs/lfs/ulfs_readwrite.c Fri Mar 27 19:47:14 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_readwrite.c,v 1.8 2015/03/27 17:27:56 riastradh Exp $ */
+/* $NetBSD: ulfs_readwrite.c,v 1.9 2015/03/27 19:47:14 riastradh Exp $ */
/* from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp */
/*-
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.8 2015/03/27 17:27:56 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.9 2015/03/27 19:47:14 riastradh Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@@ -510,6 +510,7 @@
bool need_unreserve = false;
#endif
+ KASSERT(ISSET(ioflag, IO_NODELOCKED));
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(vp->v_type == VDIR || vp->v_type == VLNK);
KASSERT(vp->v_type != VDIR || ISSET(ioflag, IO_SYNC));
diff -r 38d7e1ea5ed9 -r 9e8ccd6c46e9 sys/ufs/lfs/ulfs_vnops.c
--- a/sys/ufs/lfs/ulfs_vnops.c Fri Mar 27 18:53:15 2015 +0000
+++ b/sys/ufs/lfs/ulfs_vnops.c Fri Mar 27 19:47:14 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_vnops.c,v 1.22 2015/03/27 17:27:56 riastradh Exp $ */
+/* $NetBSD: ulfs_vnops.c,v 1.23 2015/03/27 19:47:14 riastradh Exp $ */
/* from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp */
/*-
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.22 2015/03/27 17:27:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.23 2015/03/27 19:47:14 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -1329,13 +1329,9 @@
struct uio uio;
int error;
- /* XXX Remove me -- all callers should be locked. */
- if (!ISSET(ioflg, IO_NODELOCKED)) {
- if (rw == UIO_READ)
- vn_lock(vp, LK_SHARED | LK_RETRY);
- else /* UIO_WRITE */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- }
+ KASSERT(ISSET(ioflg, IO_NODELOCKED));
+ KASSERT(VOP_ISLOCKED(vp));
+ KASSERT(rw != UIO_WRITE || VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
iov.iov_base = buf;
iov.iov_len = len;
@@ -1362,7 +1358,7 @@
else if (uio.uio_resid && error == 0)
error = EIO;
- if (!ISSET(ioflg, IO_NODELOCKED))
- VOP_UNLOCK(vp);
+ KASSERT(VOP_ISLOCKED(vp));
+ KASSERT(rw != UIO_WRITE || VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
return error;
}
diff -r 38d7e1ea5ed9 -r 9e8ccd6c46e9 sys/ufs/ufs/ufs_readwrite.c
--- a/sys/ufs/ufs/ufs_readwrite.c Fri Mar 27 18:53:15 2015 +0000
+++ b/sys/ufs/ufs/ufs_readwrite.c Fri Mar 27 19:47:14 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_readwrite.c,v 1.108 2015/03/27 17:27:56 riastradh Exp $ */
+/* $NetBSD: ufs_readwrite.c,v 1.109 2015/03/27 19:47:14 riastradh Exp $ */
/*-
* Copyright (c) 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.108 2015/03/27 17:27:56 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.109 2015/03/27 19:47:14 riastradh Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@@ -543,10 +543,13 @@
bool need_unreserve = false;
#endif
+ KASSERT(ISSET(ioflag, IO_NODELOCKED));
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(vp->v_type == VDIR || vp->v_type == VLNK);
KASSERT(vp->v_type != VDIR || ISSET(ioflag, IO_SYNC));
KASSERT(uio->uio_rw == UIO_WRITE);
+ KASSERT(ISSET(ioflag, IO_JOURNALLOCKED));
+ UFS_WAPBL_JLOCK_ASSERT(vp->v_mount);
ip = VTOI(vp);
ump = ip->i_ump;
@@ -573,8 +576,6 @@
error = 0;
KASSERT(vp->v_type != VREG);
- KASSERT(ISSET(ioflag, IO_JOURNALLOCKED));
- UFS_WAPBL_JLOCK_ASSERT(vp->v_mount);
#ifdef LFS_READWRITE
lfs_availwait(fs, btofsb(fs, uio->uio_resid));
diff -r 38d7e1ea5ed9 -r 9e8ccd6c46e9 sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c Fri Mar 27 18:53:15 2015 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c Fri Mar 27 19:47:14 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_vnops.c,v 1.226 2015/03/27 17:27:56 riastradh Exp $ */
+/* $NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.226 2015/03/27 17:27:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -1896,13 +1896,11 @@
struct uio uio;
int error;
- /* XXX Remove me -- all callers should be locked. */
- if (!ISSET(ioflg, IO_NODELOCKED)) {
- if (rw == UIO_READ)
- vn_lock(vp, LK_SHARED | LK_RETRY);
- else /* UIO_WRITE */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- }
+ KASSERT(ISSET(ioflg, IO_NODELOCKED));
+ KASSERT(VOP_ISLOCKED(vp));
+ KASSERT(rw != UIO_WRITE || VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+ KASSERT(rw != UIO_WRITE || vp->v_mount->mnt_wapbl == NULL ||
+ ISSET(ioflg, IO_JOURNALLOCKED));
iov.iov_base = buf;
iov.iov_len = len;
@@ -1929,7 +1927,7 @@
else if (uio.uio_resid && error == 0)
error = EIO;
- if (!ISSET(ioflg, IO_NODELOCKED))
- VOP_UNLOCK(vp);
+ KASSERT(VOP_ISLOCKED(vp));
+ KASSERT(rw != UIO_WRITE || VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
return error;
}
Home |
Main Index |
Thread Index |
Old Index