Whamcloud - gitweb
b=14471
authorkomaln <komaln>
Tue, 10 Jun 2008 13:45:35 +0000 (13:45 +0000)
committerkomaln <komaln>
Tue, 10 Jun 2008 13:45:35 +0000 (13:45 +0000)
i=adilger

  replace /proc/fs/lustre access with lctl {get,set}_param in test-framework.sh

lustre/tests/test-framework.sh

index 241fc1c..0717e18 100644 (file)
@@ -432,15 +432,15 @@ cleanup_check() {
 }
 
 wait_delete_completed () {
-    local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
-            $LPROC/osc/*/kbytesavail`
+    local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
+                     awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
 
     local WAIT=0
     local MAX_WAIT=20
     while [ "$WAIT" -ne "$MAX_WAIT" ]; do
         sleep 1
-        TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
-            $LPROC/osc/*/kbytesavail`
+        TOTAL=`lctl get_param -n osc.*.kbytesavail | \
+               awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
         [ "$TOTAL" -eq "$TOTALPREV" ] && break
         echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
         TOTALPREV=$TOTAL
@@ -469,7 +469,7 @@ wait_mds_recovery_done () {
     MAX=$(( timeout * 4 ))
     WAIT=0
     while [ $WAIT -lt $MAX ]; do
-        STATUS=`do_facet mds grep status /proc/fs/lustre/mds/*-MDT*/recovery_status`
+        STATUS=`do_facet mds "lctl get_param -n mds.*-MDT*.recovery_status | grep status"`
         echo $STATUS | grep COMPLETE && return 0
         sleep 5
         WAIT=$((WAIT + 5))
@@ -560,13 +560,13 @@ replay_barrier_nodf() {
 }
 
 mds_evict_client() {
-    UUID=`cat /proc/fs/lustre/mdc/${mds_svc}-mdc-*/uuid`
-    do_facet mds "echo $UUID > /proc/fs/lustre/mds/${mds_svc}/evict_client"
+    UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
+    do_facet mds "lctl set_param -n mds.${mds_svc}.evict_client $UUID"
 }
 
 ost_evict_client() {
-    UUID=`cat /proc/fs/lustre/osc/${ost1_svc}-osc-*/uuid`
-    do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
+    UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
+    do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
 }
 
 fail() {
@@ -1062,10 +1062,8 @@ set_nodes_failloc () {
 
 cancel_lru_locks() {
     $LCTL mark "cancel_lru_locks $1 start"
-    for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
-        [ -f $d/lru_size ] && echo clear > $d/lru_size
-        [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
-    done
+    lctl set_param ldlm.namespaces.*$1*.lru_size=0
+    lctl get_param ldlm.namespaces.*$1*.lock_unused_count | grep -v '=0'
     $LCTL mark "cancel_lru_locks $1 stop"
 }
 
@@ -1078,33 +1076,21 @@ default_lru_size()
 
 lru_resize_enable()
 {
-        NS=$1
-        test "x$NS" = "x" && NS="mdc"
-        for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
-                D=$(dirname $F)
-                log "Enable lru resize for $(basename $D)"
-                echo "0" > $F
-        done
+    lctl set_param ldlm.namespaces.*$1*.lru_size=0
 }
 
 lru_resize_disable()
 {
-        NS=$1
-        test "x$NS" = "x" && NS="mdc"
-        for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
-                D=$(dirname $F)
-                log "Disable lru resize for $(basename $D)"
-                DEFAULT_LRU_SIZE=$(default_lru_size)
-                echo "$DEFAULT_LRU_SIZE" > $F
-        done
+    lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
 }
 
 pgcache_empty() {
-    for a in /proc/fs/lustre/llite/*/dump_page_cache; do
-        if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
-            echo there is still data in page cache $a ?
-            cat $a;
-            return 1;
+    local FILE
+    for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
+        if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
+            echo there is still data in page cache $FILE ?
+            lctl get_param -n $FILE
+            return 1
         fi
     done
     return 0
@@ -1274,8 +1260,8 @@ pass() {
 }
 
 check_mds() {
-    FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
-    FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
+    FFREE=`lctl get_param -n mds.*.filesfree`
+    FTOTAL=`lctl get_param -n mds.*.filestotal`
     [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
 }
 
@@ -1332,9 +1318,9 @@ check_grant() {
     [ "$CHECK_GRANT" == "no" ] && return 0
 
        testname=GCHECK_ONLY_${base}
-        [ ${!testname}x == x ] && return 0
+    [ ${!testname}x == x ] && return 0
 
-       echo -n "checking grant......"
+    echo -n "checking grant......"
        cd $SAVE_PWD
        # write some data to sync client lost_grant
        rm -f $DIR1/${tfile}_check_grant_* 2>&1
@@ -1343,18 +1329,18 @@ check_grant() {
                dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
                                              count=1 > /dev/null 2>&1 
        done
-       # sync all the data and make sure no pending data on server
-       sync_clients
-       
-       #get client grant and server grant 
-       client_grant=0
-    for d in ${LPROC}/osc/*/cur_grant_bytes; do 
-               client_grant=$((client_grant + `cat $d`))
-       done
-       server_grant=0
-       for d in ${LPROC}/obdfilter/*/tot_granted; do
-               server_grant=$((server_grant + `cat $d`))
-       done
+    # sync all the data and make sure no pending data on server
+    sync_clients
+
+    #get client grant and server grant
+    client_grant=0
+    for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
+        client_grant=$((client_grant + $d))
+    done
+    server_grant=0
+    for d in `lctl get_param -n obdfilter.*.tot_granted`; do
+        server_grant=$((server_grant + $d))
+    done
 
        # cleanup the check_grant file
        for i in `seq $OSTCOUNT`; do