1

I'm trying to make a persistent change to sunrpc.tcp_slot_table_entries on a Linux CentOS 5.5. This value has been found important for the performance of our NFS clients, and must be set before the NFS mounts are done.

Simply putting the value in /etc/sysctl.conf doesn't work because /etc/rc.d/rc.sysinit (which does the sysctl -p) is executed before the sunrpc module is loaded.

Same problem with RHEL 4:

I tried to:

  • put install sunrpc /sbin/modprobe -q --ignore-install sunrpc;/sbin/sysctl -w sunrpc.tcp_slot_table_entries=64 in /etc/modprobe.conf (and in /etc/modprobe.d/sunrpc)
  • put SUBSYSTEM=="module" ACTION=="add" DEVPATH=="*/sunrpc" RUN+="/sbin/sysctl -w sunrpc.tcp_slot_table_entries=64" (maybe it has to be changed for CentOS 5) in /etc/udev/rules.d/23-sunrpc.rules but to no avail.

And I'd prefer not to modify /etc/init.d/netfs (from initscripts package).

So, have you succeeded in doing it properly on a CentOS 5, and if so, how ?

Edit: found in /etc/modprobe.d/modprobe.conf.dist:

install sunrpc /sbin/modprobe --first-time --ignore-install sunrpc && { /bin/mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs > /dev/null 2>&1 || :; }

That's maybe why my own addition to modprobe wasn't taken into account. But I'm not sure if I should modify directly that file, as it may be overwritten by module-init-tools updates ...

David142
  • 353
  • 1
  • 2
  • 9

4 Answers4

1

Finally I created an almost dummy init script, inserted at S15 (see in /etc/rc3.d/), as the module is loaded in S14 (nfslock) and used in S25 (netfs).

/etc/init.d/sunrpc_tuning:

#!/bin/sh
#
# sunrpc_tuning       Tunes /proc/sys/sunrpc (launched after lockd)
#
# chkconfig: 345 15 85
# description: set values to sunrpc after module is loaded
# probe: true

case "$1" in
   start)
      echo "Setting sunrpc.tcp_slot_table_entries ..."
      /sbin/sysctl -w sunrpc.tcp_slot_table_entries=128
      ;;
   *) ;;
esac

Then: chkconfig --add sunrpc_tuning

David142
  • 353
  • 1
  • 2
  • 9
1

I'm running RHEL5.4, and it seems that somehow the sysctl.conf settings are being applied (somehow?) before netfs mounts volumes. How did you verify this?

I modified the netfs initscript, to write the sunrpc.tcp_slot_table_entries value before nfs mounts were actioned, and it wrote out '128' vs the default '16'.

  start)
    # Let udev handle any backlog before trying to mount file systems
    /sbin/udevsettle --timeout=30
    [ -n "$NFSFSTAB" ] &&
      {
        [ ! -f /var/lock/subsys/portmap ] && service portmap start
 /sbin/sysctl sunrpc.tcp_slot_table_entries >> /tmp/sunrpc
        action $"Mounting NFS filesystems: " mount -a -t nfs,nfs4
jau
  • 11
  • 1
  • actually, sysctl is called in /etc/rc.d/rc.sysinit, which is executed before any runlevel initscripts get run, so I'm not sure why you have to do what you're doing here... – jau Nov 02 '11 at 14:05
  • _actually, sysctl is called in /etc/rc.d/rc.sysinit, which is executed before any runlevel initscripts get run, so I'm not sure why you have to do what you're doing here..._ The reason is that at sysinit time the sunrpc module isn't loaded so there's no /proc/sys/sunrpc to modify. It has to be done between sunrpc loading (network init) and nfs mounting. – David142 Nov 14 '12 at 13:42
0

You could put /sbin/sysctl -w sunrpc.tcp_slot_table_entries=64 in /etc/rc.d/rc.local.

Mark Wagner
  • 17,764
  • 2
  • 30
  • 47
  • `# This script will be executed *after* all the other init scripts.` so it's not useful as sysctl will be done *after* the NFS mounts, and the setting won't be taken into account. – David142 Sep 28 '10 at 07:08
0

I had tried something similar to what David142 tried, and this was on a RedHat 6.3 system, but I was finding that even at S15 or S20, it was still not being set out since the sunrpc kernel module was not loaded. Even when S52netfs starts and tries doing sysctl -p, it would fail.

The fix I tried was similar to yours, but I added a modprobe command:

#!/bin/bash
#
# set_nfs_parms        Set kernel parmeters for NFS
#
# chkconfig: 235 15 85
# description: At boot time, sunrpc.tcp_slot_table_entries cannot be set since
#              the nfs module is not loaded.  This sets it later in the boot
#              sequence. 
#

# Source function library.
. /etc/rc.d/init.d/functions

case "$1" in
    start)
          #/sbin/sysctl -w sunrpc.tcp_slot_table_entries=128
          /sbin/modprobe sunrpc
          /sbin/sysctl -p
       ;;
    stop)
       ;;
    *)
       echo $"Usage: $0 {start}"
       exit 2
esac
exit $?

After that, the parameter seems to reliably get set after a reboot.

Carl
  • 1