diff --git a/src/packaging/RedHat/openafs-client-systemd-helper.sh b/src/packaging/RedHat/openafs-client-systemd-helper.sh index 32221ef716..df8bdcf0ae 100755 --- a/src/packaging/RedHat/openafs-client-systemd-helper.sh +++ b/src/packaging/RedHat/openafs-client-systemd-helper.sh @@ -5,6 +5,8 @@ set -e +UMOUNT_TIMEOUT=30 + [ -f /etc/sysconfig/openafs ] && . /etc/sysconfig/openafs case $1 in @@ -38,6 +40,28 @@ case $1 in else echo "Failed to unmount /afs: $?" fi + + state=$(systemctl is-system-running || true) + if [ "$state" = stopping ] && [ x"$UMOUNT_TIMEOUT" != x ] && /bin/mountpoint --quiet /afs ; then + # If we are shutting down the system, failing to umount /afs + # can lead to longer delays later as systemd tries to forcibly + # kill our afsd processes. So retry the umount a few times, + # just in case other /afs-using processes just need a few + # seconds to go away. + echo "For system shutdown, retrying umount /afs for $UMOUNT_TIMEOUT secs" + interval=3 + for (( i = 0; i < $UMOUNT_TIMEOUT; i += $interval )) ; do + sleep $interval + if /bin/umount --verbose /afs ; then + exit 0 + fi + if ! /bin/mountpoint --quiet /afs ; then + echo "mountpoint /afs disappeared; bailing out" + exit 0 + fi + done + echo "Still cannot umount /afs, bailing out" + fi exit 1 ;;