|
|
2de1a8 |
From 764757380af19d3a21d40f3c9624e4135ff074e1 Mon Sep 17 00:00:00 2001
|
|
|
2de1a8 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
2de1a8 |
Date: Wed, 2 Nov 2022 10:26:31 +0100
|
|
|
2de1a8 |
Subject: [PATCH] nfsserver: add nfsv4_only parameter to make it run without
|
|
|
2de1a8 |
rpc-statd/rpcbind services
|
|
|
2de1a8 |
|
|
|
2de1a8 |
---
|
|
|
2de1a8 |
heartbeat/nfsserver | 200 +++++++++++++++++++++++++-------------------
|
|
|
2de1a8 |
1 file changed, 114 insertions(+), 86 deletions(-)
|
|
|
2de1a8 |
|
|
|
2de1a8 |
diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
|
|
|
2de1a8 |
index 9bbd603e5..cb2d43ab1 100755
|
|
|
2de1a8 |
--- a/heartbeat/nfsserver
|
|
|
2de1a8 |
+++ b/heartbeat/nfsserver
|
|
|
2de1a8 |
@@ -79,6 +79,16 @@ Init script for nfsserver
|
|
|
2de1a8 |
<content type="string" default="auto detected" />
|
|
|
2de1a8 |
</parameter>
|
|
|
2de1a8 |
|
|
|
2de1a8 |
+<parameter name="nfsv4_only" unique="0" required="0">
|
|
|
2de1a8 |
+<longdesc lang="en">
|
|
|
2de1a8 |
+Run in NFSv4 only mode (rpc-statd and rpcbind services masked).
|
|
|
2de1a8 |
+</longdesc>
|
|
|
2de1a8 |
+<shortdesc lang="en">
|
|
|
2de1a8 |
+NFSv4 only mode.
|
|
|
2de1a8 |
+</shortdesc>
|
|
|
2de1a8 |
+<content type="boolean" default="false" />
|
|
|
2de1a8 |
+</parameter>
|
|
|
2de1a8 |
+
|
|
|
2de1a8 |
<parameter name="nfs_no_notify" unique="0" required="0">
|
|
|
2de1a8 |
<longdesc lang="en">
|
|
|
2de1a8 |
Do not send reboot notifications to NFSv3 clients during server startup.
|
|
|
2de1a8 |
@@ -332,7 +342,7 @@ v3locking_exec()
|
|
|
2de1a8 |
if [ $EXEC_MODE -eq 2 ]; then
|
|
|
2de1a8 |
nfs_exec $cmd nfs-lock.service
|
|
|
2de1a8 |
elif [ $EXEC_MODE -eq 3 ]; then
|
|
|
2de1a8 |
- nfs_exec $cmd rpc-statd.service
|
|
|
2de1a8 |
+ nfs_exec $cmd rpc-statd.service
|
|
|
2de1a8 |
else
|
|
|
2de1a8 |
case $cmd in
|
|
|
2de1a8 |
start) locking_start;;
|
|
|
2de1a8 |
@@ -348,20 +358,22 @@ nfsserver_systemd_monitor()
|
|
|
2de1a8 |
local rc
|
|
|
2de1a8 |
local fn
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- ocf_log debug "Status: rpcbind"
|
|
|
2de1a8 |
- rpcinfo > /dev/null 2>&1
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "rpcbind is not running"
|
|
|
2de1a8 |
- return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
- fi
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ ocf_log debug "Status: rpcbind"
|
|
|
2de1a8 |
+ rpcinfo > /dev/null 2>&1
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "rpcbind is not running"
|
|
|
2de1a8 |
+ return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- ocf_log debug "Status: nfs-mountd"
|
|
|
2de1a8 |
- ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "nfs-mountd is not running"
|
|
|
2de1a8 |
- return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
+ ocf_log debug "Status: nfs-mountd"
|
|
|
2de1a8 |
+ ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "nfs-mountd is not running"
|
|
|
2de1a8 |
+ return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
ocf_log debug "Status: nfs-idmapd"
|
|
|
2de1a8 |
@@ -375,12 +387,14 @@ nfsserver_systemd_monitor()
|
|
|
2de1a8 |
return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- ocf_log debug "Status: rpc-statd"
|
|
|
2de1a8 |
- rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "rpc-statd is not running"
|
|
|
2de1a8 |
- return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ ocf_log debug "Status: rpc-statd"
|
|
|
2de1a8 |
+ rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -ne "0" ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "rpc-statd is not running"
|
|
|
2de1a8 |
+ return $OCF_NOT_RUNNING
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
nfs_exec is-active nfs-server
|
|
|
2de1a8 |
@@ -424,7 +438,7 @@ nfsserver_monitor ()
|
|
|
2de1a8 |
if [ $rc -eq 0 ]; then
|
|
|
2de1a8 |
# don't report success if nfs servers are up
|
|
|
2de1a8 |
# without locking daemons.
|
|
|
2de1a8 |
- v3locking_exec "status"
|
|
|
2de1a8 |
+ ocf_is_true "$OCF_RESKEY_nfsv4_only" || v3locking_exec "status"
|
|
|
2de1a8 |
rc=$?
|
|
|
2de1a8 |
if [ $rc -ne 0 ]; then
|
|
|
2de1a8 |
ocf_exit_reason "NFS server is up, but the locking daemons are down"
|
|
|
2de1a8 |
@@ -786,48 +800,54 @@ nfsserver_start ()
|
|
|
2de1a8 |
|
|
|
2de1a8 |
# systemd
|
|
|
2de1a8 |
case $EXEC_MODE in
|
|
|
2de1a8 |
- [23]) nfs_exec start rpcbind
|
|
|
2de1a8 |
- local i=1
|
|
|
2de1a8 |
- while : ; do
|
|
|
2de1a8 |
- ocf_log info "Start: rpcbind i: $i"
|
|
|
2de1a8 |
- rpcinfo > /dev/null 2>&1
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- break;
|
|
|
2de1a8 |
- fi
|
|
|
2de1a8 |
- sleep 1
|
|
|
2de1a8 |
- i=$((i + 1))
|
|
|
2de1a8 |
- done
|
|
|
2de1a8 |
+ [23]) if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ nfs_exec start rpcbind
|
|
|
2de1a8 |
+ local i=1
|
|
|
2de1a8 |
+ while : ; do
|
|
|
2de1a8 |
+ ocf_log info "Start: rpcbind i: $i"
|
|
|
2de1a8 |
+ rpcinfo > /dev/null 2>&1
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
+ break
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
+ sleep 1
|
|
|
2de1a8 |
+ i=$((i + 1))
|
|
|
2de1a8 |
+ done
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
;;
|
|
|
2de1a8 |
esac
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- # check to see if we need to start rpc.statd
|
|
|
2de1a8 |
- v3locking_exec "status"
|
|
|
2de1a8 |
- if [ $? -ne $OCF_SUCCESS ]; then
|
|
|
2de1a8 |
- v3locking_exec "start"
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ $rc -ne 0 ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "Failed to start NFS server locking daemons"
|
|
|
2de1a8 |
- return $rc
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ # check to see if we need to start rpc.statd
|
|
|
2de1a8 |
+ v3locking_exec "status"
|
|
|
2de1a8 |
+ if [ $? -ne $OCF_SUCCESS ]; then
|
|
|
2de1a8 |
+ v3locking_exec "start"
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ $rc -ne 0 ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "Failed to start NFS server locking daemons"
|
|
|
2de1a8 |
+ return $rc
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
+ else
|
|
|
2de1a8 |
+ ocf_log info "rpc.statd already up"
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
- else
|
|
|
2de1a8 |
- ocf_log info "rpc.statd already up"
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
# systemd
|
|
|
2de1a8 |
case $EXEC_MODE in
|
|
|
2de1a8 |
- [23]) nfs_exec start nfs-mountd
|
|
|
2de1a8 |
- local i=1
|
|
|
2de1a8 |
- while : ; do
|
|
|
2de1a8 |
- ocf_log info "Start: nfs-mountd i: $i"
|
|
|
2de1a8 |
- ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- break;
|
|
|
2de1a8 |
- fi
|
|
|
2de1a8 |
- sleep 1
|
|
|
2de1a8 |
- i=$((i + 1))
|
|
|
2de1a8 |
- done
|
|
|
2de1a8 |
+ [23]) if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ nfs_exec start nfs-mountd
|
|
|
2de1a8 |
+ local i=1
|
|
|
2de1a8 |
+ while : ; do
|
|
|
2de1a8 |
+ ocf_log info "Start: nfs-mountd i: $i"
|
|
|
2de1a8 |
+ ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
+ break
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
+ sleep 1
|
|
|
2de1a8 |
+ i=$((i + 1))
|
|
|
2de1a8 |
+ done
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
nfs_exec start nfs-idmapd
|
|
|
2de1a8 |
local i=1
|
|
|
2de1a8 |
@@ -839,24 +859,26 @@ nfsserver_start ()
|
|
|
2de1a8 |
ocf_log debug "$(cat $fn)"
|
|
|
2de1a8 |
rm -f $fn
|
|
|
2de1a8 |
if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- break;
|
|
|
2de1a8 |
+ break
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
sleep 1
|
|
|
2de1a8 |
i=$((i + 1))
|
|
|
2de1a8 |
done
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- nfs_exec start rpc-statd
|
|
|
2de1a8 |
- local i=1
|
|
|
2de1a8 |
- while : ; do
|
|
|
2de1a8 |
- ocf_log info "Start: rpc-statd i: $i"
|
|
|
2de1a8 |
- rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- break;
|
|
|
2de1a8 |
- fi
|
|
|
2de1a8 |
- sleep 1
|
|
|
2de1a8 |
- i=$((i + 1))
|
|
|
2de1a8 |
- done
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ nfs_exec start rpc-statd
|
|
|
2de1a8 |
+ local i=1
|
|
|
2de1a8 |
+ while : ; do
|
|
|
2de1a8 |
+ ocf_log info "Start: rpc-statd i: $i"
|
|
|
2de1a8 |
+ rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
+ break
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
+ sleep 1
|
|
|
2de1a8 |
+ i=$((i + 1))
|
|
|
2de1a8 |
+ done
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
esac
|
|
|
2de1a8 |
|
|
|
2de1a8 |
|
|
|
2de1a8 |
@@ -914,13 +936,15 @@ nfsserver_stop ()
|
|
|
2de1a8 |
sleep 1
|
|
|
2de1a8 |
done
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- nfs_exec stop rpc-statd > /dev/null 2>&1
|
|
|
2de1a8 |
- ocf_log info "Stop: rpc-statd"
|
|
|
2de1a8 |
- rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "Failed to stop rpc-statd"
|
|
|
2de1a8 |
- return $OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ nfs_exec stop rpc-statd > /dev/null 2>&1
|
|
|
2de1a8 |
+ ocf_log info "Stop: rpc-statd"
|
|
|
2de1a8 |
+ rpcinfo -t localhost 100024 > /dev/null 2>&1
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "Failed to stop rpc-statd"
|
|
|
2de1a8 |
+ return $OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
nfs_exec stop nfs-idmapd > /dev/null 2>&1
|
|
|
2de1a8 |
@@ -935,13 +959,15 @@ nfsserver_stop ()
|
|
|
2de1a8 |
return $OCF_ERR_GENERIC
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- nfs_exec stop nfs-mountd > /dev/null 2>&1
|
|
|
2de1a8 |
- ocf_log info "Stop: nfs-mountd"
|
|
|
2de1a8 |
- ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
- rc=$?
|
|
|
2de1a8 |
- if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "Failed to stop nfs-mountd"
|
|
|
2de1a8 |
- return $OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ nfs_exec stop nfs-mountd > /dev/null 2>&1
|
|
|
2de1a8 |
+ ocf_log info "Stop: nfs-mountd"
|
|
|
2de1a8 |
+ ps axww | grep -q "[r]pc.mountd"
|
|
|
2de1a8 |
+ rc=$?
|
|
|
2de1a8 |
+ if [ "$rc" -eq "0" ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "Failed to stop nfs-mountd"
|
|
|
2de1a8 |
+ return $OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
if systemctl --no-legend list-unit-files "nfsdcld*" | grep -q nfsdcld; then
|
|
|
2de1a8 |
@@ -960,10 +986,12 @@ nfsserver_stop ()
|
|
|
2de1a8 |
esac
|
|
|
2de1a8 |
|
|
|
2de1a8 |
|
|
|
2de1a8 |
- v3locking_exec "stop"
|
|
|
2de1a8 |
- if [ $? -ne 0 ]; then
|
|
|
2de1a8 |
- ocf_exit_reason "Failed to stop NFS locking daemons"
|
|
|
2de1a8 |
- rc=$OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
|
|
|
2de1a8 |
+ v3locking_exec "stop"
|
|
|
2de1a8 |
+ if [ $? -ne 0 ]; then
|
|
|
2de1a8 |
+ ocf_exit_reason "Failed to stop NFS locking daemons"
|
|
|
2de1a8 |
+ rc=$OCF_ERR_GENERIC
|
|
|
2de1a8 |
+ fi
|
|
|
2de1a8 |
fi
|
|
|
2de1a8 |
|
|
|
2de1a8 |
# systemd
|