svn commit: r363316 - projects/nfs-over-tls/sys/fs/nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Sun Jul 19 02:14:35 UTC 2020
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
More information about the svn-src-projects
mailing list