From 3f0574f34b5dcfdf1b9d8567c364702c3239f65b Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 11 Aug 2005 17:34:35 +0000 Subject: [PATCH] - Add an AFS_PRE_SHUTDOWN hook called before shutting down the client. - Provide a shutdown hook, disabled by default, that kills all processes with files open in /afs. Enabling this ensures a more reliable clean shutdown and umounting of the cache partition, but may not always be what the admin wants. This duplicates the functionality in the upstream init script (where it calls /usr/vice/etc/killafs if present), but in a more general way and with better documentation. --- debian/afs.conf | 17 +++++++++++++++++ debian/changelog | 5 +++++ debian/openafs-client.init | 29 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/debian/afs.conf b/debian/afs.conf index 78ce36b34..aa67e8724 100644 --- a/debian/afs.conf +++ b/debian/afs.conf @@ -97,3 +97,20 @@ AFS_POST_INIT= # have other commands that you also want to run, you'll have to put them in # that function, as you can only run one function.) #AFS_POST_INIT=afs_server_prefs + +# If you want to always run some command before shutting down OpenAFS, you can +# put it here. The same caveat applies about multiple commands. +AFS_PRE_SHUTDOWN= + +# If you are having problems with AFS shutting down cleanly or the system not +# rebooting because the partition the AFS cache was on could not be unmounted, +# try installing lsof and uncommenting this. This will cause all processes +# with open AFS files to be killed before unmounting AFS. +# +# Warning: This means /etc/init.d/openafs-client stop will kill all processes +# with files open in AFS rather than returning an error saying the file system +# is busy. This is what you want when the whole system is shutting down, but +# often *not* what you want when just stopping and restarting the client. +# OpenAFS has no way of distinguishing between those two cases. Only enable +# this if you're certain it's what you want. +#AFS_PRE_SHUTDOWN=kill_all_afs diff --git a/debian/changelog b/debian/changelog index 7df6e608c..829225317 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,11 @@ openafs (1.3.87-1) unstable; urgency=low - Choose the client options based on the cache size by default. - Move the code to build the options string to the init script from afs.conf so that afs.conf is pure configuration. + - Add an AFS_PRE_SHUTDOWN hook called before shutting down the client. + - Provide a shutdown hook, disabled by default, that kills all + processes with files open in /afs. Enabling this ensures a more + reliable clean shutdown and umounting of the cache partition, but + may not always be what the admin wants. - Improve the readability of the output on start. - Significantly improve the comments in afs.conf. - Remove the code to set -nosettime as it's now the default. diff --git a/debian/openafs-client.init b/debian/openafs-client.init index c495ccb44..a271fbfce 100755 --- a/debian/openafs-client.init +++ b/debian/openafs-client.init @@ -139,6 +139,34 @@ start_client() { fi } +# Kill all processes that are accessing AFS. Not enabled by default, and +# normally called via kill_all_afs. Warns and does nothing if lsof is not +# installed. +kill_afs() { + signal=$1 + pids=`/usr/bin/lsof -Fp /afs | sed 's/p//'` + if [ -n "$pids" ] ; then + kill -$signal $pids > /dev/null 2>&1 + sleep 1 + fi +} + +# Repeatedly call kill_afs for a series of signals to give AFS-using processes +# a hope of shutting down cleanly. Not enabled by default. Enable this in +# /etc/openafs/afs.conf (but see the warning in that file). +kill_all_afs() { + if [ -x /usr/bin/lsof ] ; then + echo -n "Killing processes with AFS files open: " + kill_afs HUP + kill_afs TERM + kill_afs ABRT + kill_afs KILL + echo "done." + else + echo '/usr/bin/lsof not found, not killing processes' >&2 + fi +} + case "$1" in start) @@ -170,6 +198,7 @@ force-start) ;; stop|force-stop) + $AFS_PRE_SHUTDOWN echo -n "Stopping AFS services:" if mount | grep -q '^AFS' ; then umount /afs -- 2.39.5