diff options
Diffstat (limited to 'sys/nfs')
| -rw-r--r-- | sys/nfs/bootp_subr.c | 14 | ||||
| -rw-r--r-- | sys/nfs/nfs_bio.c | 30 | ||||
| -rw-r--r-- | sys/nfs/nfs_nqlease.c | 5 | ||||
| -rw-r--r-- | sys/nfs/nfs_serv.c | 7 | ||||
| -rw-r--r-- | sys/nfs/nfs_socket.c | 13 | ||||
| -rw-r--r-- | sys/nfs/nfs_subs.c | 16 | ||||
| -rw-r--r-- | sys/nfs/nfs_syscalls.c | 3 | ||||
| -rw-r--r-- | sys/nfs/nfs_vfsops.c | 8 | ||||
| -rw-r--r-- | sys/nfs/nfs_vnops.c | 202 | ||||
| -rw-r--r-- | sys/nfs/nfsm_subs.h | 73 | ||||
| -rw-r--r-- | sys/nfs/nfsnode.h | 5 |
11 files changed, 174 insertions, 202 deletions
diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 1efca259d5364..c66e384665401 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -1,4 +1,4 @@ -/* $Id: bootp_subr.c,v 1.17 1998/12/04 22:54:54 archie Exp $ */ +/* $Id: bootp_subr.c,v 1.14 1998/08/18 00:32:47 bde Exp $ */ /* * Copyright (c) 1995 Gordon Ross, Adam Glass @@ -262,11 +262,13 @@ bootpc_call(call,reply,procp) { struct socket *so; struct sockaddr_in *sin, sa; + struct mbuf *m; struct uio auio; struct sockopt sopt; struct iovec aio; struct timeval tv; int error, on, len, rcvflg, secs, timo; + u_int tport; /* * Create socket and set its recieve timeout. @@ -343,7 +345,7 @@ bootpc_call(call,reply,procp) error = sosend(so, (struct sockaddr *)sin, &auio, NULL, NULL, 0, procp); if (error) { - printf("bootpc_call: sosend: %d state %08x\n", error, (int)so->so_state); + printf("bootpc_call: sosend: %d\n", error); goto out; } @@ -728,7 +730,7 @@ bootpc_init(void) struct socket *so; int error; int code,ncode,len; - int j; + int i,j; char *p; unsigned int ip; @@ -742,6 +744,7 @@ bootpc_init(void) char lookup_path[24]; #define EALEN 6 + unsigned char ea[EALEN]; struct ifaddr *ifa; struct sockaddr_dl *sdl = NULL; char *delim; @@ -771,8 +774,7 @@ bootpc_init(void) bzero(&ireq, sizeof(ireq)); for (ifp = TAILQ_FIRST(&ifnet); ifp != 0; ifp = TAILQ_NEXT(ifp,if_link)) { - snprintf(ireq.ifr_name, sizeof(ireq.ifr_name), - "%s%d", ifp->if_name, ifp->if_unit); + sprintf(ireq.ifr_name, "%s%d", ifp->if_name, ifp->if_unit); #ifdef BOOTP_WIRED_TO if (strcmp(ireq.ifr_name, __XSTRING(BOOTP_WIRED_TO)) == 0) break; @@ -883,7 +885,7 @@ bootpc_init(void) myaddr.sin_addr = reply.yiaddr; ip = ntohl(myaddr.sin_addr.s_addr); - snprintf(lookup_path, sizeof(lookup_path), "swap.%d.%d.%d.%d", + sprintf(lookup_path,"swap.%d.%d.%d.%d", ip >> 24, (ip >> 16) & 255 ,(ip >> 8) & 255 ,ip & 255 ); printip("My ip address",myaddr.sin_addr); diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index c9737006f1d47..b8b97a4aa8602 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 - * $Id: nfs_bio.c,v 1.64 1998/12/07 21:58:43 archie Exp $ + * $Id: nfs_bio.c,v 1.61 1998/09/29 21:46:54 mckusick Exp $ */ @@ -86,6 +86,7 @@ nfs_getpages(ap) int i, error, nextoff, size, toff, npages, count; struct uio uio; struct iovec iov; + vm_page_t m; vm_offset_t kva; struct buf *bp; struct vnode *vp; @@ -197,6 +198,7 @@ nfs_putpages(ap) { struct uio uio; struct iovec iov; + vm_page_t m; vm_offset_t kva; struct buf *bp; int iomode, must_commit, i, error, npages, count; @@ -277,8 +279,7 @@ nfs_bioread(vp, uio, ioflag, cred, getpages) int getpages; { register struct nfsnode *np = VTONFS(vp); - register int biosize, i; - off_t diff; + register int biosize, diff, i; struct buf *bp = 0, *rabp; struct vattr vattr; struct proc *p; @@ -433,7 +434,7 @@ again: bufsize = biosize; if ((off_t)(lbn + 1) * biosize > np->n_size && (off_t)(lbn + 1) * biosize - np->n_size < biosize) { - bufsize = np->n_size - (off_t)lbn * biosize; + bufsize = np->n_size - lbn * biosize; bufsize = (bufsize + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); } bp = nfs_getcacheblk(vp, lbn, bufsize, p); @@ -755,11 +756,11 @@ again: if (uio->uio_offset + n > np->n_size) { np->n_size = uio->uio_offset + n; np->n_flag |= NMODIFIED; - vnode_pager_setsize(vp, np->n_size); + vnode_pager_setsize(vp, (u_long)np->n_size); } bufsize = biosize; - if ((off_t)(lbn + 1) * biosize > np->n_size) { - bufsize = np->n_size - (off_t)lbn * biosize; + if ((lbn + 1) * biosize > np->n_size) { + bufsize = np->n_size - lbn * biosize; bufsize = (bufsize + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); } bp = nfs_getcacheblk(vp, lbn, bufsize, p); @@ -771,8 +772,9 @@ again: } np->n_flag |= NMODIFIED; - if ((off_t)bp->b_blkno * DEV_BSIZE + bp->b_dirtyend > np->n_size) - bp->b_dirtyend = np->n_size - (off_t)bp->b_blkno * DEV_BSIZE; + if ((bp->b_blkno * DEV_BSIZE) + bp->b_dirtyend > np->n_size) { + bp->b_dirtyend = np->n_size - (bp->b_blkno * DEV_BSIZE); + } /* * If the new write will leave a contiguous dirty @@ -903,10 +905,10 @@ nfs_getcacheblk(vp, bn, size, p) } else bp = getblk(vp, bn, size, 0, 0); - if (vp->v_type == VREG) { + if( vp->v_type == VREG) { int biosize; biosize = mp->mnt_stat.f_iosize; - bp->b_blkno = bn * (biosize / DEV_BSIZE); + bp->b_blkno = (bn * biosize) / DEV_BSIZE; } return (bp); @@ -1216,13 +1218,13 @@ nfs_doio(bp, cr, p) bp->b_error = error; } } else { - if ((off_t)bp->b_blkno * DEV_BSIZE + bp->b_dirtyend > np->n_size) - bp->b_dirtyend = np->n_size - (off_t)bp->b_blkno * DEV_BSIZE; + if (((bp->b_blkno * DEV_BSIZE) + bp->b_dirtyend) > np->n_size) + bp->b_dirtyend = np->n_size - (bp->b_blkno * DEV_BSIZE); if (bp->b_dirtyend > bp->b_dirtyoff) { io.iov_len = uiop->uio_resid = bp->b_dirtyend - bp->b_dirtyoff; - uiop->uio_offset = (off_t)bp->b_blkno * DEV_BSIZE + uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff; io.iov_base = (char *)bp->b_data + bp->b_dirtyoff; uiop->uio_rw = UIO_WRITE; diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c index ae6a14a2fc070..a9464dc7b265f 100644 --- a/sys/nfs/nfs_nqlease.c +++ b/sys/nfs/nfs_nqlease.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_nqlease.c 8.9 (Berkeley) 5/20/95 - * $Id: nfs_nqlease.c,v 1.38 1998/09/05 15:17:33 bde Exp $ + * $Id: nfs_nqlease.c,v 1.37 1998/05/31 20:08:52 peter Exp $ */ @@ -1117,8 +1117,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) } } else if ((np->n_expiry - NQ_RENEWAL) < time_second) { if ((np->n_flag & (NQNFSWRITE | NQNFSNONCACHE)) - == NQNFSWRITE && - !TAILQ_EMPTY(&vp->v_dirtyblkhd) && + == NQNFSWRITE && vp->v_dirtyblkhd.lh_first && vget(vp, LK_EXCLUSIVE, p) == 0) { nmp->nm_inprog = vp; if (vpid == vp->v_id && diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 346c4fc58c7c0..d701213545373 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 - * $Id: nfs_serv.c,v 1.71 1998/12/08 23:11:24 eivind Exp $ + * $Id: nfs_serv.c,v 1.68 1998/05/31 20:08:52 peter Exp $ */ /* @@ -1776,7 +1776,8 @@ out: vrele(nd.ni_dvp); else vput(nd.ni_dvp); - vput(vp); + if (vp != NULLVP); + vput(vp); } if (dirp && v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); @@ -3121,7 +3122,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) for_ret = VOP_GETATTR(vp, &bfor, cred, procp); if (vp->v_object && (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) { - vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC); + vm_object_page_clean(vp->v_object, 0, 0, TRUE); } error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); aft_ret = VOP_GETATTR(vp, &aft, cred, procp); diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 8c1b812af1651..11ac518995980 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_socket.c,v 1.48 1998/12/07 21:58:44 archie Exp $ + * $Id: nfs_socket.c,v 1.45 1998/09/07 05:42:15 bde Exp $ */ /* @@ -191,6 +191,7 @@ nfs_connect(nmp, rep) int s, error, rcvreserve, sndreserve; struct sockaddr *saddr; struct sockaddr_in *sin; + struct mbuf *m; u_int16_t tport; struct proc *p = &proc0; /* only used for socreate and sobind */ @@ -403,11 +404,11 @@ nfs_safedisconnect(nmp) * For the client side: * - return EINTR if the RPC is terminated, 0 otherwise * - set R_MUSTRESEND if the send fails for any reason - * - do any cleanup required by recoverable socket errors (?) + * - do any cleanup required by recoverable socket errors (???) * For the server side: * - return EINTR or ERESTART if interrupted by a signal * - return EPIPE if a connection is lost for connection based sockets (TCP...) - * - do any cleanup required by recoverable socket errors (?) + * - do any cleanup required by recoverable socket errors (???) */ int nfs_send(so, nam, top, rep) @@ -469,7 +470,7 @@ nfs_send(so, nam, top, rep) log(LOG_INFO, "nfsd send error %d\n", error); /* - * Handle any recoverable (soft) socket errors here. (?) + * Handle any recoverable (soft) socket errors here. (???) */ if (error != EINTR && error != ERESTART && error != EWOULDBLOCK && error != EPIPE) @@ -2231,9 +2232,7 @@ nfsrv_dorec(slp, nfsd, ndp) nd->nd_dpos = mtod(m, caddr_t); error = nfs_getreq(nd, nfsd, TRUE); if (error) { - if (nam) { - FREE(nam, M_SONAME); - } + FREE(nam, M_SONAME); free((caddr_t)nd, M_NFSRVDESC); return (error); } diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index b3eec2408a2e9..346e9e6191996 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95 - * $Id: nfs_subs.c,v 1.69 1998/12/14 18:54:03 dt Exp $ + * $Id: nfs_subs.c,v 1.64 1998/09/05 15:17:33 bde Exp $ */ /* @@ -208,8 +208,7 @@ static u_char nfsrv_v2errmap[ELAST] = { NFSERR_NOTEMPTY, NFSERR_IO, NFSERR_IO, NFSERR_DQUOT, NFSERR_STALE, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, - NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, - NFSERR_IO /* << Last is 86 */ + NFSERR_IO, NFSERR_IO, NFSERR_IO /* << Last is 83 */ }; /* @@ -651,6 +650,7 @@ nfsm_rpchead(cr, nmflag, procid, auth_type, auth_len, auth_str, verf_len, register int i; struct mbuf *mreq, *mb2; int siz, grpsiz, authsiz; + static u_int32_t base; authsiz = nfsm_rndup(auth_len); MGETHDR(mb, M_WAIT, MT_DATA); @@ -1377,7 +1377,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) np->n_size = vap->va_size; } else np->n_size = vap->va_size; - vnode_pager_setsize(vp, np->n_size); + vnode_pager_setsize(vp, (u_long)np->n_size); } else np->n_size = vap->va_size; } @@ -1463,7 +1463,7 @@ nfs_getattrcache(vp, vaper) np->n_size = vap->va_size; } else np->n_size = vap->va_size; - vnode_pager_setsize(vp, np->n_size); + vnode_pager_setsize(vp, (u_long)np->n_size); } else np->n_size = vap->va_size; } @@ -2129,8 +2129,8 @@ loop: if (vp->v_mount != mp) /* Paranoia */ goto loop; nvp = vp->v_mntvnodes.le_next; - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_vnbufs); + for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { + nbp = bp->b_vnbufs.le_next; if ((bp->b_flags & (B_BUSY | B_DELWRI | B_NEEDCOMMIT)) == (B_DELWRI | B_NEEDCOMMIT)) bp->b_flags &= ~B_NEEDCOMMIT; @@ -2177,7 +2177,7 @@ nfsrv_object_create(vp) if (vp == NULL || vp->v_type != VREG) return (1); return (vfs_object_create(vp, curproc, - curproc ? curproc->p_ucred : NULL)); + curproc ? curproc->p_ucred : NULL, 1)); } /* diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 8b85b9b22bd9d..abf3383e709d3 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_syscalls.c,v 1.43 1998/09/01 02:31:52 luoqi Exp $ + * $Id: nfs_syscalls.c,v 1.42 1998/08/23 03:07:16 wollman Exp $ */ #include <sys/param.h> @@ -357,6 +357,7 @@ nfssvc_addsock(fp, mynam, p) struct sockaddr *mynam; struct proc *p; { + register struct mbuf *m; register int siz; register struct nfssvc_sock *slp; register struct socket *so; diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index cc4775b618669..23e30c00a9562 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95 - * $Id: nfs_vfsops.c,v 1.78 1998/10/31 15:31:26 peter Exp $ + * $Id: nfs_vfsops.c,v 1.76 1998/09/07 13:17:05 bde Exp $ */ #include <sys/param.h> @@ -486,7 +486,7 @@ nfs_mountroot(mp) nd->root_args.fh = nd->root_fh; nd->root_args.fhsize = nd->root_fhsize; l = ntohl(nd->root_saddr.sin_addr.s_addr); - snprintf(buf, sizeof(buf), "%ld.%ld.%ld.%ld:%s", + sprintf(buf,"%ld.%ld.%ld.%ld:%s", (l >> 24) & 0xff, (l >> 16) & 0xff, (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam); printf("NFS ROOT: %s\n",buf); @@ -512,7 +512,7 @@ nfs_mountroot(mp) nd->swap_args.fh = nd->swap_fh; nd->swap_args.fhsize = nd->swap_fhsize; l = ntohl(nd->swap_saddr.sin_addr.s_addr); - snprintf(buf, sizeof(buf), "%ld.%ld.%ld.%ld:%s", + sprintf(buf,"%ld.%ld.%ld.%ld:%s", (l >> 24) & 0xff, (l >> 16) & 0xff, (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam); printf("NFS SWAP: %s\n",buf); @@ -1066,7 +1066,7 @@ loop: */ if (vp->v_mount != mp) goto loop; - if (VOP_ISLOCKED(vp) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || + if (VOP_ISLOCKED(vp) || vp->v_dirtyblkhd.lh_first == NULL || waitfor == MNT_LAZY) continue; if (vget(vp, LK_EXCLUSIVE, p)) diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index c97267a42aee3..e4917c1d5616b 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 - * $Id: nfs_vnops.c,v 1.115 1998/12/25 10:34:27 dfr Exp $ + * $Id: nfs_vnops.c,v 1.108 1998/09/29 23:29:48 mckusick Exp $ */ @@ -60,7 +60,6 @@ #include <sys/fcntl.h> #include <sys/lockf.h> #include <sys/stat.h> -#include <sys/sysctl.h> #include <vm/vm.h> #include <vm/vm_extern.h> @@ -248,18 +247,6 @@ struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; int nfs_numasync = 0; #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) -static int nfsaccess_cache_timeout = 2; -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, - &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout"); - -static int nfsaccess_cache_hits; -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, - &nfsaccess_cache_hits, 0, "NFS ACCESS cache hit count"); - -static int nfsaccess_cache_fills; -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_fills, CTLFLAG_RD, - &nfsaccess_cache_fills, 0, "NFS ACCESS cache fill count"); - /* * nfs access vnode op. * For nfs version 2, just return ok. File accesses may fail later. @@ -282,9 +269,8 @@ nfs_access(ap) caddr_t bpos, dpos, cp2; int error = 0, attrflag; struct mbuf *mreq, *mrep, *md, *mb, *mb2; - u_int32_t mode, rmode, wmode; + u_int32_t mode, rmode; int v3 = NFS_ISV3(vp); - struct nfsnode *np = VTONFS(vp); /* * Disallow write attempts on filesystems mounted read-only; @@ -302,14 +288,18 @@ nfs_access(ap) } } /* - * For nfs v3, check to see if we have done this recently, and if - * so return our cached result instead of making an ACCESS call. - * If not, do an access rpc, otherwise you are stuck emulating + * For nfs v3, do an access rpc, otherwise you are stuck emulating * ufs_access() locally using the vattr. This may not be correct, * since the server may apply other access criteria such as - * client uid-->server uid mapping that we do not know about. + * client uid-->server uid mapping that we do not know about, but + * this is better than just returning anything that is lying about + * in the cache. */ if (v3) { + nfsstats.rpccnt[NFSPROC_ACCESS]++; + nfsm_reqhead(vp, NFSPROC_ACCESS, NFSX_FH(v3) + NFSX_UNSIGNED); + nfsm_fhtom(vp, v3); + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); if (ap->a_mode & VREAD) mode = NFSV3ACCESS_READ; else @@ -326,54 +316,21 @@ nfs_access(ap) if (ap->a_mode & VEXEC) mode |= NFSV3ACCESS_LOOKUP; } - /* XXX safety belt, only make blanket request if caching */ - if (nfsaccess_cache_timeout > 0) { - wmode = NFSV3ACCESS_READ | NFSV3ACCESS_MODIFY | - NFSV3ACCESS_EXTEND | NFSV3ACCESS_EXECUTE | - NFSV3ACCESS_DELETE | NFSV3ACCESS_LOOKUP; - } else { - wmode = mode; - } - - /* - * Does our cached result allow us to give a definite yes to - * this request? - */ - if ((time_second < (np->n_modestamp + nfsaccess_cache_timeout)) && - (ap->a_cred->cr_uid == np->n_modeuid) && - ((np->n_mode & mode) == mode)) { - nfsaccess_cache_hits++; - } else { + *tl = txdr_unsigned(mode); + nfsm_request(vp, NFSPROC_ACCESS, ap->a_p, ap->a_cred); + nfsm_postop_attr(vp, attrflag); + if (!error) { + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + rmode = fxdr_unsigned(u_int32_t, *tl); /* - * Either a no, or a don't know. Go to the wire. + * The NFS V3 spec does not clarify whether or not + * the returned access bits can be a superset of + * the ones requested, so... */ - nfsstats.rpccnt[NFSPROC_ACCESS]++; - nfsm_reqhead(vp, NFSPROC_ACCESS, NFSX_FH(v3) + NFSX_UNSIGNED); - nfsm_fhtom(vp, v3); - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); - *tl = txdr_unsigned(wmode); - nfsm_request(vp, NFSPROC_ACCESS, ap->a_p, ap->a_cred); - nfsm_postop_attr(vp, attrflag); - if (!error) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); - rmode = fxdr_unsigned(u_int32_t, *tl); - /* - * The NFS V3 spec does not clarify whether or not - * the returned access bits can be a superset of - * the ones requested, so... - */ - if ((rmode & mode) != mode) { - error = EACCES; - } else if (nfsaccess_cache_timeout > 0) { - /* cache the result */ - nfsaccess_cache_fills++; - np->n_mode = rmode; - np->n_modeuid = ap->a_cred->cr_uid; - np->n_modestamp = time_second; - } - } - nfsm_reqdone; + if ((rmode & mode) != mode) + error = EACCES; } + nfsm_reqdone; return (error); } else { if (error = nfsspec_access(ap)) @@ -665,7 +622,7 @@ nfs_setattr(ap) */ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - vnode_pager_setsize(vp, vap->va_size); + vnode_pager_setsize(vp, (u_long)vap->va_size); if (np->n_flag & NMODIFIED) { if (vap->va_size == 0) error = nfs_vinvalbuf(vp, 0, @@ -674,7 +631,7 @@ nfs_setattr(ap) error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1); if (error) { - vnode_pager_setsize(vp, np->n_size); + vnode_pager_setsize(vp, (u_long)np->n_size); return (error); } } @@ -690,7 +647,7 @@ nfs_setattr(ap) error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_p); if (error && vap->va_size != VNOVAL) { np->n_size = np->n_vattr.va_size = tsize; - vnode_pager_setsize(vp, np->n_size); + vnode_pager_setsize(vp, (u_long)np->n_size); } return (error); } @@ -718,7 +675,64 @@ nfs_setattrrpc(vp, vap, cred, procp) nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3)); nfsm_fhtom(vp, v3); if (v3) { - nfsm_v3attrbuild(vap, TRUE); + if (vap->va_mode != (mode_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned(vap->va_mode); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (vap->va_uid != (uid_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned(vap->va_uid); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (vap->va_gid != (gid_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned(vap->va_gid); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (vap->va_size != VNOVAL) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = nfs_true; + txdr_hyper(&vap->va_size, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (vap->va_atime.tv_sec != VNOVAL) { + if (vap->va_atime.tv_sec != time_second) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); + txdr_nfsv3time(&vap->va_atime, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); + } + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); + } + if (vap->va_mtime.tv_sec != VNOVAL) { + if (vap->va_mtime.tv_sec != time_second) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); + txdr_nfsv3time(&vap->va_mtime, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); + } + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); + } nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = nfs_false; } else { @@ -1204,6 +1218,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) register struct vattr *vap; { register struct nfsv2_sattr *sp; + register struct nfsv3_sattr *sp3; register u_int32_t *tl; register caddr_t cp; register int32_t t1, t2; @@ -1235,9 +1250,10 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) { - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3SRVSATTR); *tl++ = vtonfsv3_type(vap->va_type); - nfsm_v3attrbuild(vap, FALSE); + sp3 = (struct nfsv3_sattr *)tl; + nfsm_v3sattr(sp3, vap); if (vap->va_type == VCHR || vap->va_type == VBLK) { nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(major(vap->va_rdev)); @@ -1324,6 +1340,7 @@ nfs_create(ap) register struct vattr *vap = ap->a_vap; register struct componentname *cnp = ap->a_cnp; register struct nfsv2_sattr *sp; + register struct nfsv3_sattr *sp3; register u_int32_t *tl; register caddr_t cp; register int32_t t1, t2; @@ -1356,18 +1373,20 @@ again: if (v3) { nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); if (fmode & O_EXCL) { - *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE); - nfsm_build(tl, u_int32_t *, NFSX_V3CREATEVERF); + *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE); + nfsm_build(tl, u_int32_t *, NFSX_V3CREATEVERF); #ifdef INET - if (!TAILQ_EMPTY(&in_ifaddrhead)) - *tl++ = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr.s_addr; - else + if (!TAILQ_EMPTY(&in_ifaddrhead)) + *tl++ = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr.s_addr; + else #endif - *tl++ = create_verf; - *tl = ++create_verf; + *tl++ = create_verf; + *tl = ++create_verf; } else { - *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED); - nfsm_v3attrbuild(vap, FALSE); + *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED); + nfsm_build(tl, u_int32_t *, NFSX_V3SRVSATTR); + sp3 = (struct nfsv3_sattr *)tl; + nfsm_v3sattr(sp3, vap); } } else { nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -1586,7 +1605,6 @@ nfs_rename(ap) cache_purge(tdvp); cache_purge(fdvp); } - out: if (tdvp == tvp) vrele(tdvp); @@ -1741,6 +1759,7 @@ nfs_symlink(ap) register struct vattr *vap = ap->a_vap; register struct componentname *cnp = ap->a_cnp; register struct nfsv2_sattr *sp; + register struct nfsv3_sattr *sp3; register u_int32_t *tl; register caddr_t cp; register int32_t t1, t2; @@ -1757,7 +1776,8 @@ nfs_symlink(ap) nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) { - nfsm_v3attrbuild(vap, FALSE); + nfsm_build(sp3, struct nfsv3_sattr *, NFSX_V3SRVSATTR); + nfsm_v3sattr(sp3, vap); } nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN); if (!v3) { @@ -1806,6 +1826,7 @@ nfs_mkdir(ap) register struct vattr *vap = ap->a_vap; register struct componentname *cnp = ap->a_cnp; register struct nfsv2_sattr *sp; + register struct nfsv3_sattr *sp3; register u_int32_t *tl; register caddr_t cp; register int32_t t1, t2; @@ -1830,7 +1851,8 @@ nfs_mkdir(ap) nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); if (v3) { - nfsm_v3attrbuild(vap, FALSE); + nfsm_build(sp3, struct nfsv3_sattr *, NFSX_V3SRVSATTR); + nfsm_v3sattr(sp3, vap); } else { nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(VDIR, vap->va_mode); @@ -2733,8 +2755,8 @@ again: * Count up how many buffers waiting for a commit. */ bveccount = 0; - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_vnbufs); + for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { + nbp = bp->b_vnbufs.le_next; if ((bp->b_flags & (B_BUSY | B_DELWRI | B_NEEDCOMMIT)) == (B_DELWRI | B_NEEDCOMMIT)) bveccount++; @@ -2760,8 +2782,8 @@ again: bvec = bvec_on_stack; bvecsize = NFS_COMMITBVECSIZ; } - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_vnbufs); + for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { + nbp = bp->b_vnbufs.le_next; if (bvecpos >= bvecsize) break; if ((bp->b_flags & (B_BUSY | B_DELWRI | B_NEEDCOMMIT)) @@ -2858,8 +2880,8 @@ again: */ loop: s = splbio(); - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_vnbufs); + for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { + nbp = bp->b_vnbufs.le_next; if (bp->b_flags & B_BUSY) { if (waitfor != MNT_WAIT || passone) continue; @@ -2913,7 +2935,7 @@ loop: } } } - if (!TAILQ_EMPTY(&vp->v_dirtyblkhd) && commit) { + if (vp->v_dirtyblkhd.lh_first && commit) { goto loop; } } diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index 3692b7b1375b3..75158edd074ca 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 - * $Id: nfsm_subs.h,v 1.21 1998/05/31 20:08:57 peter Exp $ + * $Id: nfsm_subs.h,v 1.20 1998/05/31 19:00:19 peter Exp $ */ @@ -235,68 +235,17 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, (f) = ttattrf; \ } } -/* If full is true, set all fields, otherwise just set mode and time fields */ -#define nfsm_v3attrbuild(a, full) \ - { if ((a)->va_mode != (mode_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_mode); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_uid); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_gid); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_size != VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - txdr_hyper(&(a)->va_size, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((a)->va_atime.tv_sec != VNOVAL) { \ - if ((a)->va_atime.tv_sec != time_second) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ - txdr_nfsv3time(&(a)->va_atime, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ - } \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ - } \ - if ((a)->va_mtime.tv_sec != VNOVAL) { \ - if ((a)->va_mtime.tv_sec != time_second) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ - txdr_nfsv3time(&(a)->va_mtime, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ - } \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ - } \ +#define nfsm_v3sattr(s, a) \ + { (s)->sa_modetrue = nfs_true; \ + (s)->sa_mode = vtonfsv3_mode((a)->va_mode); \ + (s)->sa_uidfalse = nfs_false; \ + (s)->sa_gidfalse = nfs_false; \ + (s)->sa_sizefalse = nfs_false; \ + (s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ + txdr_nfsv3time(&(a)->va_atime, &(s)->sa_atime); \ + (s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ + txdr_nfsv3time(&(a)->va_mtime, &(s)->sa_mtime); \ } - #define nfsm_strsiz(s,m) \ { nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ diff --git a/sys/nfs/nfsnode.h b/sys/nfs/nfsnode.h index 49adeb21e5c7d..51f5d78648893 100644 --- a/sys/nfs/nfsnode.h +++ b/sys/nfs/nfsnode.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95 - * $Id: nfsnode.h,v 1.27 1998/11/13 02:39:09 msmith Exp $ + * $Id: nfsnode.h,v 1.25 1998/03/06 09:46:52 msmith Exp $ */ @@ -93,9 +93,6 @@ struct nfsnode { u_quad_t n_lrev; /* Modify rev for lease */ struct vattr n_vattr; /* Vnode attribute cache */ time_t n_attrstamp; /* Attr. cache timestamp */ - u_int32_t n_mode; /* ACCESS mode cache */ - uid_t n_modeuid; /* credentials having mode */ - time_t n_modestamp; /* mode cache timestamp */ time_t n_mtime; /* Prev modify time. */ time_t n_ctime; /* Prev create time. */ time_t n_expiry; /* Lease expiry time */ |
