Whamcloud - gitweb
LU-1526 tests: Handle OFD procfs changes
authorYu Jian <yujian@whamcloud.com>
Tue, 8 Jan 2013 08:09:02 +0000 (16:09 +0800)
committerJohann Lombardi <johann.lombardi@intel.com>
Thu, 10 Jan 2013 09:21:09 +0000 (04:21 -0500)
In order to interop with 2.4 server, the following procfs entry
changes need to be handled:

- obdfilter.*.mntdev -> osd-*.*.mntdev
- obdfilter.*.<cache_related> -> osd-*.*.<cache_related>

Test-Parameters: envdefinitions=SLOW=yes,ENABLE_QUOTA=yes clientarch=x86_64 serverarch=x86_64 testlist=lfsck,sanity
Signed-off-by: Yu Jian <yujian@whamcloud.com>
Change-Id: I74bfaa1e6d68203951de31676f23fbd8250ec652
Reviewed-on: http://review.whamcloud.com/4958
Reviewed-by: Li Wei <wei.g.li@intel.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/tests/lfsck.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index c82b72f..55c2b04 100644 (file)
@@ -126,13 +126,14 @@ get_ost_dev() {
     local ost_dev
 
     ost_name=$(ostname_from_index $obdidx)
-    ost_dev=$(do_node $node "lctl get_param -n obdfilter.${ost_name}.mntdev")
-    [ ${PIPESTATUS[0]} -ne 0 ] && \
-        echo "failed to find the OST device with index $obdidx on $facet" && \
+    ost_dev=$(get_obdfilter_param $node $ost_name mntdev)
+    if [ $? -ne 0 ]; then
+        printf "unable to find OST%04x on $facet\n" $obdidx
         return 1
+    fi
 
     if [[ $ost_dev = *loop* ]]; then
-        ost_dev=$(do_node $node "losetup $ost_dev" | \
+        ost_dev=$(do_node $node "losetup $ost_dev" |
                 sed -e "s/.*(//" -e "s/).*//")
     fi
 
index 62b6a00..3b54e03 100644 (file)
@@ -4092,8 +4092,10 @@ setup_test101bc() {
        STRIPE_COUNT=$OSTCOUNT
        STRIPE_OFFSET=0
 
-       $LCTL set_param -n obdfilter.*.read_cache_enable=0
-       $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
+       local list=$(comma_list $(osts_nodes))
+       set_obdfilter_param $list '' read_cache_enable 0
+       set_obdfilter_param $list '' writethrough_cache_enable 0
+
        trap cleanup_test101bc EXIT
        # prepare the read-ahead file
        $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
@@ -4105,8 +4107,10 @@ cleanup_test101bc() {
        trap 0
        rm -rf $DIR/$tdir
        rm -f $DIR/$tfile
-       $LCTL set_param -n obdfilter.*.read_cache_enable=1
-       $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
+
+       local list=$(comma_list $(osts_nodes))
+       set_obdfilter_param $list '' read_cache_enable 1
+       set_obdfilter_param $list '' writethrough_cache_enable 1
 }
 
 calc_total() {
@@ -6335,9 +6339,8 @@ run_test 150 "truncate/append tests"
 function roc_hit() {
     local list=$(comma_list $(osts_nodes))
 
-    ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
+    echo $(get_obdfilter_param $list '' stats |
         awk '/'cache_hit'/ {sum+=$2} END {print sum}')
-    echo $ACCNUM
 }
 
 function set_cache() {
@@ -6347,7 +6350,7 @@ function set_cache() {
         on=0;
     fi
     local list=$(comma_list $(osts_nodes))
-    do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
+    set_obdfilter_param $list '' $1_cache_enable $on
 
     cancel_lru_locks osc
 }
@@ -6363,14 +6366,14 @@ test_151() {
        local CPAGES=3
 
        # check whether obdfilter is cache capable at all
-       if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
+       if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
                echo "not cache-capable obdfilter"
                return 0
        fi
 
        # make sure cache is enabled on all obdfilters
-       do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
-       do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
+       set_obdfilter_param $list '' read_cache_enable 1
+       set_obdfilter_param $list '' writethrough_cache_enable 1
 
        # pages should be in the case right after write
        dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
@@ -6384,7 +6387,7 @@ test_151() {
 
        # the following read invalidates the cache
        cancel_lru_locks osc
-       do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
+       set_obdfilter_param $list '' read_cache_enable 0
        cat $DIR/$tfile >/dev/null
 
        # now data shouldn't be found in the cache
@@ -6396,8 +6399,8 @@ test_151() {
                error "IN CACHE: before: $BEFORE, after: $AFTER"
        fi
 
-       do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
-       do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
+       set_obdfilter_param $list '' read_cache_enable 1
+       set_obdfilter_param $list '' writethrough_cache_enable 1
        rm -f $DIR/$tfile
 }
 run_test 151 "test cache on oss and controls ==============================="
index 4980849..da3c142 100644 (file)
@@ -405,6 +405,34 @@ unload_modules() {
     return 0
 }
 
+#
+# This and set_obdfilter_param() shall be used to access OBDFilter parameters
+# moved to OSD in 2.3, 2.4, or later server versions.
+#
+#   mntdev
+#   stats
+#   read_cache_enable
+#   writethrough_cache_enable
+#
+get_obdfilter_param() {
+    local nodes=$1
+    local device=${2:-$FSNAME-OST*}
+    local name=$3
+
+    do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
+        osd-*.$device.$name 2>&1" | grep -v 'Found no match'
+}
+
+set_obdfilter_param() {
+    local nodes=$1
+    local device=${2:-$FSNAME-OST*}
+    local name=$3
+    local value=$4
+
+    do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
+        osd-*.$device.$name=$value 2>&1" | grep -v 'Found no match'
+}
+
 set_debug_size () {
     local dz=${1:-$DEBUG_SIZE}
     local cpus=$(getconf _NPROCESSORS_CONF)
@@ -2411,17 +2439,15 @@ cleanup_and_setup_lustre() {
 get_mnt_devs() {
     local node=$1
     local type=$2
-    local obd_type
     local devs
     local dev
 
-    case $type in
-    mdt) obd_type="osd" ;;
-    ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
-    *) echo "invalid server type" && return 1 ;;
-    esac
-
-    devs=$(do_node $node "lctl get_param -n $obd_type.*.mntdev")
+    if [ "$type" == ost ]; then
+        devs=$(get_obdfilter_param $node "" mntdev)
+    else
+        devs=$(do_node $node \
+            "lctl get_param -n osd-*.$FSNAME-M*.mntdev")
+    fi
     for dev in $devs; do
         case $dev in
         *loop*) do_node $node "losetup $dev" | \