@@ -684,6 +684,7 @@ AC_CONFIG_COMMANDS_PRE([eval eval _sysconfdir=$sysconfdir])
AC_CONFIG_FILES([
Makefile
systemd/rpc-gssd.service
+ systemd/nfs-config.service
linux-nfs/Makefile
support/Makefile
support/export/Makefile
@@ -1,9 +1,11 @@
#
# This is a general configuration for the
-# NFS daemons and tools
+# NFS daemons and tools and kernel module parameters
#
[general]
# pipefs-directory=/var/lib/nfs/rpc_pipefs
+[kernel]
+# nfs4_unique_id = [${machine-id} || ${hostname}]
#
[exports]
# rootdir=/export
@@ -9,6 +9,7 @@ unit_files = \
nfs-mountd.service \
nfs-server.service \
nfs-utils.service \
+ nfs-config.service \
rpc-statd-notify.service \
rpc-statd.service \
\
@@ -75,4 +76,6 @@ genexec_PROGRAMS = nfs-server-generator rpc-pipefs-generator
install-data-hook: $(unit_files)
mkdir -p $(DESTDIR)/$(unitdir)
cp $(unit_files) $(DESTDIR)/$(unitdir)
+ mkdir -p $(DESTDIR)/$(libexecdir)/nfs-utils
+ install nfs-conf-export.sh $(DESTDIR)/$(libexecdir)/nfs-utils/
endif
@@ -11,6 +11,9 @@ Wants=rpc-statd-notify.service
Wants=auth-rpcgss-module.service
After=rpc-gssd.service rpc-svcgssd.service gssproxy.service
+# Run the config settings that are in nfs.conf
+After=nfs-config.service
+
[Install]
WantedBy=multi-user.target
WantedBy=remote-fs.target
new file mode 100755
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# This script pulls values out of /etc/nfs.conf and configures
+# the appropriate kernel modules which cannot read it directly
+
+NFSMOD=/sys/module/nfs/parameters/nfs4_unique_id
+NFSPROBE=/etc/modprobe.d/nfs.conf
+
+# Now read the values from nfs.conf
+MACHINEID=`nfsconf --get kernel nfs4_unique_id`
+if [ $? -ne 0 ] || [ "$MACHINEID" == "" ]
+then
+# No config value found, nothing to do
+ exit 0
+fi
+
+# Kernel module is already loaded, update the live one
+if [ -e $NFSMOD ]; then
+echo -n "$MACHINEID" >> $NFSMOD
+fi
+
+# Rewrite the modprobe file for next reboot
+echo "# This file is overwritten by systemd nfs-config.service" > $NFSPROBE
+echo "# with values taken from /etc/nfs.conf" >> $NFSPROBE
+echo "# Do not hand modify" >> $NFSPROBE
+echo "options nfs nfs4_unique_id=\"$MACHINEID\"" >> $NFSPROBE
+
+echo "Set to: $MACHINEID"
new file mode 100644
@@ -0,0 +1,18 @@
+[Unit]
+Description=Preprocess NFS configuration
+PartOf=nfs-client.target
+Before=nfs-client.target
+After=local-fs.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+# This service needs to run any time any nfs service
+# is started, so changes to local config files get
+# incorporated. Having "RemainAfterExit=no" (the default)
+# ensures this happens.
+RemainAfterExit=no
+ExecStart=/usr/libexec/nfs-utils/nfs-conf-export.sh
+
+[Install]
+WantedBy=nfs-client.target
@@ -101,7 +101,7 @@ When a list is given, the members should be comma-separated.
.TP
.B general
Recognized values:
-.BR pipefs-directory .
+.BR pipefs-directory.
See
.BR blkmapd (8),
@@ -148,6 +148,23 @@ is equivalent to providing the
.B \-\-log\-auth
option.
+.TP
+.B kernel
+.br
+Recognized value:
+.BR nfs4_unique_id .
+
+Setting
+.B "nfs4_unique_id= ${machine-id}"
+will set the nfs4_unique_id kernel module parameter
+to the systems machine_id (/etc/machine-id)
+.BR
+
+Setting
+.BR "nfs4_unique_id= ${hostname}"
+will set the nfs4_unique_id kernel module parameter
+to the systems hostname (/etc/hostname)
+
.TP
.B nfsdcltrack
Recognized values: