aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2021-06-30 22:15:41 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2021-06-30 22:15:41 +0000
commitc5f4772c66d2eb31b84a84a89c8a284043f03452 (patch)
treebc47cea606f459d964b2be943e65c699f6dbe6b6
parent447636e43c08d697664512a50f00f93f41c0a79f (diff)
downloadsrc-c5f4772c66d2eb31b84a84a89c8a284043f03452.tar.gz
src-c5f4772c66d2eb31b84a84a89c8a284043f03452.zip
nfscl: Improve "Consider increasing kern.ipc.maxsockbuf" message
When the setting of kern.ipc.maxsockbuf is less than what is desired for I/O based on vfs.maxbcachebuf and vfs.nfs.bufpackets, a console message of "Consider increasing kern.ipc.maxsockbuf". is printed. This patch modifies the message to provide a suggested value for kern.ipc.maxsockbuf. Note that the setting is only needed when the NFS rsize/wsize is set to vfs.maxbcachebuf. While here, make nfs_bufpackets global, so that it can be used by a future patch that adds a sysctl to set the NFS server's maximum I/O size. Also, remove "sizeof(u_int32_t)" from the maximum packet length, since NFS_MAXXDR is already an "overestimate" of the actual length. MFC after: 2 weeks
-rw-r--r--sys/fs/nfs/nfs_commonkrpc.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c
index 04ef04955ce0..63ff02331a0e 100644
--- a/sys/fs/nfs/nfs_commonkrpc.c
+++ b/sys/fs/nfs/nfs_commonkrpc.c
@@ -101,8 +101,8 @@ extern int nfscl_debuglevel;
extern int nfsrv_lease;
SVCPOOL *nfscbd_pool;
+int nfs_bufpackets = 4;
static int nfsrv_gsscallbackson = 0;
-static int nfs_bufpackets = 4;
static int nfs_reconnects;
static int nfs3_jukebox_delay = 10;
static int nfs_skip_wcc_data_onerr = 1;
@@ -180,6 +180,7 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
struct thread *td = curthread;
SVCXPRT *xprt;
struct timeval timo;
+ uint64_t tval;
/*
* We need to establish the socket using the credentials of
@@ -238,8 +239,21 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
do {
if (error != 0 && pktscale > 2) {
if (nmp != NULL && nrp->nr_sotype == SOCK_STREAM &&
- pktscale == pktscalesav)
- printf("Consider increasing kern.ipc.maxsockbuf\n");
+ pktscale == pktscalesav) {
+ /*
+ * Suggest vfs.nfs.bufpackets * maximum RPC message,
+ * adjusted for the sb_max->sb_max_adj conversion of
+ * MCLBYTES / (MSIZE + MCLBYTES) as the minimum setting
+ * for kern.ipc.maxsockbuf.
+ */
+ tval = (NFS_MAXBSIZE + NFS_MAXXDR) * nfs_bufpackets;
+ tval *= MSIZE + MCLBYTES;
+ tval += MCLBYTES - 1; /* Round up divide by MCLBYTES. */
+ tval /= MCLBYTES;
+ printf("Consider increasing kern.ipc.maxsockbuf to a "
+ "minimum of %ju to support %ubyte NFS I/O\n",
+ (uintmax_t)tval, NFS_MAXBSIZE);
+ }
pktscale--;
}
if (nrp->nr_sotype == SOCK_DGRAM) {
@@ -255,10 +269,10 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq *nrp,
if (nrp->nr_sotype != SOCK_STREAM)
panic("nfscon sotype");
if (nmp != NULL) {
- sndreserve = (NFS_MAXBSIZE + NFS_MAXXDR +
- sizeof (u_int32_t)) * pktscale;
- rcvreserve = (NFS_MAXBSIZE + NFS_MAXXDR +
- sizeof (u_int32_t)) * pktscale;
+ sndreserve = (NFS_MAXBSIZE + NFS_MAXXDR) *
+ pktscale;
+ rcvreserve = (NFS_MAXBSIZE + NFS_MAXXDR) *
+ pktscale;
} else {
sndreserve = rcvreserve = 1024 * pktscale;
}