+# OR
+# one can specify only case=disk or case=network or case=netdisk through
+# command line.
+
+# Perquisite: For "disk" case and "netdisk" case you need to have lustre setup
+# with one or more ost's. For "network" case you need to have all
+# modules (those llmount.sh loades) loaded in kernel. And the
+# 'lctl dl' output must be blank.
+
+# How to run test:
+# case 1 (local disk):
+# $ nobjhi=2 thrhi=2 size=1024 case=disk sh obdfilter-survey
+# instead of case=disk one can also run test as follows
+# $ nobjhi=2 thrhi=2 size=1024 OSTS="lustre-OST0000 lustre-OST0001 ..." sh obdfilter-survey
+# case 2 (network):
+# $ nobjhi=2 thrhi=2 size=1024 server_nid="<name/nid_of_server>" case=network sh obdfilter-survey
+# where, server_nid is name or ip address of system, which you want to
+# set as server.
+# case 3 (network and disk):
+# $ nobjhi=2 thrhi=2 size=1024 case=netdisk sh obdfilter-survey
+# instead of case="netdisk" one can also run test as follows
+# $ nobjhi=2 thrhi=2 size=1024 ECHO_CLIENTS="ECHO_<osc_name> ..." sh obdfilter-survey
+#[ NOTE: It is advised to have automated login (passwordless entry) between server and
+# client systems on which this test runs.]
+
+# include library
+source libobd
+
+# create a set of objects, check there are 'n' contiguous ones and
+# return the first or 'ERROR'
+# parameter: 1. hostname
+# 2. device number
+# 3. number of object to be created (specified by user)
+# 4. tempfile name
+create_objects () {
+ local host=$1
+ local devno=$2
+ local nobj=$3
+ local rfile=$4
+ remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
+ first=0
+ prev=0
+ count=0
+ error=0
+ while read line; do
+ echo "$line" | grep -q 'is object id'
+ if [ $? -ne 0 ]; then
+ continue
+ fi
+ if [ $first -eq 0 ]; then
+ first=$(echo $line | awk '{print $6}')
+ first=$(printf "%d" $first)
+ prev=$first
+ count=1
+ else
+ obj=$(echo $line | awk '{print $6}')
+ obj=$(printf "%d" $obj)
+ diff=$((obj - (prev+1)))
+ if [ $diff -ne 0 ]; then
+ error=1
+ fi
+ prev=$obj
+ count=$((count+1))
+ fi
+ done < $rfile
+ if [ $nobj -ne $count ]; then
+ echo "ERROR: $nobj != $count" >&2
+ cat $rfile >&2
+ echo "ERROR"
+ elif [ $error -ne 0 ]; then
+ echo "ERROR: non contiguous objs found" >&2
+ else
+ echo $first
+ fi
+}
+
+# destroys all objects created in create_objects routine
+# parameter: 3. start obj id.
+destroy_objects () {
+ local host=$1
+ local devno=$2
+ local obj0=$3
+ local nobj=$4
+ local rfile=$5
+ remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
+}
+
+get_stats () {
+ local rfile=$1
+ awk < $rfile \
+ '/^Selected device [0-9]+$/ {n = 0; next}\
+ /error/ {n = -1; exit}\
+ /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
+ if (n == 1 || v < min) min = v;\
+ if (n == 1 || v > max) max = v;\
+ next}\
+ {if (n != 0) {n = -1; exit}}\
+ END {printf "%d %f %f\n", n, min, max}'
+}
+
+get_global_stats () {
+ local rfile=$1
+ awk < $rfile 'BEGIN {n = 0;}\
+ {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
+ {if ($1 < err) err = $1;\
+ if ($2 < min) min = $2;\
+ if ($3 > max) max = $3}}\
+ END {if (n == 0) err = 0;\
+ printf "%d %f %f\n", err, min, max}'
+}
+
+# enable or disable data check.
+# parameter: 1. read/write
+testname2type () {
+ # 'x' disables data check
+ if ((verify)); then
+ x=""
+ else
+ x="x"
+ fi
+ case $1 in
+ *write*) echo "w$x";;
+ *) echo "r$x";;
+ esac
+}
+
+print_summary () {
+ if [ "$1" = "-n" ]; then
+ minusn=$1; shift
+ else
+ minusn=""
+ fi
+ echo $minusn "$*" >> $rsltf
+ echo $minusn "$*"
+}
+
+# Customisation variables
+#####################################################################
+# One can change variable values in this section as per requirements
+
+OSTS=${OSTS:-""}
+server_nid=${server_nid:-""}
+case=${case:-"disk"}
+if [ -n "$OSTS" ]; then