svn commit: r352024 - in projects/nfsv42/sys/fs: nfs nfsclient
Rick Macklem
rmacklem at FreeBSD.org
Sat Sep 7 21:26:58 UTC 2019
Author: rmacklem
Date: Sat Sep 7 21:26:56 2019
New Revision: 352024
URL: https://svnweb.freebsd.org/changeset/base/352024
Log:
Increase the maximum request/response size for NFSv4.2.
Since the Extended Attribute operations may want to send requests/replies
that are larger than the I/O sizes, make the max request/reply as large as
possible when the session is created.
Use these maximum request/response sizes returned in the session reply as
the limits for the Extended Attribute operations.
Modified:
projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c
projects/nfsv42/sys/fs/nfs/nfsclstate.h
projects/nfsv42/sys/fs/nfsclient/nfs_clrpcops.c
projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c
Modified: projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Sat Sep 7 20:01:26 2019 (r352023)
+++ projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Sat Sep 7 21:26:56 2019 (r352024)
@@ -4633,8 +4633,8 @@ nfsv4_setsequence(struct nfsmount *nmp, struct nfsrv_d
error = nfsv4_sequencelookup(nmp, sep, &slotpos, &maxslot, &slotseq,
sessionid);
- nd->nd_maxreq = sep->sess_maxreq;
- nd->nd_maxresp = sep->sess_maxresp;
+ nd->nd_maxreq = sep->nfsess_maxreq;
+ nd->nd_maxresp = sep->nfsess_maxresp;
/* Build the Sequence arguments. */
NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 4 * NFSX_UNSIGNED);
Modified: projects/nfsv42/sys/fs/nfs/nfsclstate.h
==============================================================================
--- projects/nfsv42/sys/fs/nfs/nfsclstate.h Sat Sep 7 20:01:26 2019 (r352023)
+++ projects/nfsv42/sys/fs/nfs/nfsclstate.h Sat Sep 7 21:26:56 2019 (r352024)
@@ -64,6 +64,8 @@ struct nfsclsession {
uint64_t nfsess_slots;
uint32_t nfsess_sequenceid;
uint32_t nfsess_maxcache; /* Max size for cached reply. */
+ uint32_t nfsess_maxreq; /* Max request size. */
+ uint32_t nfsess_maxresp; /* Max reply size. */
uint16_t nfsess_foreslots;
uint16_t nfsess_backslots;
uint8_t nfsess_sessionid[NFSX_V4SESSIONID];
Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsclient/nfs_clrpcops.c Sat Sep 7 20:01:26 2019 (r352023)
+++ projects/nfsv42/sys/fs/nfsclient/nfs_clrpcops.c Sat Sep 7 21:26:56 2019 (r352024)
@@ -74,6 +74,7 @@ extern int nfsrv_useacl;
extern char nfsv4_callbackaddr[INET6_ADDRSTRLEN];
extern int nfscl_debuglevel;
extern int nfs_pnfsiothreads;
+extern u_long sb_max_adj;
NFSCLSTATEMUTEX;
int nfstest_outofseq = 0;
int nfscl_assumeposixlocks = 1;
@@ -4778,8 +4779,19 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsc
/* Fill in fore channel attributes. */
NFSM_BUILD(tl, uint32_t *, 7 * NFSX_UNSIGNED);
*tl++ = 0; /* Header pad size */
- *tl++ = txdr_unsigned(nmp->nm_wsize + NFS_MAXXDR);/* Max request size */
- *tl++ = txdr_unsigned(nmp->nm_rsize + NFS_MAXXDR);/* Max reply size */
+ if ((nd->nd_flag & ND_NFSV42) != 0 && mds != 0 &&
+ sb_max_adj - NFS_MAXXDR > nmp->nm_wsize - NFS_MAXXDR &&
+ sb_max_adj - NFS_MAXXDR > nmp->nm_rsize - NFS_MAXXDR) {
+ /*
+ * NFSv4.2 Extended Attribute operations may want to do
+ * requests/replies that are larger than nm_rsize/nm_wsize.
+ */
+ *tl++ = txdr_unsigned(sb_max_adj - NFS_MAXXDR);
+ *tl++ = txdr_unsigned(sb_max_adj - NFS_MAXXDR);
+ } else {
+ *tl++ = txdr_unsigned(nmp->nm_wsize + NFS_MAXXDR);
+ *tl++ = txdr_unsigned(nmp->nm_rsize + NFS_MAXXDR);
+ }
*tl++ = txdr_unsigned(4096); /* Max response size cached */
*tl++ = txdr_unsigned(20); /* Max operations */
*tl++ = txdr_unsigned(64); /* Max slots */
@@ -4836,6 +4848,7 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsc
else
break;
}
+ sep->nfsess_maxreq = maxval;
/* Make sure nm_rsize is small enough. */
maxval = fxdr_unsigned(uint32_t, *tl++);
@@ -4845,6 +4858,7 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsc
else
break;
}
+ sep->nfsess_maxresp = maxval;
sep->nfsess_maxcache = fxdr_unsigned(int, *tl++);
tl++;
@@ -8327,6 +8341,11 @@ nfsrpc_setextattr(vnode_t vp, const char *name, struct
*attrflagp = 0;
NFSCL_REQSTART(nd, NFSPROC_SETEXTATTR, vp);
+ if (uiop->uio_resid > nd->nd_maxreq) {
+ /* nd_maxreq is set by NFSCL_REQSTART(). */
+ mbuf_freem(nd->nd_mreq);
+ return (EINVAL);
+ }
NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(NFSV4SXATTR_EITHER);
nfsm_strtom(nd, name, strlen(name));
Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Sat Sep 7 20:01:26 2019 (r352023)
+++ projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Sat Sep 7 21:26:56 2019 (r352024)
@@ -3835,7 +3835,7 @@ nfs_setextattr(struct vop_setextattr_args *ap)
}
mtx_unlock(&nmp->nm_mtx);
- if (ap->a_uio->uio_resid <= 0 || ap->a_uio->uio_resid > nmp->nm_wsize)
+ if (ap->a_uio->uio_resid <= 0)
return (EINVAL);
cred = ap->a_cred;
if (cred == NULL)
More information about the svn-src-projects
mailing list