summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/vnd.c4
-rw-r--r--sys/kern/kern_physio.c3
-rw-r--r--sys/kern/vfs_bio.c18
-rw-r--r--sys/nfs/nfs_bio.c69
-rw-r--r--sys/nfs/nfs_node.c73
-rw-r--r--sys/nfs/nfs_syscalls.c6
-rw-r--r--sys/nfs/nfs_var.h14
-rw-r--r--sys/nfs/nfs_vnops.c106
-rw-r--r--sys/nfs/nfsnode.h6
-rw-r--r--sys/sys/buf.h4
-rw-r--r--sys/uvm/uvm_swap.c5
11 files changed, 126 insertions, 182 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 649423489f8..b2935e0edba 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.27 2000/07/05 07:27:12 niklas Exp $ */
+/* $OpenBSD: vnd.c,v 1.28 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -558,8 +558,6 @@ vndstrategy(bp)
nbp->vb_buf.b_proc = bp->b_proc;
nbp->vb_buf.b_iodone = vndiodone;
nbp->vb_buf.b_vp = vp;
- nbp->vb_buf.b_rcred = vnd->sc_cred; /* XXX crdup? */
- nbp->vb_buf.b_wcred = vnd->sc_cred; /* XXX crdup? */
nbp->vb_buf.b_dirtyoff = bp->b_dirtyoff;
nbp->vb_buf.b_dirtyend = bp->b_dirtyend;
nbp->vb_buf.b_validoff = bp->b_validoff;
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 038ccd6c843..6be92145c71 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.15 2001/11/09 15:33:02 art Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.16 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -283,7 +283,6 @@ getphysbuf()
bzero(bp, sizeof(*bp));
/* XXXCDC: are the following two lines necessary? */
- bp->b_rcred = bp->b_wcred = NOCRED;
bp->b_vnbufs.le_next = NOLIST;
return (bp);
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 7d7cafc05a6..91efbc10320 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.49 2001/11/09 15:32:22 art Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.50 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*-
@@ -200,8 +200,6 @@ bufinit()
bp = &buf[i];
bzero((char *)bp, sizeof *bp);
bp->b_dev = NODEV;
- bp->b_rcred = NOCRED;
- bp->b_wcred = NOCRED;
bp->b_vnbufs.le_next = NOLIST;
bp->b_data = buffers + i * MAXBSIZE;
LIST_INIT(&bp->b_dep);
@@ -265,10 +263,6 @@ bio_doread(vp, blkno, size, cred, async)
if (!ISSET(bp->b_flags, (B_DONE | B_DELWRI))) {
/* Start I/O for the buffer (keeping credentials). */
SET(bp->b_flags, B_READ | async);
- if (cred != NOCRED && bp->b_rcred == NOCRED) {
- crhold(cred);
- bp->b_rcred = cred;
- }
VOP_STRATEGY(bp);
/* Pay for the read. */
@@ -912,16 +906,6 @@ start:
bp->b_dirtyoff = bp->b_dirtyend = 0;
bp->b_validoff = bp->b_validend = 0;
- /* nuke any credentials we were holding */
- if (bp->b_rcred != NOCRED) {
- crfree(bp->b_rcred);
- bp->b_rcred = NOCRED;
- }
- if (bp->b_wcred != NOCRED) {
- crfree(bp->b_wcred);
- bp->b_wcred = NOCRED;
- }
-
bremhash(bp);
*bpp = bp;
return (ret);
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c
index 71f59eced14..1f33bc2eab7 100644
--- a/sys/nfs/nfs_bio.c
+++ b/sys/nfs/nfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_bio.c,v 1.23 2001/11/06 19:53:21 miod Exp $ */
+/* $OpenBSD: nfs_bio.c,v 1.24 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfs_bio.c,v 1.25.4.2 1996/07/08 20:47:04 jtc Exp $ */
/*
@@ -136,6 +136,15 @@ nfs_bioread(vp, uio, ioflag, cred)
}
}
}
+
+ /*
+ * update the cache read creds for this vnode
+ */
+ if (np->n_rcred)
+ crfree(np->n_rcred);
+ np->n_rcred = cred;
+ crhold(cred);
+
do {
if ((vp->v_flag & VROOT) && vp->v_type == VLNK) {
return (nfs_readlinkrpc(vp, uio, cred));
@@ -162,7 +171,7 @@ nfs_bioread(vp, uio, ioflag, cred)
return (EINTR);
if ((rabp->b_flags & (B_DELWRI | B_DONE)) == 0) {
rabp->b_flags |= (B_READ | B_ASYNC);
- if (nfs_asyncio(rabp, cred)) {
+ if (nfs_asyncio(rabp)) {
rabp->b_flags |= B_INVAL;
brelse(rabp);
}
@@ -191,7 +200,7 @@ again:
if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0) {
bp->b_flags |= B_READ;
not_readin = 0;
- error = nfs_doio(bp, cred, p);
+ error = nfs_doio(bp, p);
if (error) {
brelse(bp);
return (error);
@@ -232,7 +241,7 @@ again:
return (EINTR);
if ((bp->b_flags & B_DONE) == 0) {
bp->b_flags |= B_READ;
- error = nfs_doio(bp, cred, p);
+ error = nfs_doio(bp, p);
if (error) {
brelse(bp);
return (error);
@@ -245,7 +254,7 @@ again:
default:
printf(" nfsbioread: type %x unexpected\n",vp->v_type);
break;
- };
+ }
if (n > 0) {
if (!baddr)
@@ -335,6 +344,15 @@ nfs_write(v)
psignal(p, SIGXFSZ);
return (EFBIG);
}
+
+ /*
+ * update the cache write creds for this node.
+ */
+ if (np->n_wcred)
+ crfree(np->n_wcred);
+ np->n_wcred = cred;
+ crhold(cred);
+
/*
* I use nm_rsize, not nm_wsize so that all buffer cache blocks
* will be the same size within a filesystem. nfs_writerpc will
@@ -357,10 +375,6 @@ again:
bp = nfs_getcacheblk(vp, bn, biosize, p);
if (!bp)
return (EINTR);
- if (bp->b_wcred == NOCRED) {
- crhold(cred);
- bp->b_wcred = cred;
- }
np->n_flag |= NMODIFIED;
if (uio->uio_offset + n > np->n_size) {
np->n_size = uio->uio_offset + n;
@@ -522,9 +536,8 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg)
* are all hung on a dead server.
*/
int
-nfs_asyncio(bp, cred)
- register struct buf *bp;
- struct ucred *cred;
+nfs_asyncio(bp)
+ struct buf *bp;
{
int i,s;
@@ -532,17 +545,8 @@ nfs_asyncio(bp, cred)
return (EIO);
for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
if (nfs_iodwant[i]) {
- if (bp->b_flags & B_READ) {
- if (bp->b_rcred == NOCRED && cred != NOCRED) {
- crhold(cred);
- bp->b_rcred = cred;
- }
- } else {
+ if ((bp->b_flags & B_READ) == 0) {
bp->b_flags |= B_WRITEINPROG;
- if (bp->b_wcred == NOCRED && cred != NOCRED) {
- crhold(cred);
- bp->b_wcred = cred;
- }
}
TAILQ_INSERT_TAIL(&nfs_bufq, bp, b_freelist);
@@ -577,9 +581,8 @@ nfs_asyncio(bp, cred)
* synchronously or from an nfsiod.
*/
int
-nfs_doio(bp, cr, p)
- register struct buf *bp;
- struct ucred *cr;
+nfs_doio(bp, p)
+ struct buf *bp;
struct proc *p;
{
register struct uio *uiop;
@@ -609,16 +612,16 @@ nfs_doio(bp, cr, p)
io.iov_len = uiop->uio_resid = bp->b_bcount;
/* mapping was done by vmapbuf() */
io.iov_base = bp->b_data;
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE;
+ uiop->uio_offset = ((off_t)bp->b_blkno) << DEV_BSHIFT;
if (bp->b_flags & B_READ) {
uiop->uio_rw = UIO_READ;
nfsstats.read_physios++;
- error = nfs_readrpc(vp, uiop, cr);
+ error = nfs_readrpc(vp, uiop);
} else {
iomode = NFSV3WRITE_DATASYNC;
uiop->uio_rw = UIO_WRITE;
nfsstats.write_physios++;
- error = nfs_writerpc(vp, uiop, cr, &iomode, &must_commit);
+ error = nfs_writerpc(vp, uiop, &iomode, &must_commit);
}
if (error) {
bp->b_flags |= B_ERROR;
@@ -630,9 +633,9 @@ nfs_doio(bp, cr, p)
uiop->uio_rw = UIO_READ;
switch (vp->v_type) {
case VREG:
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE;
+ uiop->uio_offset = ((off_t)bp->b_blkno) << DEV_BSHIFT;
nfsstats.read_bios++;
- error = nfs_readrpc(vp, uiop, cr);
+ error = nfs_readrpc(vp, uiop);
if (!error) {
bp->b_validoff = 0;
if (uiop->uio_resid) {
@@ -643,7 +646,7 @@ nfs_doio(bp, cr, p)
* Just zero fill the rest of the valid area.
*/
diff = bp->b_bcount - uiop->uio_resid;
- len = np->n_size - (((u_quad_t)bp->b_blkno) * DEV_BSIZE
+ len = np->n_size - ((((off_t)bp->b_blkno) << DEV_BSHIFT)
+ diff);
if (len > 0) {
len = min(len, uiop->uio_resid);
@@ -664,7 +667,7 @@ nfs_doio(bp, cr, p)
case VLNK:
uiop->uio_offset = (off_t)0;
nfsstats.readlink_bios++;
- error = nfs_readlinkrpc(vp, uiop, cr);
+ error = nfs_readlinkrpc(vp, uiop, curproc->p_ucred);
break;
default:
printf("nfs_doio: type %x unexpected\n",vp->v_type);
@@ -691,7 +694,7 @@ nfs_doio(bp, cr, p)
printf("nfs_doio(%x): bp %x doff %d dend %d\n",
vp, bp, bp->b_dirtyoff, bp->b_dirtyend);
#endif
- error = nfs_writerpc(vp, uiop, cr, &iomode, &must_commit);
+ error = nfs_writerpc(vp, uiop, &iomode, &must_commit);
if (!error && iomode == NFSV3WRITE_UNSTABLE)
bp->b_flags |= B_NEEDCOMMIT;
else
diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c
index f23e8087a8f..987259eadc3 100644
--- a/sys/nfs/nfs_node.c
+++ b/sys/nfs/nfs_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_node.c,v 1.15 2001/06/25 03:28:06 csapuntz Exp $ */
+/* $OpenBSD: nfs_node.c,v 1.16 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */
/*
@@ -48,6 +48,7 @@
#include <sys/vnode.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
@@ -58,6 +59,11 @@
LIST_HEAD(nfsnodehashhead, nfsnode) *nfsnodehashtbl;
u_long nfsnodehash;
+struct lock nfs_hashlock;
+
+struct pool nfs_node_pool;
+
+extern int prtactive;
#define TRUE 1
#define FALSE 0
@@ -69,8 +75,11 @@ u_long nfsnodehash;
void
nfs_nhinit()
{
-
nfsnodehashtbl = hashinit(desiredvnodes, M_NFSNODE, M_WAITOK, &nfsnodehash);
+ lockinit(&nfs_hashlock, PINOD, "nfs_hashlock", 0, 0);
+
+ pool_init(&nfs_node_pool, sizeof(struct nfsnode), 0, 0, 0, "nfsnodepl",
+ 0, pool_page_alloc_nointr, pool_page_free_nointr, M_NFSNODE);
}
/*
@@ -78,12 +87,12 @@ nfs_nhinit()
*/
u_long
nfs_hash(fhp, fhsize)
- register nfsfh_t *fhp;
+ nfsfh_t *fhp;
int fhsize;
{
- register u_char *fhpp;
- register u_long fhsum;
- register int i;
+ u_char *fhpp;
+ u_long fhsum;
+ int i;
fhpp = &fhp->fh_bytes[0];
fhsum = 0;
@@ -101,19 +110,18 @@ nfs_hash(fhp, fhsize)
int
nfs_nget(mntp, fhp, fhsize, npp)
struct mount *mntp;
- register nfsfh_t *fhp;
+ nfsfh_t *fhp;
int fhsize;
struct nfsnode **npp;
{
struct proc *p = curproc; /* XXX */
- register struct nfsnode *np, *np2;
+ struct nfsnode *np;
struct nfsnodehashhead *nhpp;
- register struct vnode *vp;
+ struct vnode *vp;
extern int (**nfsv2_vnodeop_p)__P((void *));
struct vnode *nvp;
int error;
-retry:
nhpp = NFSNOHASH(nfs_hash(fhp, fhsize));
loop:
for (np = nhpp->lh_first; np != 0; np = np->n_hash.le_next) {
@@ -126,15 +134,19 @@ loop:
*npp = np;
return(0);
}
+ if (lockmgr(&nfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, NULL, p))
+ goto loop;
error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &nvp);
if (error) {
*npp = 0;
+ lockmgr(&nfs_hashlock, LK_RELEASE, NULL, p);
return (error);
}
vp = nvp;
- MALLOC(np, struct nfsnode *, sizeof *np, M_NFSNODE, M_WAITOK);
+ np = pool_get(&nfs_node_pool, PR_WAITOK);
bzero((caddr_t)np, sizeof *np);
vp->v_data = np;
+ np->n_vnode = vp;
/*
* Are we getting the root? If so, make sure the vnode flags
@@ -149,28 +161,15 @@ loop:
vp->v_flag |= VROOT;
}
}
-
- np->n_vnode = vp;
- /*
- * Insert the nfsnode in the hash queue for its new file handle
- */
- for (np2 = nhpp->lh_first; np2 != 0; np2 = np2->n_hash.le_next) {
- if (vp->v_mount != NFSTOV(np2)->v_mount ||
- fhsize != np2->n_fhsize ||
- bcmp((caddr_t)fhp, (caddr_t)np2->n_fhp, fhsize))
- continue;
-
- vrele(vp);
- goto retry;
- }
LIST_INSERT_HEAD(nhpp, np, n_hash);
if (fhsize > NFS_SMALLFH) {
- MALLOC(np->n_fhp, nfsfh_t *, fhsize, M_NFSBIGFH, M_WAITOK);
+ np->n_fhp = malloc(fhsize, M_NFSBIGFH, M_WAITOK);
} else
np->n_fhp = &np->n_fh;
bcopy((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize);
np->n_fhsize = fhsize;
+ lockmgr(&nfs_hashlock, LK_RELEASE, 0, p);
*npp = np;
return (0);
}
@@ -183,10 +182,9 @@ nfs_inactive(v)
struct vnode *a_vp;
struct proc *a_p;
} */ *ap = v;
- register struct nfsnode *np;
- register struct sillyrename *sp;
+ struct nfsnode *np;
+ struct sillyrename *sp;
struct proc *p = curproc; /* XXX */
- extern int prtactive;
np = VTONFS(ap->a_vp);
if (prtactive && ap->a_vp->v_usecount != 0)
@@ -222,10 +220,9 @@ nfs_reclaim(v)
struct vop_reclaim_args /* {
struct vnode *a_vp;
} */ *ap = v;
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- register struct nfsdmap *dp, *dp2;
- extern int prtactive;
+ struct vnode *vp = ap->a_vp;
+ struct nfsnode *np = VTONFS(vp);
+ struct nfsdmap *dp, *dp2;
if (prtactive && vp->v_usecount != 0)
vprint("nfs_reclaim: pushing active", vp);
@@ -247,12 +244,16 @@ nfs_reclaim(v)
}
}
if (np->n_fhsize > NFS_SMALLFH) {
- FREE((caddr_t)np->n_fhp, M_NFSBIGFH);
+ free(np->n_fhp, M_NFSBIGFH);
}
+ if (np->n_rcred)
+ crfree(np->n_rcred);
+ if (np->n_wcred)
+ crfree(np->n_wcred);
cache_purge(vp);
- FREE(vp->v_data, M_NFSNODE);
- vp->v_data = (void *)0;
+ pool_put(&nfs_node_pool, vp->v_data);
+ vp->v_data = NULL;
return (0);
}
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 5f8f87a36c9..c71a662ccb2 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.19 2001/06/26 05:19:35 csapuntz Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.20 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -945,7 +945,7 @@ nfssvc_iod(p)
/* Take one off the front of the list */
TAILQ_REMOVE(&nfs_bufq, bp, b_freelist);
if (bp->b_flags & B_READ)
- (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
+ (void) nfs_doio(bp, NULL);
else do {
/*
* Look for a delayed write for the same vnode, so I can do
@@ -975,7 +975,7 @@ nfssvc_iod(p)
}
splx(s);
- (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);
+ (void) nfs_doio(bp, NULL);
} while ((bp = nbp) != NULL);
}
if (error) {
diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h
index 6010cdc1a57..861eaf3059e 100644
--- a/sys/nfs/nfs_var.h
+++ b/sys/nfs/nfs_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_var.h,v 1.14 2001/06/25 03:28:12 csapuntz Exp $ */
+/* $OpenBSD: nfs_var.h,v 1.15 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */
/*
@@ -66,8 +66,8 @@ int nfs_write __P((void *));
struct buf *nfs_getcacheblk __P((struct vnode *, daddr_t, int, struct proc *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
-int nfs_asyncio __P((struct buf *, struct ucred *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
+int nfs_asyncio __P((struct buf *));
+int nfs_doio __P((struct buf *, struct proc *));
/* nfs_boot.c */
int nfs_boot_init __P((struct nfs_diskless *, struct proc *));
@@ -93,9 +93,8 @@ int nfs_lookup __P((void *));
int nfs_read __P((void *));
int nfs_readlink __P((void *));
int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
+int nfs_readrpc __P((struct vnode *, struct uio *));
+int nfs_writerpc __P((struct vnode *, struct uio *, int *, int *));
int nfs_mknodrpc __P((struct vnode *, struct vnode **, struct componentname *,
struct vattr *));
int nfs_mknod __P((void *));
@@ -120,8 +119,7 @@ int nfs_sillyrename __P((struct vnode *, struct vnode *,
struct componentname *));
int nfs_lookitup __P((struct vnode *, char *, int, struct ucred *,
struct proc *, struct nfsnode **));
-int nfs_commit __P((struct vnode *, u_quad_t, int, struct ucred *,
- struct proc *));
+int nfs_commit __P((struct vnode *, u_quad_t, int, struct proc *));
int nfs_bmap __P((void *));
int nfs_strategy __P((void *));
int nfs_mmap __P((void *));
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 72bb4661e11..0813b439cb2 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.38 2001/11/06 19:53:21 miod Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.39 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -594,8 +594,8 @@ nfs_setattr(v)
*/
int
nfs_setattrrpc(vp, vap, cred, procp)
- register struct vnode *vp;
- register struct vattr *vap;
+ struct vnode *vp;
+ struct vattr *vap;
struct ucred *cred;
struct proc *procp;
{
@@ -877,14 +877,13 @@ nfs_readlinkrpc(vp, uiop, cred)
* Ditto above
*/
int
-nfs_readrpc(vp, uiop, cred)
- register struct vnode *vp;
+nfs_readrpc(vp, uiop)
+ struct vnode *vp;
struct uio *uiop;
- struct ucred *cred;
{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
+ u_int32_t *tl;
+ caddr_t cp;
+ int32_t t1, t2;
caddr_t bpos, dpos, cp2;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
struct nfsmount *nmp;
@@ -912,7 +911,8 @@ nfs_readrpc(vp, uiop, cred)
*tl++ = txdr_unsigned(len);
*tl = 0;
}
- nfsm_request(vp, NFSPROC_READ, uiop->uio_procp, cred);
+ nfsm_request(vp, NFSPROC_READ, uiop->uio_procp,
+ VTONFS(vp)->n_rcred);
if (v3) {
nfsm_postop_attr(vp, attrflag);
if (error) {
@@ -941,15 +941,14 @@ nfsmout:
* nfs write call
*/
int
-nfs_writerpc(vp, uiop, cred, iomode, must_commit)
- register struct vnode *vp;
- register struct uio *uiop;
- struct ucred *cred;
+nfs_writerpc(vp, uiop, iomode, must_commit)
+ struct vnode *vp;
+ struct uio *uiop;
int *iomode, *must_commit;
{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2, backup;
+ u_int32_t *tl;
+ caddr_t cp;
+ int32_t t1, t2, backup;
caddr_t bpos, dpos, cp2;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
@@ -991,7 +990,8 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit)
}
nfsm_uiotom(uiop, len);
- nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp, cred);
+ nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp,
+ VTONFS(vp)->n_wcred);
if (v3) {
wccflag = NFSV3_WCCCHK;
nfsm_wcc_data(vp, wccflag);
@@ -2508,17 +2508,16 @@ nfs_lookitup(dvp, name, len, cred, procp, npp)
* Nfs Version 3 commit rpc
*/
int
-nfs_commit(vp, offset, cnt, cred, procp)
- register struct vnode *vp;
+nfs_commit(vp, offset, cnt, procp)
+ struct vnode *vp;
u_quad_t offset;
int cnt;
- struct ucred *cred;
struct proc *procp;
{
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1, t2;
- register struct nfsmount *nmp = VFSTONFS(vp->v_mount);
+ caddr_t cp;
+ u_int32_t *tl;
+ int32_t t1, t2;
+ struct nfsmount *nmp = VFSTONFS(vp->v_mount);
caddr_t bpos, dpos, cp2;
int error = 0, wccflag = NFSV3_WCCRATTR;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
@@ -2532,7 +2531,7 @@ nfs_commit(vp, offset, cnt, cred, procp)
txdr_hyper(offset, tl);
tl += 2;
*tl = txdr_unsigned(cnt);
- nfsm_request(vp, NFSPROC_COMMIT, procp, cred);
+ nfsm_request(vp, NFSPROC_COMMIT, procp, VTONFS(vp)->n_wcred);
nfsm_wcc_data(vp, wccflag);
if (!error) {
nfsm_dissect(tl, u_int32_t *, NFSX_V3WRITEVERF);
@@ -2587,29 +2586,23 @@ nfs_strategy(v)
void *v;
{
struct vop_strategy_args *ap = v;
- register struct buf *bp = ap->a_bp;
- struct ucred *cr;
+ struct buf *bp = ap->a_bp;
struct proc *p;
int error = 0;
if ((bp->b_flags & (B_PHYS|B_ASYNC)) == (B_PHYS|B_ASYNC))
panic("nfs physio/async");
if (bp->b_flags & B_ASYNC)
- p = (struct proc *)0;
+ p = NULL;
else
p = curproc; /* XXX */
- if (bp->b_flags & B_READ)
- cr = bp->b_rcred;
- else
- cr = bp->b_wcred;
/*
* If the op is asynchronous and an i/o daemon is waiting
* queue the request, wake it up and wait for completion
* otherwise just do it ourselves.
*/
- if ((bp->b_flags & B_ASYNC) == 0 ||
- nfs_asyncio(bp, NOCRED))
- error = nfs_doio(bp, cr, p);
+ if ((bp->b_flags & B_ASYNC) == 0 || nfs_asyncio(bp))
+ error = nfs_doio(bp, p);
return (error);
}
@@ -2639,21 +2632,20 @@ nfs_fsync(v)
*/
int
nfs_flush(vp, cred, waitfor, p, commit)
- register struct vnode *vp;
+ struct vnode *vp;
struct ucred *cred;
int waitfor;
struct proc *p;
int commit;
{
- register struct nfsnode *np = VTONFS(vp);
- register struct buf *bp;
- register int i;
+ struct nfsnode *np = VTONFS(vp);
+ struct buf *bp;
+ int i;
struct buf *nbp;
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
int s, error = 0, slptimeo = 0, slpflag = 0, retv, bvecpos;
int passone = 1;
u_quad_t off = (u_quad_t)-1, endoff = 0, toff;
- struct ucred* wcred = NULL;
#ifndef NFS_COMMITBVECSIZ
#define NFS_COMMITBVECSIZ 20
#endif
@@ -2682,14 +2674,6 @@ again:
!= (B_DELWRI | B_NEEDCOMMIT))
continue;
bremfree(bp);
- /*
- * Work out if all buffers are using the same cred
- * so we can deal with them all with one commit.
- */
- if (wcred == NULL)
- wcred = bp->b_wcred;
- else if (wcred != bp->b_wcred)
- wcred = NOCRED;
bp->b_flags |= (B_BUSY | B_WRITEINPROG);
/*
* A list of these buffers is kept so that the
@@ -2712,28 +2696,8 @@ again:
if (bvecpos > 0) {
/*
* Commit data on the server, as required.
- * If all bufs are using the same wcred, then use that with
- * one call for all of them, otherwise commit each one
- * separately.
*/
- if (wcred != NOCRED)
- retv = nfs_commit(vp, off, (int)(endoff - off),
- wcred, p);
- else {
- retv = 0;
- for (i = 0; i < bvecpos; i++) {
- off_t off, size;
- bp = bvec[i];
- off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE +
- bp->b_dirtyoff;
- size = (u_quad_t)(bp->b_dirtyend
- - bp->b_dirtyoff);
- retv = nfs_commit(vp, off, (int)size,
- bp->b_wcred, p);
- if (retv) break;
- }
- }
-
+ retv = nfs_commit(vp, off, (int)(endoff - off), p);
if (retv == NFSERR_STALEWRITEVERF)
nfs_clearcommit(vp->v_mount);
/*
@@ -2951,7 +2915,7 @@ nfs_writebp(bp, force)
off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff;
bp->b_flags |= B_WRITEINPROG;
retv = nfs_commit(bp->b_vp, off, bp->b_dirtyend-bp->b_dirtyoff,
- bp->b_wcred, bp->b_proc);
+ bp->b_proc);
bp->b_flags &= ~B_WRITEINPROG;
if (!retv) {
bp->b_dirtyoff = bp->b_dirtyend = 0;
diff --git a/sys/nfs/nfsnode.h b/sys/nfs/nfsnode.h
index 02b8c8cbd31..e1e0fd64327 100644
--- a/sys/nfs/nfsnode.h
+++ b/sys/nfs/nfsnode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfsnode.h,v 1.10 2001/06/25 03:28:14 csapuntz Exp $ */
+/* $OpenBSD: nfsnode.h,v 1.11 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: nfsnode.h,v 1.16 1996/02/18 11:54:04 fvdl Exp $ */
/*
@@ -117,6 +117,8 @@ struct nfsnode {
short n_fhsize; /* size in bytes, of fh */
short n_flag; /* Flag for locking.. */
nfsfh_t n_fh; /* Small File Handle */
+ struct ucred *n_rcred;
+ struct ucred *n_wcred;
};
#define n_atim n_un1.nf_atim
@@ -141,7 +143,7 @@ struct nfsnode {
* Convert between nfsnode pointers and vnode pointers
*/
#define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
-#define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
+#define NFSTOV(np) ((np)->n_vnode)
/*
* Queue head for nfsiod's
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 92855ae36f4..cabdcbbe084 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.32 2001/11/09 15:32:21 art Exp $ */
+/* $OpenBSD: buf.h,v 1.33 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */
/*
@@ -98,8 +98,6 @@ struct buf {
struct vnode *b_vp; /* Device vnode. */
int b_dirtyoff; /* Offset in buffer of dirty region. */
int b_dirtyend; /* Offset of end of dirty region. */
- struct ucred *b_rcred; /* Read credentials reference. */
- struct ucred *b_wcred; /* Write credentials reference. */
int b_validoff; /* Offset in buffer of valid region. */
int b_validend; /* Offset of end of valid region. */
struct workhead b_dep; /* List of filesystem dependencies. */
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index 61dfcd02bc9..4697d8a23f6 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.40 2001/11/12 01:26:10 art Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.41 2001/11/15 23:15:15 art Exp $ */
/* $NetBSD: uvm_swap.c,v 1.46 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -1391,8 +1391,6 @@ sw_reg_strategy(sdp, bp, bn)
nbp->vb_buf.b_iodone = sw_reg_iodone;
nbp->vb_buf.b_vp = NULLVP;
nbp->vb_buf.b_vnbufs.le_next = NOLIST;
- nbp->vb_buf.b_rcred = sdp->swd_cred;
- nbp->vb_buf.b_wcred = sdp->swd_cred;
LIST_INIT(&nbp->vb_buf.b_dep);
/*
@@ -1977,7 +1975,6 @@ uvm_swap_io(pps, startslot, npages, flags)
*/
bp->b_flags = B_BUSY | B_NOCACHE | (flags & (B_READ|B_ASYNC));
bp->b_proc = &proc0; /* XXX */
- bp->b_rcred = bp->b_wcred = proc0.p_ucred;
bp->b_vnbufs.le_next = NOLIST;
bp->b_data = (caddr_t)kva;
bp->b_blkno = startblk;