git: 5509bad74e44 - main - nfsd: Add a new rc variable nfs_server_maxio

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 17 Nov 2021 00:06:40 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=5509bad74e44eed3b9d54fbd74d3752b88428147

commit 5509bad74e44eed3b9d54fbd74d3752b88428147
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-17 00:02:53 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-17 00:02:53 +0000

    nfsd: Add a new rc variable nfs_server_maxio
    
    Since vfs.nfsd.srvmaxio can only be set when nfsd.ko
    is loaded, but nfsd is not running, setting it in
    /etc/sysctl.conf is not feasible when "options NFSD"
    was not specified for the kernel.
    
    This patch adds a new rc variable nfs_server_maxio,
    which sets vfs.nfsd.srvmaxio at the correct time.
    
    rc.conf.5 will be patched separately.
    
    Reviewed by:    0mp
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D32997
---
 libexec/rc/rc.conf   | 1 +
 libexec/rc/rc.d/nfsd | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 0cfee2d9c194..b27e1154a5e7 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -359,6 +359,7 @@ nfs_access_cache="60"		# Client cache timeout in seconds
 nfs_server_enable="NO"		# This host is an NFS server (or NO).
 nfs_server_flags="-u -t"	# Flags to nfsd (if enabled).
 nfs_server_managegids="NO"	# The NFS server maps gids for AUTH_SYS (or NO).
+nfs_server_maxio="131072"	# Maximum I/O size for the nfsd.
 mountd_enable="NO"		# Run mountd (or NO).
 mountd_flags="-r -S"		# Flags to mountd (if NFS server enabled).
 weak_mountd_authentication="NO"	# Allow non-root mount requests to be served.
diff --git a/libexec/rc/rc.d/nfsd b/libexec/rc/rc.d/nfsd
index 1d0689b3beb7..b746cf7cea9d 100755
--- a/libexec/rc/rc.d/nfsd
+++ b/libexec/rc/rc.d/nfsd
@@ -28,6 +28,12 @@ nfsd_precmd()
 	# oids are available.
 	load_kld nfsd || return 1
 
+	if [ -n "${nfs_server_maxio}" ]; then
+		if ! sysctl vfs.nfsd.srvmaxio=${nfs_server_maxio} >/dev/null; then
+			warn "Failed to set server max I/O"
+		fi
+	fi
+
 	if checkyesno nfs_reserved_port_only; then
 		echo 'NFS on reserved port only=YES'
 		sysctl vfs.nfsd.nfs_privport=1 > /dev/null