2 ######################################################################
5 # specify obd instances to exercise
6 # these can be either...
7 # obdfilter instances (set 'ost_names')
9 # echo_client instances (set 'client_names')
10 # ... use 'host:name' for obd instances on other nodes.
11 # allow these to be passed in via string...
13 # one can specify only case=disk or case=network or case=netdisk through
16 # Prerequisite: For "disk" case and "netdisk" case you need to have lustre setup
17 # with one or more ost's. For "network" case you need to have all
18 # modules (those llmount.sh loades) loaded in kernel. And the
19 # 'lctl dl' output must be blank.
22 # case 1 (local disk):
23 # $ nobjhi=2 thrhi=2 size=1024 case=disk sh obdfilter-survey
24 # one can also run test with user defined targets as follows,
25 # $ nobjhi=2 thrhi=2 size=1024 targets="lustre-OST0000 lustre-OST0001 ..." sh obdfilter-survey
27 # $ nobjhi=2 thrhi=2 size=1024 targets="<name/ip_of_server>" case=network sh obdfilter-survey
28 # where, targets is name or ip address of system, which you want to
30 # case 3 (network and disk):
31 # $ nobjhi=2 thrhi=2 size=1024 case=netdisk sh obdfilter-survey
32 # one can also run test with user defined targets as follows,
33 # $ nobjhi=2 thrhi=2 size=1024 targets="<osc_name> ..." sh obdfilter-survey
34 #[ NOTE: It is advised to have automated login (passwordless entry) between server and
35 # client systems on which this test runs.]
38 source $(dirname $0)/iokit-libecho
40 # The following variables can be set in the environment, or on the
42 # result file prefix (date/time + hostname makes unique)
43 # NB ensure path to it exists
44 rslt_loc=${rslt_loc:-"/tmp"}
45 rslt=${rslt:-"$rslt_loc/obdfilter_survey_$(date +%F@%R)_$(uname -n)"}
47 # Set this true to check file contents
51 targets=${targets:-""}
55 # total size (MBytes) per obd instance
56 # large enough to avoid cache effects
57 # and to make test startup/shutdown overhead insignificant
60 # record size (KBytes) ( 7168 max)
63 rszmax=${rszmax:-4096}
65 # number of objects per OST
67 #was nobjhi=${nobjhi:-512}
70 # threads per OST (1024 max)
78 # create a set of objects, check there are 'n' contiguous ones and
79 # echo out the first or 'ERROR'
80 # parameter: 1. hostname
82 # 3. number of object to be created (specified by user)
90 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
96 # Count number of objects (lines containing " is object id "), and
97 # ensure that the objects numbers are sequential.
100 while read -u3 line; do
102 ( *' is object id '* )
104 if test $(( count += 1 )) -gt 1 ; then
105 (( $6 != prev + 1 )) && error=1
115 if [ $nobj -ne $count ]; then
116 echo "ERROR: $nobj != $count" >&2
119 elif [ $error -ne 0 ]; then
120 echo "ERROR: non contiguous objs found" >&2
128 # destroys all objects created in create_objects routine
129 # parameter: 3. start obj id.
137 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
144 '/^Selected device [0-9]+$/ { \
155 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ { \
158 if (n == 1 || v < min) \
160 if (n == 1 || v > max) \
171 printf "%d %f %f\n", n, min, max \
175 get_global_stats () {
200 printf "%d %f %f\n", err, min, max \
204 # enable or disable data check.
205 # parameter: 1. read/write
207 # 'x' disables data check
214 *write*) echo "w$x";;
219 # for "echo_client + obdfilter" case, "prep + commit" mode should be used
220 # for "echo_client + osc" case, "BRW" mode should be used
229 if [ "$1" = "-n" ]; then
234 echo $minusn "$*" >> $rsltf
238 # Return a numeric version code based on a version string. The version
239 # code is useful for comparison two version strings to see which is newer.
241 # split arguments like "2.3.61" into "2", "3", "61"
242 eval set -- $(tr "[:punct:]" " " <<< $*)
243 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
246 # inspired from the lustre_build_version routine in test-framework.sh
247 get_lustre_version() {
248 local host=${1:-${unique_hosts[0]}}
251 ver=$(remote_shell $host "$lctl get_param -n version 2>/dev/null ||
252 $lctl lustre_build_version 2>/dev/null ||
253 $lctl --version 2>/dev/null | cut -d' ' -f2")
254 local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1)
255 [ -n "$lver" ] && ver="$lver"
257 sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver |
261 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
263 check_record_size() {
264 [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] &&
267 if [ "$rszhi" -gt "$rszmax" ]; then
268 echo "Test disk case support maximum ${rszmax}KB IO data" \
269 "(rszhi=$rszhi is too big), please use a smaller value."
275 # Customisation variables
276 #####################################################################
277 # One can change variable values in this section as per requirements
279 if [ -n "$targets" ]; then
281 declare -a client_names
283 for name in $targets; do
284 if [ $case == "disk" ]; then
285 ost_names[$count]=$name
287 client_names[$count]=$name
293 # what tests to run (first must be write)
294 tests_str=${tests_str:-""}
295 if [ -n "$tests_str" ]; then
298 for name in $tests_str; do
303 #tests=(write rewrite read reread rewrite_again)
304 tests=(write rewrite read)
307 # restart from here iff all are defined
312 # machine's page size (KB)
313 PAGE_SIZE=${PAGE_SIZE:-$(($(getconf PAGE_SIZE) / 1024))}
314 PAGE_SIZE=${PAGE_SIZE:-4}
318 # Customisation variables ends here.
319 #####################################################################
320 # leave the rest of this alone unless you know what you're doing...
322 # check and insert obdecho module
323 if ! lsmod | grep obdecho > /dev/null; then
326 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
327 echo "tests: ${tests[@]}"
328 echo "First test must be 'write'" 1>&2
332 rsltf="${rslt}.summary"
333 workf="${rslt}.detail"
334 cmdsf="${rslt}.script"
335 vmstatf="${rslt}.vmstat"
339 # hide a little trick to unset this from the command line
340 if [ "$lustre_root" == " " ]; then
344 if [ -z "$lustre_root" ]; then
347 lctl=${lustre_root}/utils/lctl
350 # split out hostnames from client/ost names
352 for trgt in $targets; do
353 str=($(split_hostname $trgt))
354 host_names[$ndevs]=${str[0]}
355 client_names[$ndevs]=${str[1]}
358 if [ $case == "disk" ]; then
359 for ((i = 0; i < $ndevs; i++)); do
360 ost_names[$i]=${client_names[$i]}
363 if [ $case == "netdisk" ]; then
364 if [ "$targets" ]; then
365 for ((i = 0; i < $ndevs; i++)); do
366 setup_osc_for_remote_ost ${host_names[$i]} \
367 ${client_names[$i]} $i
368 osc_name=${client_names[$i]}_osc
369 ec_using_osc $osc_name
370 cleanup_oscs="$cleanup_oscs $osc_name"
373 client_names_str=$($lctl dl | grep -v mdt |
374 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
376 for name in $client_names_str; do
377 client_names[$count]=$(echo $name | sed 's/-osc-.*$//')
381 host_names_str=$($lctl dl -t | grep -v mdt |
382 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
384 for name in $host_names_str; do
385 host_names[$count]=$(echo $name | sed 's/@.*$//')
389 for (( i = 0; i < $count; i++ )) do
390 setup_osc_for_remote_ost ${host_names[$i]} \
391 ${client_names[$i]} $i
392 osc_name=${client_names[$i]}_osc
393 ec_using_osc $osc_name
394 cleanup_oscs="$cleanup_oscs $osc_name"
398 echo_clients=$($lctl dl | grep echo_client |
399 awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") { \
402 for name in $echo_clients; do
403 client_names[$cnt]=$name
404 host_names[$cnt]=localhost
407 ndevs=${#client_names[@]}
409 if [ $case == "network" ]; then
411 if [ -z "$server_nid" ]; then
412 echo "Specify hostname or ip-address of server"
415 # check for obdecho module on server
416 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
417 dsh $server_nid root "modprobe obdecho"
419 # Now do the server setup
420 setup_srv_obd $server_nid "echo_srv"
421 oss_on_srv=$(dsh $server_nid root "$lctl dl | grep OSS" |
423 if [ -z $oss_on_srv ]; then
424 setup_OSS $server_nid
427 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
428 echo "obdecho not setup on server"
431 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
432 echo "ost not setup on server"
435 # Now start client setup
436 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP || true)
437 if [ -n "$osc_names_str" ]; then
438 echo "The existing setup must be cleaned";
441 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
442 client_names[0]="echotmp_ecc"
444 if [ -z "$targets" ]; then
445 if [ $case == "disk" ]; then
447 ndevs=${#ost_names[@]}
451 # disable portals debug and get obdecho loaded on all relevant hosts
452 unique_hosts=($(unique ${host_names[@]}))
455 if [ $case == "disk" ]; then
456 check_record_size || cleanup ${PIPESTATUS[0]}
460 for host in ${unique_hosts[@]}; do
461 host_vmstatf=${vmstatf}_${host}
462 echo -n > $host_vmstatf
463 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
465 vmstatpids[$pidcount]=$pid
466 pidcount=$((pidcount + 1))
468 # get all the echo_client device numbers and names
469 for ((i=0; i < $ndevs; i++)); do
470 host=${host_names[$i]}
471 devno=($(get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"))
472 if ((${#devno[@]} != 3)); then
475 devnos[$i]=${devno[0]}
476 client_names[$i]=${devno[1]}
477 do_teardown_ec[$i]=${devno[2]}
479 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
480 echo "no devices or hosts specified"
481 cleanup 0 $clean_srv_OSS $cleanup_oscs
484 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
485 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
486 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
487 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
488 if ((thr % nobj)); then
492 if [ -n "$restart_rsz" -a \
493 -n "$restart_nobj" -a \
494 -n "$restart_thr" ]; then
495 if ((rsz < restart_rsz ||
496 (rsz == restart_rsz &&
497 (nobj < restart_nobj ||
498 (nobj == restart_nobj &&
499 thr < restart_thr))))); then
505 total_thr=$((ndevs * thr))
506 total_nobj=$((ndevs * nobj))
507 pages=$((rsz / PAGE_SIZE))
508 actual_rsz=$((pages * PAGE_SIZE))
509 count=$((size * 1024 / (actual_rsz * thr)))
510 actual_size=$((actual_rsz * count * thr))
511 total_size=$((actual_size * ndevs))
513 # show computed parameters
514 str=$(printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
515 $ndevs $total_size $actual_rsz $total_nobj $total_thr)
516 echo "=======================> $str" >> $workf
517 print_summary -n "$str"
521 for ((idx = 0; idx < $ndevs; idx++)); do
522 host=${host_names[$idx]}
523 devno=${devnos[$idx]}
524 client_name="${host}:${client_names[$idx]}"
525 echo "=============> Create $nobj on $client_name" >> $workf
526 first_obj=$(create_objects $host $devno $nobj $tmpf)
529 if [ $first_obj = "ERROR" ]; then
530 print_summary "created object #s on $client_name not contiguous"
533 first_objs[$idx]=$first_obj
537 for test in ${tests[@]}; do
539 for host in ${unique_hosts[@]}; do
541 "lctl set_param -n osd*.*.force_sync 1 &>/dev/null || true"
542 echo "starting run for test: $test rsz: $rsz " \
543 "threads: $thr objects: $nobj" >> ${vmstatf}_${host}
545 print_summary -n "$test "
547 # create per-host script files
548 for host in ${unique_hosts[@]}; do
549 echo -n > ${cmdsf}_${host}
551 for ((idx = 0; idx < $ndevs; idx++)); do
552 host=${host_names[$idx]}
553 devno=${devnos[$idx]}
555 first_obj=${first_objs[$idx]}
556 thr_per_obj=$((${thr}/${nobj}))
557 echo >> ${cmdsf}_${host} \
558 "$lctl > $tmpfi 2>&1 \\
559 --threads $thr -$snap $devno \\
560 test_brw $count $(testname2type $test) q $pages \\
561 ${thr_per_obj}t${first_obj} $(testcase2mode)$pages &"
564 for host in ${unique_hosts[@]}; do
565 echo "wait" >> ${cmdsf}_${host}
566 pidarray[$pidcount]=0
567 pidcount=$((pidcount + 1))
569 # timed run of all the per-host script files
572 for host in ${unique_hosts[@]}; do
573 remote_shell $host bash < ${cmdsf}_${host} &
574 pidarray[$pidcount]=$!
575 pidcount=$((pidcount + 1))
578 for host in ${unique_hosts[@]}; do
579 wait ${pidarray[$pidcount]}
580 pidcount=$((pidcount + 1))
584 # clean up per-host script files
585 for host in ${unique_hosts[@]}; do
589 # compute bandwidth from total data / elapsed time
590 str=$(awk "BEGIN {printf \"%7.2f \",\
591 $total_size / (( $t1 - $t0 ) * 1024)}")
592 print_summary -n "$str"
593 # collect/check individual OST stats
595 for ((idx = 0; idx < $ndevs; idx++)); do
596 client_name="${host_names[$idx]}:${client_names[$idx]}"
598 echo "=============> $test $client_name" >> $workf
599 host="${host_names[$idx]}"
600 remote_shell $host cat $tmpfi > ${tmpfi}_local
601 cat ${tmpfi}_local >> $workf
602 get_stats ${tmpfi}_local >> $tmpf
603 rm -f $tmpfi ${tmpfi}_local
606 # compute/display global min/max stats
607 echo "=============> $test global" >> $workf
609 stats=($(get_global_stats $tmpf))
611 if ((stats[0] <= 0)); then
612 if ((stats[0] < 0)); then
613 str=$(printf "%17s " ERROR)
615 str=$(printf "%17s " SHORT)
618 str=$(awk "BEGIN {printf \"[%7.2f, %7.2f] \",\
619 (${stats[1]} * $actual_rsz)/1024,\
620 (${stats[2]} * $actual_rsz)/1024; exit}")
622 print_summary -n "$str"
626 # destroy objects we created
627 for ((idx = 0; idx < $ndevs; idx++)); do
628 host=${host_names[$idx]}
629 devno=${devnos[$idx]}
630 client_name="${host}:${client_names[$idx]}"
631 first_obj=${first_objs[$idx]}
632 echo "=============> Destroy $nobj on $client_name" >> $workf
633 destroy_objects $host $devno $first_obj $nobj $tmpf
640 cleanup 0 $clean_srv_OSS $cleanup_oscs