Merge 220876, 220877, and 221537 from the new NFS client to the old:
Allow the NFS client to use a max file size larger than 1TB for v3 mounts. It now allows files up to OFF_MAX subject to whatever limit the server advertises. Reviewed by: rmacklem Approved by: re (kib) MFC after: 1 week
This commit is contained in:
parent
3797b1fc58
commit
bf2e38e673
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=224733
@ -445,6 +445,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
||||
struct thread *td;
|
||||
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
|
||||
daddr_t lbn, rabn;
|
||||
off_t end;
|
||||
int bcount;
|
||||
int seqcount;
|
||||
int nra, error = 0, n = 0, on = 0;
|
||||
@ -464,8 +465,9 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
||||
} else
|
||||
mtx_unlock(&nmp->nm_mtx);
|
||||
|
||||
end = uio->uio_offset + uio->uio_resid;
|
||||
if (vp->v_type != VDIR &&
|
||||
(uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize)
|
||||
(end > nmp->nm_maxfilesize || end < uio->uio_offset))
|
||||
return (EFBIG);
|
||||
|
||||
if (nfs_directio_enable && (ioflag & IO_DIRECT) && (vp->v_type == VREG))
|
||||
@ -865,6 +867,7 @@ nfs_write(struct vop_write_args *ap)
|
||||
struct vattr vattr;
|
||||
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
|
||||
daddr_t lbn;
|
||||
off_t end;
|
||||
int bcount;
|
||||
int n, on, error = 0;
|
||||
|
||||
@ -932,7 +935,8 @@ nfs_write(struct vop_write_args *ap)
|
||||
|
||||
if (uio->uio_offset < 0)
|
||||
return (EINVAL);
|
||||
if ((uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize)
|
||||
end = uio->uio_offset + uio->uio_resid;
|
||||
if (end > nmp->nm_maxfilesize || end < uio->uio_offset)
|
||||
return (EFBIG);
|
||||
if (uio->uio_resid == 0)
|
||||
return (0);
|
||||
|
@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bio.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -1228,13 +1229,11 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
|
||||
*
|
||||
* For V3, nfs_fsinfo will adjust this as necessary. Assume maximum
|
||||
* that we can handle until we find out otherwise.
|
||||
* XXX Our "safe" limit on the client is what we can store in our
|
||||
* buffer cache using signed(!) block numbers.
|
||||
*/
|
||||
if ((argp->flags & NFSMNT_NFSV3) == 0)
|
||||
nmp->nm_maxfilesize = 0xffffffffLL;
|
||||
else
|
||||
nmp->nm_maxfilesize = (u_int64_t)0x80000000 * DEV_BSIZE - 1;
|
||||
nmp->nm_maxfilesize = OFF_MAX;
|
||||
|
||||
nmp->nm_timeo = NFS_TIMEO;
|
||||
nmp->nm_retry = NFS_RETRANS;
|
||||
|
@ -1276,6 +1276,7 @@ nfs_readrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred)
|
||||
caddr_t bpos, dpos;
|
||||
struct mbuf *mreq, *mrep, *md, *mb;
|
||||
struct nfsmount *nmp;
|
||||
off_t end;
|
||||
int error = 0, len, retlen, tsiz, eof, attrflag;
|
||||
int v3 = NFS_ISV3(vp);
|
||||
int rsize;
|
||||
@ -1286,7 +1287,8 @@ nfs_readrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred)
|
||||
nmp = VFSTONFS(vp->v_mount);
|
||||
tsiz = uiop->uio_resid;
|
||||
mtx_lock(&nmp->nm_mtx);
|
||||
if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) {
|
||||
end = uiop->uio_offset + tsiz;
|
||||
if (end > nmp->nm_maxfilesize || end < uiop->uio_offset) {
|
||||
mtx_unlock(&nmp->nm_mtx);
|
||||
return (EFBIG);
|
||||
}
|
||||
@ -1348,6 +1350,7 @@ nfs_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
|
||||
caddr_t bpos, dpos;
|
||||
struct mbuf *mreq, *mrep, *md, *mb;
|
||||
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
|
||||
off_t end;
|
||||
int error = 0, len, tsiz, wccflag = NFSV3_WCCRATTR, rlen, commit;
|
||||
int v3 = NFS_ISV3(vp), committed = NFSV3WRITE_FILESYNC;
|
||||
int wsize;
|
||||
@ -1356,7 +1359,8 @@ nfs_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
|
||||
*must_commit = 0;
|
||||
tsiz = uiop->uio_resid;
|
||||
mtx_lock(&nmp->nm_mtx);
|
||||
if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) {
|
||||
end = uiop->uio_offset + tsiz;
|
||||
if (end > nmp->nm_maxfilesize || end < uiop->uio_offset) {
|
||||
mtx_unlock(&nmp->nm_mtx);
|
||||
return (EFBIG);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user