Date: Tue, 3 May 2011 01:19:39 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r221355 - stable/8/sys/fs/nfsclient Message-ID: <201105030119.p431JdTu062515@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Tue May 3 01:19:39 2011 New Revision: 221355 URL: http://svn.freebsd.org/changeset/base/221355 Log: MFC: r220810 Fix up handling of the nfsmount structure in read and write within the experimental NFS client. Mostly add mutex locking and use the same rsize, wsize during the operation by keeping a local copy of it. This is another change that brings it closer to the regular NFS client. Modified: stable/8/sys/fs/nfsclient/nfs_clrpcops.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) Modified: stable/8/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clrpcops.c Mon May 2 23:34:33 2011 (r221354) +++ stable/8/sys/fs/nfsclient/nfs_clrpcops.c Tue May 3 01:19:39 2011 (r221355) @@ -1284,16 +1284,22 @@ nfsrpc_readrpc(vnode_t vp, struct uio *u struct nfsrv_descript nfsd; struct nfsmount *nmp = VFSTONFS(vnode_mount(vp)); struct nfsrv_descript *nd = &nfsd; + int rsize; *attrflagp = 0; tsiz = uio_uio_resid(uiop); - if (uiop->uio_offset + tsiz > 0xffffffff && - !NFSHASNFSV3OR4(nmp)) + NFSLOCKMNT(nmp); + if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) { + /* XXX Needs overflow/negative check for uio_offset */ + NFSUNLOCKMNT(nmp); return (EFBIG); + } + rsize = nmp->nm_rsize; + NFSUNLOCKMNT(nmp); nd->nd_mrep = NULL; while (tsiz > 0) { *attrflagp = 0; - len = (tsiz > nmp->nm_rsize) ? nmp->nm_rsize : tsiz; + len = (tsiz > rsize) ? rsize : tsiz; NFSCL_REQSTART(nd, NFSPROC_READ, vp); if (nd->nd_flag & ND_NFSV4) nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID); @@ -1333,7 +1339,7 @@ nfsrpc_readrpc(vnode_t vp, struct uio *u NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); eof = fxdr_unsigned(int, *tl); } - NFSM_STRSIZ(retlen, nmp->nm_rsize); + NFSM_STRSIZ(retlen, rsize); error = nfsm_mbufuio(nd, uiop, retlen); if (error) goto nfsmout; @@ -1457,8 +1463,7 @@ nfsrpc_writerpc(vnode_t vp, struct uio * *attrflagp = 0; tsiz = uio_uio_resid(uiop); NFSLOCKMNT(nmp); - if (uiop->uio_offset + tsiz > 0xffffffff && - !NFSHASNFSV3OR4(nmp)) { + if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) { NFSUNLOCKMNT(nmp); return (EFBIG); } @@ -1467,11 +1472,6 @@ nfsrpc_writerpc(vnode_t vp, struct uio * nd->nd_mrep = NULL; /* NFSv2 sometimes does a write with */ nd->nd_repstat = 0; /* uio_resid == 0, so the while is not done */ while (tsiz > 0) { - nmp = VFSTONFS(vnode_mount(vp)); - if (nmp == NULL) { - error = ENXIO; - goto nfsmout; - } *attrflagp = 0; len = (tsiz > wsize) ? wsize : tsiz; NFSCL_REQSTART(nd, NFSPROC_WRITE, vp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105030119.p431JdTu062515>