svn commit: r209556 - in stable/8/sys: fs/nfsclient fs/nfsserver
nfsclient
Konstantin Belousov
kib at FreeBSD.org
Mon Jun 28 01:16:35 UTC 2010
Author: kib
Date: Mon Jun 28 01:16:34 2010
New Revision: 209556
URL: http://svn.freebsd.org/changeset/base/209556
Log:
MFC r209120:
In NFS clients, instead of inconsistently using #ifdef
DIAGNOSTIC and #ifndef DIAGNOSTIC for debug assertions, prefer
KASSERT(). Also change one #ifdef DIAGNOSTIC in the new nfs server.
Modified:
stable/8/sys/fs/nfsclient/nfs_clbio.c
stable/8/sys/fs/nfsclient/nfs_clcomsubs.c
stable/8/sys/fs/nfsclient/nfs_clrpcops.c
stable/8/sys/fs/nfsclient/nfs_clsubs.c
stable/8/sys/fs/nfsclient/nfs_clvnops.c
stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c
stable/8/sys/nfsclient/nfs_bio.c
stable/8/sys/nfsclient/nfs_subs.c
stable/8/sys/nfsclient/nfs_vnops.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clbio.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsclient/nfs_clbio.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -449,10 +449,7 @@ ncl_bioread(struct vnode *vp, struct uio
int seqcount;
int nra, error = 0, n = 0, on = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("ncl_read mode");
-#endif
+ KASSERT(uio->uio_rw == UIO_READ, ("ncl_read mode"));
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */
@@ -878,12 +875,9 @@ ncl_write(struct vop_write_args *ap)
int n, on, error = 0;
struct proc *p = td?td->td_proc:NULL;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("ncl_write mode");
- if (uio->uio_segflg == UIO_USERSPACE && uio->uio_td != curthread)
- panic("ncl_write proc");
-#endif
+ KASSERT(uio->uio_rw == UIO_WRITE, ("ncl_write mode"));
+ KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread,
+ ("ncl_write proc"));
if (vp->v_type != VREG)
return (EIO);
mtx_lock(&np->n_mtx);
Modified: stable/8/sys/fs/nfsclient/nfs_clcomsubs.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clcomsubs.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsclient/nfs_clcomsubs.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -194,10 +194,7 @@ nfsm_uiombuf(struct nfsrv_descript *nd,
int uiosiz, clflg, rem;
char *cp, *tcp;
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfsm_uiotombuf: iovcnt != 1");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1"));
if (siz > ncl_mbuf_mlen) /* or should it >= MCLBYTES ?? */
clflg = 1;
@@ -346,10 +343,7 @@ nfscl_getcookie(struct nfsnode *np, off_
pos = off / NFS_DIRBLKSIZ;
if (pos == 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at 0");
-#endif
+ KASSERT(!add, ("nfs getcookie add at 0"));
return (&nfs_nullcookie);
}
pos--;
Modified: stable/8/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clrpcops.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsclient/nfs_clrpcops.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -1452,10 +1452,7 @@ nfsrpc_writerpc(vnode_t vp, struct uio *
struct nfsrv_descript *nd = &nfsd;
nfsattrbit_t attrbits;
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfs: writerpc iovcnt > 1");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1, ("nfs: writerpc iovcnt > 1"));
*attrflagp = 0;
tsiz = uio_uio_resid(uiop);
NFSLOCKMNT(nmp);
@@ -2508,10 +2505,9 @@ nfsrpc_readdir(vnode_t vp, struct uio *u
u_int32_t *tl2 = NULL;
size_t tresid;
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uio_uio_resid(uiop) & (DIRBLKSIZ - 1)))
- panic("nfs readdirrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uio_uio_resid(uiop) & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirrpc bad uio"));
/*
* There is no point in reading a lot more than uio_resid, however
@@ -2946,10 +2942,9 @@ nfsrpc_readdirplus(vnode_t vp, struct ui
size_t tresid;
u_int32_t *tl2 = NULL, fakefileno = 0xffffffff, rderr;
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uio_uio_resid(uiop) & (DIRBLKSIZ - 1)))
- panic("nfs readdirplusrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uio_uio_resid(uiop) & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirplusrpc bad uio"));
*attrflagp = 0;
if (eofp != NULL)
*eofp = 0;
Modified: stable/8/sys/fs/nfsclient/nfs_clsubs.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clsubs.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsclient/nfs_clsubs.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -282,10 +282,7 @@ ncl_getcookie(struct nfsnode *np, off_t
pos = (uoff_t)off / NFS_DIRBLKSIZ;
if (pos == 0 || off < 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at <= 0");
-#endif
+ KASSERT(!add, ("nfs getcookie add at <= 0"));
return (&nfs_nullcookie);
}
pos--;
@@ -336,10 +333,7 @@ ncl_invaldir(struct vnode *vp)
{
struct nfsnode *np = VTONFS(vp);
-#ifdef DIAGNOSTIC
- if (vp->v_type != VDIR)
- panic("nfs: invaldir not dir");
-#endif
+ KASSERT(vp->v_type == VDIR, ("nfs: invaldir not dir"));
ncl_dircookie_lock(np);
np->n_direofoffset = 0;
np->n_cookieverf.nfsuquad[0] = 0;
Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clvnops.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsclient/nfs_clvnops.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -1564,12 +1564,8 @@ nfs_remove(struct vop_remove_args *ap)
int error = 0;
struct vattr vattr;
-#ifndef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("nfs_remove: no name");
- if (vrefcnt(vp) < 1)
- panic("nfs_remove: bad v_usecount");
-#endif
+ KASSERT((cnp->cn_flags & HASBUF) != 0, ("nfs_remove: no name"));
+ KASSERT(vrefcnt(vp) > 0, ("nfs_remove: bad v_usecount"));
if (vp->v_type == VDIR)
error = EPERM;
else if (vrefcnt(vp) == 1 || (np->n_sillyrename &&
@@ -1676,11 +1672,8 @@ nfs_rename(struct vop_rename_args *ap)
struct nfsv4node *newv4 = NULL;
int error;
-#ifndef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("nfs_rename: no name");
-#endif
+ KASSERT((tcnp->cn_flags & HASBUF) != 0 &&
+ (fcnp->cn_flags & HASBUF) != 0, ("nfs_rename: no name"));
/* Check for cross-device rename */
if ((fvp->v_mount != tdvp->v_mount) ||
(tvp && (fvp->v_mount != tvp->v_mount))) {
@@ -2137,11 +2130,10 @@ ncl_readdirrpc(struct vnode *vp, struct
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
int error = 0, eof, attrflag;
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirrpc bad uio"));
/*
* If there is no cookie, assume directory was stale.
@@ -2198,11 +2190,10 @@ ncl_readdirplusrpc(struct vnode *vp, str
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
int error = 0, attrflag, eof;
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirplusrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirplusrpc bad uio"));
/*
* If there is no cookie, assume directory was stale.
@@ -2264,10 +2255,7 @@ nfs_sillyrename(struct vnode *dvp, struc
cache_purge(dvp);
np = VTONFS(vp);
-#ifndef DIAGNOSTIC
- if (vp->v_type == VDIR)
- panic("nfs: sillyrename dir");
-#endif
+ KASSERT(vp->v_type != VDIR, ("nfs: sillyrename dir"));
MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename),
M_NEWNFSREQ, M_WAITOK);
sp->s_cred = crhold(cnp->cn_cred);
Modified: stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -364,10 +364,7 @@ nfsrvd_dorpc(struct nfsrv_descript *nd,
* Get a locked vnode for the first file handle
*/
if (!(nd->nd_flag & ND_NFSV4)) {
-#ifdef DIAGNOSTIC
- if (nd->nd_repstat)
- panic("nfsrvd_dorpc");
-#endif
+ KASSERT(nd->nd_repstat == 0, ("nfsrvd_dorpc"));
/*
* For NFSv3, if the malloc/mget allocation is near limits,
* return NFSERR_DELAY.
Modified: stable/8/sys/nfsclient/nfs_bio.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_bio.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/nfsclient/nfs_bio.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -448,10 +448,7 @@ nfs_bioread(struct vnode *vp, struct uio
int seqcount;
int nra, error = 0, n = 0, on = 0;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("nfs_read mode");
-#endif
+ KASSERT(uio->uio_rw == UIO_READ, ("nfs_read mode"));
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */
@@ -871,12 +868,9 @@ nfs_write(struct vop_write_args *ap)
int n, on, error = 0;
struct proc *p = td?td->td_proc:NULL;
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("nfs_write mode");
- if (uio->uio_segflg == UIO_USERSPACE && uio->uio_td != curthread)
- panic("nfs_write proc");
-#endif
+ KASSERT(uio->uio_rw == UIO_WRITE, ("nfs_write mode"));
+ KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread,
+ ("nfs_write proc"));
if (vp->v_type != VREG)
return (EIO);
mtx_lock(&np->n_mtx);
Modified: stable/8/sys/nfsclient/nfs_subs.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_subs.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/nfsclient/nfs_subs.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -199,10 +199,7 @@ nfsm_uiotombuf(struct uio *uiop, struct
int uiosiz, clflg, rem;
char *cp;
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfsm_uiotombuf: iovcnt != 1");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1"));
if (siz > MLEN) /* or should it >= MCLBYTES ?? */
clflg = 1;
@@ -789,10 +786,7 @@ nfs_getcookie(struct nfsnode *np, off_t
pos = (uoff_t)off / NFS_DIRBLKSIZ;
if (pos == 0 || off < 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at <= 0");
-#endif
+ KASSERT(!add, ("nfs getcookie add at <= 0"));
return (&nfs_nullcookie);
}
pos--;
@@ -843,10 +837,7 @@ nfs_invaldir(struct vnode *vp)
{
struct nfsnode *np = VTONFS(vp);
-#ifdef DIAGNOSTIC
- if (vp->v_type != VDIR)
- panic("nfs: invaldir not dir");
-#endif
+ KASSERT(vp->v_type == VDIR, ("nfs: invaldir not dir"));
nfs_dircookie_lock(np);
np->n_direofoffset = 0;
np->n_cookieverf.nfsuquad[0] = 0;
Modified: stable/8/sys/nfsclient/nfs_vnops.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_vnops.c Sun Jun 27 23:11:35 2010 (r209555)
+++ stable/8/sys/nfsclient/nfs_vnops.c Mon Jun 28 01:16:34 2010 (r209556)
@@ -1348,10 +1348,7 @@ nfs_writerpc(struct vnode *vp, struct ui
int v3 = NFS_ISV3(vp), committed = NFSV3WRITE_FILESYNC;
int wsize;
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfs: writerpc iovcnt > 1");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1, ("nfs: writerpc iovcnt > 1"));
*must_commit = 0;
tsiz = uiop->uio_resid;
mtx_lock(&nmp->nm_mtx);
@@ -1708,12 +1705,8 @@ nfs_remove(struct vop_remove_args *ap)
int error = 0;
struct vattr vattr;
-#ifndef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("nfs_remove: no name");
- if (vrefcnt(vp) < 1)
- panic("nfs_remove: bad v_usecount");
-#endif
+ KASSERT((cnp->cn_flags & HASBUF) != 0, ("nfs_remove: no name"));
+ KASSERT(vrefcnt(vp) > 0, ("nfs_remove: bad v_usecount"));
if (vp->v_type == VDIR)
error = EPERM;
else if (vrefcnt(vp) == 1 || (np->n_sillyrename &&
@@ -1814,11 +1807,8 @@ nfs_rename(struct vop_rename_args *ap)
struct componentname *fcnp = ap->a_fcnp;
int error;
-#ifndef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("nfs_rename: no name");
-#endif
+ KASSERT((tcnp->cn_flags & HASBUF) != 0 &&
+ (fcnp->cn_flags & HASBUF) != 0, ("nfs_rename: no name"));
/* Check for cross-device rename */
if ((fvp->v_mount != tdvp->v_mount) ||
(tvp && (fvp->v_mount != tvp->v_mount))) {
@@ -2277,11 +2267,10 @@ nfs_readdirrpc(struct vnode *vp, struct
int attrflag;
int v3 = NFS_ISV3(vp);
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirrpc bad uio"));
/*
* If there is no cookie, assume directory was stale.
@@ -2482,11 +2471,10 @@ nfs_readdirplusrpc(struct vnode *vp, str
#ifndef nolint
dp = NULL;
#endif
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirplusrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirplusrpc bad uio"));
ndp->ni_dvp = vp;
newvp = NULLVP;
@@ -2752,10 +2740,7 @@ nfs_sillyrename(struct vnode *dvp, struc
cache_purge(dvp);
np = VTONFS(vp);
-#ifndef DIAGNOSTIC
- if (vp->v_type == VDIR)
- panic("nfs: sillyrename dir");
-#endif
+ KASSERT(vp->v_type != VDIR, ("nfs: sillyrename dir"));
sp = malloc(sizeof (struct sillyrename),
M_NFSREQ, M_WAITOK);
sp->s_cred = crhold(cnp->cn_cred);
More information about the svn-src-stable
mailing list