From 4336d178fad88e0fbdd34cae12652f54139e7825 Mon Sep 17 00:00:00 2001
From: rread <rread>
Date: Tue, 6 Jan 2004 00:58:08 +0000
Subject: [PATCH] b=2460

Add a test to recovery-small to trigger this bug. Also fix some
typos/brainos in recovery-small and test-framework, and set the debug
level to the default for local configs,
---
 lustre/tests/cfg/local.sh      |  2 +-
 lustre/tests/recovery-small.sh | 20 +++++++++++++++++---
 lustre/tests/test-framework.sh | 23 ++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh
index 1e41cff87a..a7350221ed 100644
--- a/lustre/tests/cfg/local.sh
+++ b/lustre/tests/cfg/local.sh
@@ -15,7 +15,7 @@ MOUNT1=${MOUNT1:-$MOUNT}
 MOUNT2=${MOUNT2:-"/mnt/lustre2"}
 DIR=${DIR:-$MOUNT}
 DIR2=${DIR2:-$MOUNT1}
-PTLDEBUG=${PTLDEBUG:-0}
+PTLDEBUG=${PTLDEBUG:-0x3f0400}
 PDSH=${PDSH:-no_dsh}
 
 MDSDEV=${MDSDEV:-$ROOT/tmp/mds-`hostname`}
diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh
index 3b737e788b..35ab93448c 100755
--- a/lustre/tests/recovery-small.sh
+++ b/lustre/tests/recovery-small.sh
@@ -9,8 +9,6 @@ init_test_env $@
 
 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
 
-. $LUSTRE/tests/test-framework.sh
-
 build_test_filter
 
 
@@ -135,6 +133,22 @@ test_10() {
     do_facet client checkstat -v -p 0777 $MOUNT/f10  || return 3
     do_facet client "munlink $MOUNT/f10"
 }
-run_test 10 "finish request after client eviction (bug 1521)"
+run_test 10 "finish request on server after client eviction (bug 1521)"
+
+#bug 2460
+# wake up a thead waiting for completion after eviction
+test_11(){
+    do_facet client multiop $MOUNT/$tfile Ow  || return 1
+    do_facet client multiop $MOUNT/$tfile or  || return 2
 
+    cancel_lru_locks OSC
+
+    do_facet client multiop $MOUNT/$tfile or  || return 3
+    drop_bl_callback multiop $MOUNT/$tfile Ow  || 
+        echo "client evicted, as expected"
+
+    do_facet client unlink $MOUNT/$tfile  || return 4
+}
+run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
 $CLEANUP
+    
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index 610c26831d..4c49e83780 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -2,6 +2,9 @@
 
 set -e
 
+export REFORMAT=""
+export VERBOSE=false
+
 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
 assert_env() {
     local failed=""
@@ -247,7 +250,7 @@ do_node() {
     shift
 
     if $VERBOSE; then
-	echo "CMD $HOST $@"
+	echo "CMD: $HOST $@"
     fi
     $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
 }
@@ -389,6 +392,15 @@ pause_bulk() {
     return $RC
 }
 
+drop_ldlm_cancel() {
+#define OBD_FAIL_LDLM_CANCEL             0x304
+    RC=0
+    do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
+    do_facet client "$@" || RC=$?
+    do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
+    return $RC
+}
+
 drop_bl_callback() {
 #define OBD_FAIL_LDLM_BL_CALLBACK        0x305
     RC=0
@@ -398,6 +410,15 @@ drop_bl_callback() {
     return $RC
 }
 
+cancel_lru_locks() {
+	for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
+	    if [ -f $d/lru_size ]; then
+		echo clear > $d/lru_size
+		grep [0-9] $d/lock_unused_count
+	    fi
+	done
+}
+
 ##################################
 # Test interface 
 error() {
-- 
GitLab