Add a sysctl to specify the amount of UDP receive space NFS should

reserve, in maximal NFS packets.  Originally only 2 packets worth of
    space was reserved.  The default is now 4, which appears to greatly
    improve performance for slow to mid-speed machines on gigabit networks.

    Add documentation and correct some prior documentation.

Problem Researched by: Andrew Gallatin <gallatin@cs.duke.edu>
Approved by: jkh
This commit is contained in:
Matthew Dillon 2000-03-27 21:38:35 +00:00
parent 25db2c5417
commit 8d1b3828fa
12 changed files with 110 additions and 25 deletions

View File

@ -109,6 +109,7 @@ nfs_server_flags="-u -t -n 4" # Flags to nfsd (if enabled).
single_mountd_enable="NO" # Run mountd only (or NO).
mountd_flags="-r" # Flags to mountd (if NFS server enabled).
nfs_reserved_port_only="NO" # Provide NFS only on secure port (or NO).
nfs_bufpackets="DEFAULT" # bufspace (in packets) for client (or DEFAULT)
rpc_lockd_enable="NO" # Run NFS rpc.lockd (*broken!*) if nfs_server.
rpc_statd_enable="YES" # Run NFS rpc.statd if nfs_server (or NO).
portmap_enable="YES" # Run the portmapper service (or NO).

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -493,6 +493,11 @@ network_pass3() {
echo -n ' nfsd'; nfsd ${nfs_server_flags}
if [ -n "${nfs_bufpackets}" ]; then
sysctl -w vfs.nfs.bufpackets=${nfs_bufpackets} \
> /dev/null
fi
case ${rpc_lockd_enable} in
[Yy][Ee][Ss])
echo -n ' rpc.lockd'; rpc.lockd

View File

@ -491,10 +491,17 @@ It is commonly needed to run CFS without real NFS used.
.Ar YES ,
allow services like PCNFSD to make non-privileged mount
requests.
.It Ar nfs_reserved_port_only
.It Ar nfs_privport
(bool) If set to
.Ar YES ,
provide NFS services only on a secure port.
.It Ar nfs_bufpackets
(integer) If set to a number, indicates the number of packets worth of
socket buffer space to reserve on an NFS client. If set to
.Ar DEFAULT ,
the kernel default is used (typically 4). Using a higher number may be
useful on gigabit networks to improve performance. The minimum value is
2 and the maximum is 64.
.It Ar rcp_lockd_enable
(bool) If set to
.Ar YES

View File

@ -119,11 +119,13 @@ static int proct[NFS_NPROCS] = {
static int nfs_realign_test;
static int nfs_realign_count;
static int nfs_bufpackets = 4;
SYSCTL_DECL(_vfs_nfs);
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RD, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RD, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "");
/*
@ -201,6 +203,7 @@ nfs_connect(nmp, rep)
{
register struct socket *so;
int s, error, rcvreserve, sndreserve;
int pktscale;
struct sockaddr *saddr;
struct sockaddr_in *sin;
struct proc *p = &proc0; /* only used for socreate and sobind */
@ -301,14 +304,25 @@ nfs_connect(nmp, rep)
so->so_rcv.sb_timeo = 0;
so->so_snd.sb_timeo = 0;
}
/*
* Get buffer reservation size from sysctl, but impose reasonable
* limits.
*/
pktscale = nfs_bufpackets;
if (pktscale < 2)
pktscale = 2;
if (pktscale > 64)
pktscale = 64;
if (nmp->nm_sotype == SOCK_DGRAM) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else if (nmp->nm_sotype == SOCK_SEQPACKET) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else {
if (nmp->nm_sotype != SOCK_STREAM)
panic("nfscon sotype");
@ -337,9 +351,9 @@ nfs_connect(nmp, rep)
sosetopt(so, &sopt);
}
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
}
error = soreserve(so, sndreserve, rcvreserve);
if (error)

View File

@ -119,11 +119,13 @@ static int proct[NFS_NPROCS] = {
static int nfs_realign_test;
static int nfs_realign_count;
static int nfs_bufpackets = 4;
SYSCTL_DECL(_vfs_nfs);
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RD, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RD, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "");
/*
@ -201,6 +203,7 @@ nfs_connect(nmp, rep)
{
register struct socket *so;
int s, error, rcvreserve, sndreserve;
int pktscale;
struct sockaddr *saddr;
struct sockaddr_in *sin;
struct proc *p = &proc0; /* only used for socreate and sobind */
@ -301,14 +304,25 @@ nfs_connect(nmp, rep)
so->so_rcv.sb_timeo = 0;
so->so_snd.sb_timeo = 0;
}
/*
* Get buffer reservation size from sysctl, but impose reasonable
* limits.
*/
pktscale = nfs_bufpackets;
if (pktscale < 2)
pktscale = 2;
if (pktscale > 64)
pktscale = 64;
if (nmp->nm_sotype == SOCK_DGRAM) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else if (nmp->nm_sotype == SOCK_SEQPACKET) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else {
if (nmp->nm_sotype != SOCK_STREAM)
panic("nfscon sotype");
@ -337,9 +351,9 @@ nfs_connect(nmp, rep)
sosetopt(so, &sopt);
}
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
}
error = soreserve(so, sndreserve, rcvreserve);
if (error)

View File

@ -119,11 +119,13 @@ static int proct[NFS_NPROCS] = {
static int nfs_realign_test;
static int nfs_realign_count;
static int nfs_bufpackets = 4;
SYSCTL_DECL(_vfs_nfs);
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RD, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RD, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "");
SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "");
/*
@ -201,6 +203,7 @@ nfs_connect(nmp, rep)
{
register struct socket *so;
int s, error, rcvreserve, sndreserve;
int pktscale;
struct sockaddr *saddr;
struct sockaddr_in *sin;
struct proc *p = &proc0; /* only used for socreate and sobind */
@ -301,14 +304,25 @@ nfs_connect(nmp, rep)
so->so_rcv.sb_timeo = 0;
so->so_snd.sb_timeo = 0;
}
/*
* Get buffer reservation size from sysctl, but impose reasonable
* limits.
*/
pktscale = nfs_bufpackets;
if (pktscale < 2)
pktscale = 2;
if (pktscale > 64)
pktscale = 64;
if (nmp->nm_sotype == SOCK_DGRAM) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else if (nmp->nm_sotype == SOCK_SEQPACKET) {
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
NFS_MAXPKTHDR) * 2;
NFS_MAXPKTHDR) * pktscale;
} else {
if (nmp->nm_sotype != SOCK_STREAM)
panic("nfscon sotype");
@ -337,9 +351,9 @@ nfs_connect(nmp, rep)
sosetopt(so, &sopt);
}
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
sizeof (u_int32_t)) * 2;
sizeof (u_int32_t)) * pktscale;
}
error = soreserve(so, sndreserve, rcvreserve);
if (error)