From 54ebd6abf68a5dcaec37ba51fbbc596d8404048b Mon Sep 17 00:00:00 2001 From: grev Date: Tue, 23 Dec 2008 13:13:35 +0000 Subject: [PATCH] b=17589 i=Nathan.Rutman i=Robert.Read zconf_umount_client{s} fix: kill ps-s before force umount --- lustre/tests/test-framework.sh | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index d9a058e..fd329d7 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -382,12 +382,27 @@ zconf_mount() { zconf_umount() { local client=$1 local mnt=$2 + local force + local busy + local need_kill + [ "$3" ] && force=-f local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true if [ $running -ne 0 ]; then echo "Stopping client $client $mnt (opts:$force)" - do_node $client lsof | grep "$mnt" || true - do_node $client umount $force $mnt + do_node $client lsof -t $mnt || need_kill=no + if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then + pids=$(do_node $client lsof -t $mnt | sort -u); + if [ -n $pids ]; then + do_node $client kill -9 $pids || true + fi + fi + + busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true + if [ $busy -ne 0 ] ; then + echo "$mnt is still busy, wait one second" && sleep 1 + do_node $client umount $force $mnt + fi fi } @@ -423,10 +438,27 @@ zconf_mount_clients() { zconf_umount_clients() { local clients=$1 local mnt=$2 + local force + [ "$3" ] && force=-f echo "Stopping clients: $clients $mnt (opts:$force)" - do_nodes $clients umount $force $mnt + do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts) +if [ \\\$running -ne 0 ] ; then +echo Stopping client \\\$(hostname) client $mnt opts:$force +lsof -t $mnt || need_kill=no +if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then + pids=\\\$(lsof -t $mnt | sort -u); + if [ -n \\\$pids ]; then + kill -9 \\\$pids + fi +fi +busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy") +if [ \\\$busy -ne 0 ] ; then + echo "$mnt is still busy, wait one second" && sleep 1 + umount $force $mnt +fi +fi" } shutdown_facet() { -- 1.8.3.1