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 # one can also run test with user defined targets as follows,
26 # $ nobjhi=2 thrhi=2 size=1024 targets="lustre-OST0000 lustre-OST0001 ..." sh obdfilter-survey
28 # $ nobjhi=2 thrhi=2 size=1024 targets="<name/ip_of_server>" case=network sh obdfilter-survey
29 # where, targets 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 # one can also run test with user defined targets as follows,
34 # $ nobjhi=2 thrhi=2 size=1024 targets="<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.]
39 source $(dirname $0)/iokit-libecho
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
52 targets=${targets:-""}
56 # total size (MBytes) per obd instance
57 # large enough to avoid cache effects
58 # and to make test startup/shutdown overhead insignificant
61 # record size (KBytes) ( 7168 max)
64 rszmax=${rszmax:-4096}
66 # number of objects per OST
68 #was nobjhi=${nobjhi:-512}
71 # threads per OST (1024 max)
79 # create a set of objects, check there are 'n' contiguous ones and
80 # echo out the first or 'ERROR'
81 # parameter: 1. hostname
83 # 3. number of object to be created (specified by user)
91 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
97 # Count number of objects (lines containing " is object id "), and
98 # ensure that the objects numbers are sequential.
101 while read -u3 line; do
103 ( *' is object id '* )
105 if test $(( count += 1 )) -gt 1 ; then
106 (( $6 != prev + 1 )) && error=1
116 if [ $nobj -ne $count ]; then
117 echo "ERROR: $nobj != $count" >&2
120 elif [ $error -ne 0 ]; then
121 echo "ERROR: non contiguous objs found" >&2
129 # destroys all objects created in create_objects routine
130 # parameter: 3. start obj id.
138 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
145 '/^Selected device [0-9]+$/ { \
156 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ { \
159 if (n == 1 || v < min) \
161 if (n == 1 || v > max) \
172 printf "%d %f %f\n", n, min, max \
176 get_global_stats () {
201 printf "%d %f %f\n", err, min, max \
205 # enable or disable data check.
206 # parameter: 1. read/write
208 # 'x' disables data check
215 *write*) echo "w$x";;
220 # for "echo_client + obdfilter" case, "prep + commit" mode should be used
221 # for "echo_client + osc" case, "BRW" mode should be used
230 if [ "$1" = "-n" ]; then
235 echo $minusn "$*" >> $rsltf
239 # Return a numeric version code based on a version string. The version
240 # code is useful for comparison two version strings to see which is newer.
242 # split arguments like "2.3.61" into "2", "3", "61"
243 eval set -- $(tr "[:punct:]" " " <<< $*)
244 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
247 # inspired from the lustre_build_version routine in test-framework.sh
248 get_lustre_version() {
249 local host=${1:-${unique_hosts[0]}}
252 ver=$(remote_shell $host "$lctl get_param -n version 2>/dev/null ||
253 $lctl lustre_build_version 2>/dev/null ||
254 $lctl --version 2>/dev/null | cut -d' ' -f2")
255 local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1)
256 [ -n "$lver" ] && ver="$lver"
258 sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver |
262 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
264 check_record_size() {
265 [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] &&
268 if [ "$rszhi" -gt "$rszmax" ]; then
269 echo "Test disk case support maximum ${rszmax}KB IO data" \
270 "(rszhi=$rszhi is too big), please use a smaller value."
276 # Customisation variables
277 #####################################################################
278 # One can change variable values in this section as per requirements
280 if [ -n "$targets" ]; then
282 declare -a client_names
284 for name in $targets; do
285 if [ $case == "disk" ]; then
286 ost_names[$count]=$name
288 client_names[$count]=$name
294 # what tests to run (first must be write)
295 tests_str=${tests_str:-""}
296 if [ -n "$tests_str" ]; then
299 for name in $tests_str; do
304 #tests=(write rewrite read reread rewrite_again)
305 tests=(write rewrite read)
308 # restart from here iff all are defined
313 # machine's page size (KB)
314 PAGE_SIZE=${PAGE_SIZE:-$(($(getconf PAGE_SIZE) / 1024))}
315 PAGE_SIZE=${PAGE_SIZE:-4}
319 # Customisation variables ends here.
320 #####################################################################
321 # leave the rest of this alone unless you know what you're doing...
323 # check and insert obdecho module
324 if ! lsmod | grep obdecho > /dev/null; then
327 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
328 echo "tests: ${tests[@]}"
329 echo "First test must be 'write'" 1>&2
333 rsltf="${rslt}.summary"
334 workf="${rslt}.detail"
335 cmdsf="${rslt}.script"
336 vmstatf="${rslt}.vmstat"
340 # hide a little trick to unset this from the command line
341 if [ "$lustre_root" == " " ]; then
345 if [ -z "$lustre_root" ]; then
348 lctl=${lustre_root}/utils/lctl
351 # split out hostnames from client/ost names
353 for trgt in $targets; do
354 str=($(split_hostname $trgt))
355 host_names[$ndevs]=${str[0]}
356 client_names[$ndevs]=${str[1]}
359 if [ $case == "disk" ]; then
360 for ((i = 0; i < $ndevs; i++)); do
361 ost_names[$i]=${client_names[$i]}
364 if [ $case == "netdisk" ]; then
365 if [ "$targets" ]; then
366 for ((i = 0; i < $ndevs; i++)); do
367 setup_osc_for_remote_ost ${host_names[$i]} \
368 ${client_names[$i]} $i
369 osc_name=${client_names[$i]}_osc
370 ec_using_osc $osc_name
371 cleanup_oscs="$cleanup_oscs $osc_name"
374 client_names_str=$($lctl dl | grep -v mdt |
375 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
377 for name in $client_names_str; do
378 client_names[$count]=$(echo $name | sed 's/-osc-.*$//')
382 host_names_str=$($lctl dl -t | grep -v mdt |
383 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
385 for name in $host_names_str; do
386 host_names[$count]=$(echo $name | sed 's/@.*$//')
390 for (( i = 0; i < $count; i++ )) do
391 setup_osc_for_remote_ost ${host_names[$i]} \
392 ${client_names[$i]} $i
393 osc_name=${client_names[$i]}_osc
394 ec_using_osc $osc_name
395 cleanup_oscs="$cleanup_oscs $osc_name"
399 echo_clients=$($lctl dl | grep echo_client |
400 awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") { \
403 for name in $echo_clients; do
404 client_names[$cnt]=$name
405 host_names[$cnt]=localhost
408 ndevs=${#client_names[@]}
410 if [ $case == "network" ]; then
412 if [ -z "$server_nid" ]; then
413 echo "Specify hostname or ip-address of server"
416 # check for obdecho module on server
417 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
418 dsh $server_nid root "modprobe obdecho"
420 # Now do the server setup
421 setup_srv_obd $server_nid "echo_srv"
422 oss_on_srv=$(dsh $server_nid root "$lctl dl | grep OSS" |
424 if [ -z $oss_on_srv ]; then
425 setup_OSS $server_nid
428 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
429 echo "obdecho not setup on server"
432 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
433 echo "ost not setup on server"
436 # Now start client setup
437 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
438 if [ -n "$osc_names_str" ]; then
439 echo "The existing setup must be cleaned";
442 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
443 client_names[0]="echotmp_ecc"
445 if [ -z "$targets" ]; then
446 if [ $case == "disk" ]; then
448 ndevs=${#ost_names[@]}
452 # disable portals debug and get obdecho loaded on all relevant hosts
453 unique_hosts=($(unique ${host_names[@]}))
456 if [ $case == "disk" ]; then
457 check_record_size || cleanup ${PIPESTATUS[0]}
461 for host in ${unique_hosts[@]}; do
462 host_vmstatf=${vmstatf}_${host}
463 echo -n > $host_vmstatf
464 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
466 vmstatpids[$pidcount]=$pid
467 pidcount=$((pidcount + 1))
469 # get all the echo_client device numbers and names
470 for ((i=0; i < $ndevs; i++)); do
471 host=${host_names[$i]}
472 devno=($(get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"))
473 if ((${#devno[@]} != 3)); then
476 devnos[$i]=${devno[0]}
477 client_names[$i]=${devno[1]}
478 do_teardown_ec[$i]=${devno[2]}
480 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
481 echo "no devices or hosts specified"
482 cleanup 0 $clean_srv_OSS $cleanup_oscs
485 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
486 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
487 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
488 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
489 if ((thr % nobj)); then
493 if [ -n "$restart_rsz" -a \
494 -n "$restart_nobj" -a \
495 -n "$restart_thr" ]; then
496 if ((rsz < restart_rsz ||
497 (rsz == restart_rsz &&
498 (nobj < restart_nobj ||
499 (nobj == restart_nobj &&
500 thr < restart_thr))))); then
506 total_thr=$((ndevs * thr))
507 total_nobj=$((ndevs * nobj))
508 pages=$((rsz / PAGE_SIZE))
509 actual_rsz=$((pages * PAGE_SIZE))
510 count=$((size * 1024 / (actual_rsz * thr)))
511 actual_size=$((actual_rsz * count * thr))
512 total_size=$((actual_size * ndevs))
514 # show computed parameters
515 str=$(printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
516 $ndevs $total_size $actual_rsz $total_nobj $total_thr)
517 echo "=======================> $str" >> $workf
518 print_summary -n "$str"
522 for ((idx = 0; idx < $ndevs; idx++)); do
523 host=${host_names[$idx]}
524 devno=${devnos[$idx]}
525 client_name="${host}:${client_names[$idx]}"
526 echo "=============> Create $nobj on $client_name" >> $workf
527 first_obj=$(create_objects $host $devno $nobj $tmpf)
530 if [ $first_obj = "ERROR" ]; then
531 print_summary "created object #s on $client_name not contiguous"
534 first_objs[$idx]=$first_obj
538 for test in ${tests[@]}; do
540 for host in ${unique_hosts[@]}; do
542 "lctl set_param -n osd*.*OST*.force_sync 1"
543 echo "starting run for test: $test rsz: $rsz " \
544 "threads: $thr objects: $nobj" >> ${vmstatf}_${host}
546 print_summary -n "$test "
548 # create per-host script files
549 for host in ${unique_hosts[@]}; do
550 echo -n > ${cmdsf}_${host}
552 for ((idx = 0; idx < $ndevs; idx++)); do
553 host=${host_names[$idx]}
554 devno=${devnos[$idx]}
556 first_obj=${first_objs[$idx]}
557 thr_per_obj=$((${thr}/${nobj}))
558 echo >> ${cmdsf}_${host} \
559 "$lctl > $tmpfi 2>&1 \\
560 --threads $thr -$snap $devno \\
561 test_brw $count $(testname2type $test) q $pages \\
562 ${thr_per_obj}t${first_obj} $(testcase2mode)$pages &"
565 for host in ${unique_hosts[@]}; do
566 echo "wait" >> ${cmdsf}_${host}
567 pidarray[$pidcount]=0
568 pidcount=$((pidcount + 1))
570 # timed run of all the per-host script files
573 for host in ${unique_hosts[@]}; do
574 remote_shell $host bash < ${cmdsf}_${host} &
575 pidarray[$pidcount]=$!
576 pidcount=$((pidcount + 1))
579 for host in ${unique_hosts[@]}; do
580 wait ${pidarray[$pidcount]}
581 pidcount=$((pidcount + 1))
585 # clean up per-host script files
586 for host in ${unique_hosts[@]}; do
590 # compute bandwidth from total data / elapsed time
591 str=$(awk "BEGIN {printf \"%7.2f \",\
592 $total_size / (( $t1 - $t0 ) * 1024)}")
593 print_summary -n "$str"
594 # collect/check individual OST stats
596 for ((idx = 0; idx < $ndevs; idx++)); do
597 client_name="${host_names[$idx]}:${client_names[$idx]}"
599 echo "=============> $test $client_name" >> $workf
600 host="${host_names[$idx]}"
601 remote_shell $host cat $tmpfi > ${tmpfi}_local
602 cat ${tmpfi}_local >> $workf
603 get_stats ${tmpfi}_local >> $tmpf
604 rm -f $tmpfi ${tmpfi}_local
607 # compute/display global min/max stats
608 echo "=============> $test global" >> $workf
610 stats=($(get_global_stats $tmpf))
612 if ((stats[0] <= 0)); then
613 if ((stats[0] < 0)); then
614 str=$(printf "%17s " ERROR)
616 str=$(printf "%17s " SHORT)
619 str=$(awk "BEGIN {printf \"[%7.2f, %7.2f] \",\
620 (${stats[1]} * $actual_rsz)/1024,\
621 (${stats[2]} * $actual_rsz)/1024; exit}")
623 print_summary -n "$str"
627 # destroy objects we created
628 for ((idx = 0; idx < $ndevs; idx++)); do
629 host=${host_names[$idx]}
630 devno=${devnos[$idx]}
631 client_name="${host}:${client_names[$idx]}"
632 first_obj=${first_objs[$idx]}
633 echo "=============> Destroy $nobj on $client_name" >> $workf
634 destroy_objects $host $devno $first_obj $nobj $tmpf
641 cleanup 0 $clean_srv_OSS $cleanup_oscs