3 ######################################################################
6 # specify obd instances to exercise
7 # these can be either...
8 # obdfilter instances (set 'ost_names')
10 # echo_client instances (set 'client_names')
11 # ... use 'host:name' for obd instances on other nodes.
12 # allow these to be passed in via string...
14 # one can specify only case=disk or case=network or case=netdisk through
17 # Perquisite: For "disk" case and "netdisk" case you need to have lustre setup
18 # with one or more ost's. For "network" case you need to have all
19 # modules (those llmount.sh loades) loaded in kernel. And the
20 # 'lctl dl' output must be blank.
23 # case 1 (local disk):
24 # $ nobjhi=2 thrhi=2 size=1024 case=disk sh obdfilter-survey
25 # instead of case=disk one can also run test as follows
26 # $ nobjhi=2 thrhi=2 size=1024 OSTS="lustre-OST0000 lustre-OST0001 ..." sh obdfilter-survey
28 # $ nobjhi=2 thrhi=2 size=1024 server_nid="<name/nid_of_server>" case=network sh obdfilter-survey
29 # where, server_nid is name or ip address of system, which you want to
31 # case 3 (network and disk):
32 # $ nobjhi=2 thrhi=2 size=1024 case=netdisk sh obdfilter-survey
33 # instead of case="netdisk" one can also run test as follows
34 # $ nobjhi=2 thrhi=2 size=1024 ECHO_CLIENTS="ECHO_<osc_name> ..." sh obdfilter-survey
35 #[ NOTE: It is advised to have automated login (passwordless entry) between server and
36 # client systems on which this test runs.]
41 # The following variables can be set in the environment, or on the
43 # result file prefix (date/time + hostname makes unique)
44 # NB ensure path to it exists
45 rslt_loc=${rslt_loc:-"/tmp"}
46 rslt=${rslt:-"$rslt_loc/obdfilter_survey_`date +%F@%R`_`uname -n`"}
48 # Set this true to check file contents
51 # total size (MBytes) per obd instance
52 # large enough to avoid cache effects
53 # and to make test startup/shutdown overhead insignificant
56 # record size (KBytes)
60 # number of objects per OST
62 #was nobjhi=${nobjhi:-512}
65 # threads per OST (1024 max)
71 # create a set of objects, check there are 'n' contiguous ones and
72 # return the first or 'ERROR'
73 # parameter: 1. hostname
75 # 3. number of object to be created (specified by user)
82 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
88 echo "$line" | grep -q 'is object id'
92 if [ $first -eq 0 ]; then
93 first=$(echo $line | awk '{print $6}')
94 first=$(printf "%d" $first)
98 obj=$(echo $line | awk '{print $6}')
99 obj=$(printf "%d" $obj)
100 diff=$((obj - (prev+1)))
101 if [ $diff -ne 0 ]; then
108 if [ $nobj -ne $count ]; then
109 echo "ERROR: $nobj != $count" >&2
112 elif [ $error -ne 0 ]; then
113 echo "ERROR: non contiguous objs found" >&2
119 # destroys all objects created in create_objects routine
120 # parameter: 3. start obj id.
127 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
133 '/^Selected device [0-9]+$/ {n = 0; next}\
134 /error/ {n = -1; exit}\
135 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
136 if (n == 1 || v < min) min = v;\
137 if (n == 1 || v > max) max = v;\
139 {if (n != 0) {n = -1; exit}}\
140 END {printf "%d %f %f\n", n, min, max}'
143 get_global_stats () {
145 awk < $rfile 'BEGIN {n = 0;}\
146 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
147 {if ($1 < err) err = $1;\
148 if ($2 < min) min = $2;\
149 if ($3 > max) max = $3}}\
150 END {if (n == 0) err = 0;\
151 printf "%d %f %f\n", err, min, max}'
154 # enable or disable data check.
155 # parameter: 1. read/write
157 # 'x' disables data check
164 *write*) echo "w$x";;
170 if [ "$1" = "-n" ]; then
175 echo $minusn "$*" >> $rsltf
179 # Customisation variables
180 #####################################################################
181 # One can change variable values in this section as per requirements
184 server_nid=${server_nid:-""}
186 if [ -n "$OSTS" ]; then
189 for name in $OSTS; do
190 ost_names[$count]=$name
194 ECHO_CLIENTS=${ECHO_CLIENTS:-""}
195 if [ -n "$ECHO_CLIENTS" ]; then
196 # make sure we unset ost_names so that our client_names get noticed...
198 declare -a client_names
200 for name in $ECHO_CLIENTS; do
201 client_names[$count]=$name
207 # what tests to run (first must be write)
208 tests_str=${tests_str:-""}
209 if [ -n "$tests_str" ]; then
212 for name in $tests_str; do
217 #tests=(write rewrite read reread rewrite_again)
218 tests=(write rewrite read)
221 # restart from here iff all are defined
226 # machine's page size (K)
227 if [ -z "$PAGE_SIZE" ]; then
228 if which python >/dev/null; then
229 PAGE_SIZE=`echo 'import resource; print resource.getpagesize()/1024;' |python`
232 PAGE_SIZE=${PAGE_SIZE:-4}
234 # max buffer_mem (total_threads * buffer size)
235 # (to avoid lctl ENOMEM problems)
236 max_buffer_mem=$((1024 * 1024))
239 # Customisation variables ends here.
240 #####################################################################
241 # leave the rest of this alone unless you know what you're doing...
243 # check and insert obdecho module
244 if ! lsmod | grep obdecho > /dev/null; then
247 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
248 echo "tests: ${tests[@]}"
249 echo "First test must be 'write'" 1>&2
253 rsltf="${rslt}.summary"
254 workf="${rslt}.detail"
255 cmdsf="${rslt}.script"
256 vmstatf="${rslt}.vmstat"
260 # hide a little trick to unset this from the command line
261 if [ "$lustre_root" == " " ]; then
265 if [ -z "$lustre_root" ]; then
268 lctl=${lustre_root}/utils/lctl
271 if [ $case == "network" ]; then
272 if [ -z "$server_nid" ]; then
273 echo "Specify the server NID"
276 # check for obdecho module on server
277 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
278 dsh $server_nid root "modprobe obdecho"
280 # Now do the server setup
281 setup_srv_obd $server_nid "echo_srv"
282 oss_on_srv=`dsh $server_nid root "lctl dl | grep OSS | awk '{ print $4 }'"`
283 if [ ! $oss_on_srv ]; then
284 setup_OSS $server_nid
287 if ! dsh $server_nid root "lctl dl | grep obdecho > /dev/null 2>&1"; then
288 echo "obdecho not setup on server"
291 if ! dsh $server_nid root "lctl dl | grep ost > /dev/null 2>&1"; then
292 echo "ost not setup on server"
295 # Now start client setup
296 osc_names_str=$(lctl dl)
297 if [ -n "$osc_names_str" ]; then
298 echo "The existing setup must be cleaned";
301 ec_using_srv_nid $server_nid "osc_testfs" "test_obdfs"
302 declare -a client_names
303 client_names[0]="ECHO_osc_testfs"
306 if [ -z "$ECHO_CLIENTS" ]; then
307 if [ $case == "netdisk" ]; then
310 osc_names_str=$(lctl dl |grep osc | awk "{if (\$2 == \"UP\" && \$3 == \"osc\") {print \$4} }")
312 for name in $osc_names_str; do
313 osc_names[$count]=$name
316 osc_uuid_str=$(lctl dl |grep osc | awk "{if (\$2 == \"UP\" && \$3 == \"osc\") {print \$5} }")
318 for uuid in $osc_uuid_str; do
319 osc_uuids[$count]=$uuid
322 for (( i = 0 ; i < $count; i++ ))
324 ec_using_osc ${osc_names[$i]} ${osc_uuids[$i]}
326 ECHO_CLIENTS=$(lctl dl | grep echo_client | awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") {print \$4} }")
328 for name in $ECHO_CLIENTS; do
329 client_names[$cnt]=$name
335 if [ -z "$OSTS" ]; then
336 if [ $case == "disk" ]; then
341 # split out hostnames from client/ost names
342 ndevs=${#client_names[@]}
343 if ((ndevs != 0)); then
344 if ((${#ost_names[@]} != 0)); then
345 echo "Please specify client_names or ost_names, but not both" 1>&2
348 for ((i = 0; i < ndevs; i++)); do
349 str=(`split_hostname ${client_names[$i]}`)
350 host_names[$i]=${str[0]}
351 client_names[$i]=${str[1]}
354 ndevs=${#ost_names[@]}
355 if ((ndevs == 0)); then
356 echo "Please specify either client_names or ost_names" 1>&2
359 for ((i = 0; i < ndevs; i++)); do
360 str=(`split_hostname ${ost_names[$i]}`)
361 host_names[$i]=${str[0]}
362 ost_names[$i]=${str[1]}
367 # disable portals debug and get obdecho loaded on all relevant hosts
368 unique_hosts=(`unique ${host_names[@]}`)
370 for host in ${unique_hosts[@]}; do
371 host_vmstatf=${vmstatf}_${host}
372 echo -n > $host_vmstatf
373 remote_shell $host "vmstat 5 >> $host_vmstatf" &
375 vmstatpids[$pidcount]=$pid
376 pidcount=$((pidcount+1))
377 do_unload_obdecho[$host]=0
378 if obdecho_loaded $host; then
382 if obdecho_loaded $host; then
383 do_unload_obdecho[$host]=1
386 echo "Can't load obdecho on $host" 1>&2
390 # get all the echo_client device numbers and names
391 for ((i=0; i < ndevs; i++)); do
392 host=${host_names[$i]}
393 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
394 if ((${#devno[@]} != 3)); then
397 devnos[$i]=${devno[0]}
398 client_names[$i]=${devno[1]}
399 do_teardown_ec[$i]=${devno[2]}
401 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
402 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
403 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
404 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
405 if ((thr % nobj)); then
409 if [ -n "$restart_rsz" -a\
410 -n "$restart_nobj" -a\
411 -n "$restart_thr" ]; then
412 if ((rsz < restart_rsz ||\
413 (rsz == restart_rsz &&\
414 (nobj < restart_nobj ||\
415 (nobj == restart_nobj &&\
416 thr < restart_thr))))); then
421 total_thr=$((ndevs*thr))
422 total_nobj=$((ndevs*nobj))
423 pages=$((rsz/PAGE_SIZE))
424 actual_rsz=$((pages*PAGE_SIZE))
425 count=$((size*1024/(actual_rsz*thr)))
426 actual_size=$((actual_rsz*count*thr))
427 total_size=$((actual_size*ndevs))
428 # show computed parameters
429 str=`printf 'ost %2d sz %8dK rsz %4d obj %4d thr %4d ' \
430 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
431 echo "=======================> $str" >> $workf
432 print_summary -n "$str"
433 if ((total_thr * actual_rsz > max_buffer_mem)); then
434 print_summary "Too much buffer space"
439 for ((idx = 0; idx < ndevs; idx++)); do
440 host=${host_names[$idx]}
441 devno=${devnos[$idx]}
442 client_name="${host}:${client_names[$idx]}"
443 echo "=============> Create $nobj on $client_name" >> $workf
444 first_obj=`create_objects $host $devno $nobj $tmpf`
447 if [ $first_obj = "ERROR" ]; then
448 print_summary "created object #s on $client_name not contiguous"
451 first_objs[$idx]=$first_obj
454 for test in ${tests[@]}; do
456 for host in ${unique_hosts[@]}; do
457 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
459 print_summary -n "$test "
460 # create per-host script files
461 for host in ${unique_hosts[@]}; do
462 echo -n > ${cmdsf}_${host}
464 for ((idx = 0; idx < ndevs; idx++)); do
465 host=${host_names[$idx]}
466 devno=${devnos[$idx]}
468 first_obj=${first_objs[$idx]}
469 thr_per_obj=$((${thr}/${nobj}))
470 echo >> ${cmdsf}_${host} \
471 "$lctl > $tmpfi 2>&1 \\
472 --threads $thr -$snap $devno \\
473 test_brw $count `testname2type $test` q $pages ${thr_per_obj}t${first_obj} &"
476 for host in ${unique_hosts[@]}; do
477 echo "wait" >> ${cmdsf}_${host}
478 pidarray[$pidcount]=0
479 pidcount=$((pidcount+1))
481 # timed run of all the per-host script files
484 for host in ${unique_hosts[@]}; do
485 remote_shell $host bash < ${cmdsf}_${host} &
486 pidarray[$pidcount]=$!
487 pidcount=$((pidcount+1))
490 for host in ${unique_hosts[@]}; do
491 wait ${pidarray[$pidcount]}
492 pidcount=$((pidcount+1))
496 # clean up per-host script files
497 for host in ${unique_hosts[@]}; do
500 # compute bandwidth from total data / elapsed time
501 str=`awk "BEGIN {printf \"%7.2f \",\
502 $total_size / (( $t1 - $t0 ) * 1024)}"`
503 print_summary -n "$str"
504 # collect/check individual OST stats
506 for ((idx = 0; idx < ndevs; idx++)); do
507 client_name="${host_names[$idx]}:${client_names[$idx]}"
509 echo "=============> $test $client_name" >> $workf
510 host="${host_names[$idx]}"
511 remote_shell $host cat $tmpfi >> $workf
512 get_stats $tmpfi >> $tmpf
515 # compute/display global min/max stats
516 echo "=============> $test global" >> $workf
518 stats=(`get_global_stats $tmpf`)
520 if ((stats[0] <= 0)); then
521 if ((stats[0] < 0)); then
522 str=`printf "%17s " ERROR`
524 str=`printf "%17s " SHORT`
527 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
528 (${stats[1]} * $actual_rsz)/1024,\
529 (${stats[2]} * $actual_rsz)/1024; exit}"`
531 print_summary -n "$str"
534 # destroy objects we created
535 for ((idx = 0; idx < ndevs; idx++)); do
536 host=${host_names[$idx]}
537 devno=${devnos[$idx]}
538 client_name="${host}:${client_names[$idx]}"
539 first_obj=${first_objs[$idx]}
540 echo "=============> Destroy $nobj on $client_name" >> $workf
541 destroy_objects $host $devno $first_obj $nobj $tmpf
548 cleanup 0 $clean_srv_OSS