From owner-svn-src-projects@freebsd.org Sat Sep 7 21:26:58 2019 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7ECB9DD5EC for ; Sat, 7 Sep 2019 21:26:58 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46QnYt0L2wz41V6; Sat, 7 Sep 2019 21:26:58 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E2FD8B9E7; Sat, 7 Sep 2019 21:26:57 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x87LQvNh095948; Sat, 7 Sep 2019 21:26:57 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x87LQvFR095945; Sat, 7 Sep 2019 21:26:57 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201909072126.x87LQvFR095945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 7 Sep 2019 21:26:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r352024 - in projects/nfsv42/sys/fs: nfs nfsclient X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/nfsv42/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 352024 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Sep 2019 21:26:58 -0000 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)