From owner-svn-src-projects@freebsd.org Sun Jul 19 02:14:35 2020 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 AAC5F37ABA5 for ; Sun, 19 Jul 2020 02:14:35 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4B8T2M46b1z43Gj; Sun, 19 Jul 2020 02:14:35 +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 71A83144E3; Sun, 19 Jul 2020 02:14:35 +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 06J2EZAx072954; Sun, 19 Jul 2020 02:14:35 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06J2EZQ5072951; Sun, 19 Jul 2020 02:14:35 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202007190214.06J2EZQ5072951@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sun, 19 Jul 2020 02:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r363316 - projects/nfs-over-tls/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfs-over-tls/sys/fs/nfsserver X-SVN-Commit-Revision: 363316 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.33 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: Sun, 19 Jul 2020 02:14:35 -0000 Author: rmacklem Date: Sun Jul 19 02:14:34 2020 New Revision: 363316 URL: https://svnweb.freebsd.org/changeset/base/363316 Log: Make sure the NFS server only generates ext_pgs mbufs when there will not be an m_copym() done to cache a reply. For NFSv3, the caching of a reply is based on the RPC number. For NFSv4.1 and NFSv4.2, the Sequence operation request indicates whether or not to hold only a copy in the session. Normally, Read, Readdir and Getextattr will not need a reply copy, but this code makes sure it does not happen for ext_pgs mbufs. For NFSv4.0, it cannot use ext_pgs mbufs, since it cannot be sure that a cached reply copy is not created. Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdserv.c Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c Sun Jul 19 01:59:56 2020 (r363315) +++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c Sun Jul 19 02:14:34 2020 (r363316) @@ -2114,10 +2114,14 @@ again: vput(vp); /* - * If the siz and cnt are larger than MCLBYTES, use ext_pgs for TLS. + * If cnt > MCLBYTES and the reply will not be saved, use + * ext_pgs mbufs for TLS. + * For NFSv4.0, we do not know for sure if the reply will + * be saved, so do not use ext_pgs mbufs for NFSv4.0. */ - if ((nd->nd_flag & (ND_EXTPG | ND_TLS)) == ND_TLS && siz > MCLBYTES && - cnt > MCLBYTES) + if (cnt > MCLBYTES && siz > MCLBYTES && + (nd->nd_flag & (ND_TLS | ND_EXTPG | ND_SAVEREPLY)) == ND_TLS && + (nd->nd_flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4) nd->nd_flag |= ND_EXTPG; /* @@ -2438,13 +2442,17 @@ again: } /* - * If the reply is likely to exceed MCLBYTES, then use TLS. + * If the reply is likely to exceed MCLBYTES and the reply will + * not be saved, use ext_pgs mbufs for TLS. * It is difficult to predict how large each entry will be and * how many entries have been read, so just assume the directory * entries grow by a factor of 4 when attributes are included. + * For NFSv4.0, we do not know for sure if the reply will + * be saved, so do not use ext_pgs mbufs for NFSv4.0. */ - if ((nd->nd_flag & (ND_EXTPG | ND_TLS)) == ND_TLS && cnt > MCLBYTES && - siz > MCLBYTES / 4) + if (cnt > MCLBYTES && siz > MCLBYTES / 4 && + (nd->nd_flag & (ND_TLS | ND_EXTPG | ND_SAVEREPLY)) == ND_TLS && + (nd->nd_flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4) nd->nd_flag |= ND_EXTPG; /* @@ -6291,10 +6299,15 @@ nfsvno_getxattr(struct vnode *vp, char *name, uint32_t len = siz; tlen = NFSM_RNDUP(len); /* - * If the cnt is larger than MCLBYTES, use ext_pgs for TLS. - * Always use ext_pgs if ND_EXTPG is set. + * If cnt > MCLBYTES and the reply will not be saved, use + * ext_pgs mbufs for TLS. + * For NFSv4.0, we do not know for sure if the reply will + * be saved, so do not use ext_pgs mbufs for NFSv4.0. + * Always use ext_pgs mbufs if ND_EXTPG is set. */ - if ((flag & ND_EXTPG) != 0 || ((flag & ND_TLS) != 0 && tlen > MCLBYTES)) + if ((flag & ND_EXTPG) != 0 || (tlen > MCLBYTES && + (flag & (ND_TLS | ND_SAVEREPLY)) == ND_TLS && + (flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4)) uiop->uio_iovcnt = nfsrv_createiovec_extpgs(tlen, maxextsiz, &m, &m2, &iv); else Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdserv.c Sun Jul 19 01:59:56 2020 (r363315) +++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdserv.c Sun Jul 19 02:14:34 2020 (r363316) @@ -857,11 +857,15 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int is m3 = NULL; if (cnt > 0) { /* - * If the cnt is larger than MCLBYTES, use ext_pgs for TLS. - * Always use ext_pgs if ND_EXTPG is set. + * If cnt > MCLBYTES and the reply will not be saved, use + * ext_pgs mbufs for TLS. + * For NFSv4.0, we do not know for sure if the reply will + * be saved, so do not use ext_pgs mbufs for NFSv4.0. + * Always use ext_pgs mbufs if ND_EXTPG is set. */ - if ((nd->nd_flag & ND_EXTPG) != 0 || - ((nd->nd_flag & ND_TLS) != 0 && cnt > MCLBYTES)) + if ((nd->nd_flag & ND_EXTPG) != 0 || (cnt > MCLBYTES && + (nd->nd_flag & (ND_TLS | ND_SAVEREPLY)) == ND_TLS && + (nd->nd_flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4)) nd->nd_repstat = nfsvno_read(vp, off, cnt, nd->nd_cred, nd->nd_maxextsiz, p, &m3, &m2); else