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
240 # split arguments like "2.3.61" into "2", "3", "61"
241 eval set -- $(tr "[:punct:]" " " <<< $*)
242 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
245 get_lustre_version() {
246 local host=${1:-${unique_hosts[0]}}
247 remote_shell $host $lctl get_param -n version |
248 awk '/^lustre:/ {print $2}'
251 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
253 check_record_size() {
254 [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] &&
257 if [ "$rszhi" -gt "$rszmax" ]; then
258 echo "Test disk case support maximum ${rszmax}KB IO data" \
259 "(rszhi=$rszhi is too big), please use a smaller value."
265 # Customisation variables
266 #####################################################################
267 # One can change variable values in this section as per requirements
269 if [ -n "$targets" ]; then
271 declare -a client_names
273 for name in $targets; do
274 if [ $case == "disk" ]; then
275 ost_names[$count]=$name
277 client_names[$count]=$name
283 # what tests to run (first must be write)
284 tests_str=${tests_str:-""}
285 if [ -n "$tests_str" ]; then
288 for name in $tests_str; do
293 #tests=(write rewrite read reread rewrite_again)
294 tests=(write rewrite read)
297 # restart from here iff all are defined
302 # machine's page size (KB)
303 PAGE_SIZE=${PAGE_SIZE:-$(($(getconf PAGE_SIZE) / 1024))}
304 PAGE_SIZE=${PAGE_SIZE:-4}
306 # max buffer_mem (total_threads * buffer size)
307 # (to avoid lctl ENOMEM problems)
308 max_buffer_mem=$((1024 * 1024))
311 # Customisation variables ends here.
312 #####################################################################
313 # leave the rest of this alone unless you know what you're doing...
315 # check and insert obdecho module
316 if ! lsmod | grep obdecho > /dev/null; then
319 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
320 echo "tests: ${tests[@]}"
321 echo "First test must be 'write'" 1>&2
325 rsltf="${rslt}.summary"
326 workf="${rslt}.detail"
327 cmdsf="${rslt}.script"
328 vmstatf="${rslt}.vmstat"
332 # hide a little trick to unset this from the command line
333 if [ "$lustre_root" == " " ]; then
337 if [ -z "$lustre_root" ]; then
340 lctl=${lustre_root}/utils/lctl
343 # split out hostnames from client/ost names
345 for trgt in $targets; do
346 str=($(split_hostname $trgt))
347 host_names[$ndevs]=${str[0]}
348 client_names[$ndevs]=${str[1]}
351 if [ $case == "disk" ]; then
352 for ((i = 0; i < $ndevs; i++)); do
353 ost_names[$i]=${client_names[$i]}
356 if [ $case == "netdisk" ]; then
357 if [ "$targets" ]; then
358 for ((i = 0; i < $ndevs; i++)); do
359 setup_osc_for_remote_ost ${host_names[$i]} \
360 ${client_names[$i]} $i
361 osc_name=${client_names[$i]}_osc
362 ec_using_osc $osc_name
363 cleanup_oscs="$cleanup_oscs $osc_name"
366 client_names_str=$($lctl dl | grep -v mdt |
367 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
369 for name in $client_names_str; do
370 client_names[$count]=$(echo $name | sed 's/-osc-.*$//')
374 host_names_str=$($lctl dl -t | grep -v mdt |
375 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
377 for name in $host_names_str; do
378 host_names[$count]=$(echo $name | sed 's/@.*$//')
382 for (( i = 0; i < $count; i++ )) do
383 setup_osc_for_remote_ost ${host_names[$i]} \
384 ${client_names[$i]} $i
385 osc_name=${client_names[$i]}_osc
386 ec_using_osc $osc_name
387 cleanup_oscs="$cleanup_oscs $osc_name"
391 echo_clients=$($lctl dl | grep echo_client |
392 awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") { \
395 for name in $echo_clients; do
396 client_names[$cnt]=$name
397 host_names[$cnt]=localhost
400 ndevs=${#client_names[@]}
402 if [ $case == "network" ]; then
404 if [ -z "$server_nid" ]; then
405 echo "Specify hostname or ip-address of server"
408 # check for obdecho module on server
409 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
410 dsh $server_nid root "modprobe obdecho"
412 # Now do the server setup
413 setup_srv_obd $server_nid "echo_srv"
414 oss_on_srv=$(dsh $server_nid root "$lctl dl | grep OSS" |
416 if [ -z $oss_on_srv ]; then
417 setup_OSS $server_nid
420 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
421 echo "obdecho not setup on server"
424 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
425 echo "ost not setup on server"
428 # Now start client setup
429 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
430 if [ -n "$osc_names_str" ]; then
431 echo "The existing setup must be cleaned";
434 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
435 client_names[0]="echotmp_ecc"
437 if [ -z "$targets" ]; then
438 if [ $case == "disk" ]; then
440 ndevs=${#ost_names[@]}
444 # disable portals debug and get obdecho loaded on all relevant hosts
445 unique_hosts=($(unique ${host_names[@]}))
448 if [ $case == "disk" ]; then
449 check_record_size || cleanup ${PIPESTATUS[0]}
453 for host in ${unique_hosts[@]}; do
454 host_vmstatf=${vmstatf}_${host}
455 echo -n > $host_vmstatf
456 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
458 vmstatpids[$pidcount]=$pid
459 pidcount=$((pidcount + 1))
461 # get all the echo_client device numbers and names
462 for ((i=0; i < $ndevs; i++)); do
463 host=${host_names[$i]}
464 devno=($(get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"))
465 if ((${#devno[@]} != 3)); then
468 devnos[$i]=${devno[0]}
469 client_names[$i]=${devno[1]}
470 do_teardown_ec[$i]=${devno[2]}
472 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
473 echo "no devices or hosts specified"
474 cleanup 0 $clean_srv_OSS $cleanup_oscs
476 # Buffers will be spread out among all hosts, so allow for that
477 max_buffer_mem=$(( ${max_buffer_mem} * ${#unique_hosts[@]} ))
478 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
479 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
480 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
481 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
482 if ((thr % nobj)); then
486 if [ -n "$restart_rsz" -a \
487 -n "$restart_nobj" -a \
488 -n "$restart_thr" ]; then
489 if ((rsz < restart_rsz ||
490 (rsz == restart_rsz &&
491 (nobj < restart_nobj ||
492 (nobj == restart_nobj &&
493 thr < restart_thr))))); then
499 total_thr=$((ndevs * thr))
500 total_nobj=$((ndevs * nobj))
501 pages=$((rsz / PAGE_SIZE))
502 actual_rsz=$((pages * PAGE_SIZE))
503 count=$((size * 1024 / (actual_rsz * thr)))
504 actual_size=$((actual_rsz * count * thr))
505 total_size=$((actual_size * ndevs))
507 # show computed parameters
508 str=$(printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
509 $ndevs $total_size $actual_rsz $total_nobj $total_thr)
510 echo "=======================> $str" >> $workf
511 print_summary -n "$str"
512 if ((total_thr * actual_rsz > max_buffer_mem)); then
513 print_summary "Too much buffer space"
519 for ((idx = 0; idx < $ndevs; idx++)); do
520 host=${host_names[$idx]}
521 devno=${devnos[$idx]}
522 client_name="${host}:${client_names[$idx]}"
523 echo "=============> Create $nobj on $client_name" >> $workf
524 first_obj=$(create_objects $host $devno $nobj $tmpf)
527 if [ $first_obj = "ERROR" ]; then
528 print_summary "created object #s on $client_name not contiguous"
531 first_objs[$idx]=$first_obj
535 for test in ${tests[@]}; do
537 for host in ${unique_hosts[@]}; do
538 echo "starting run for test: $test rsz: $rsz " \
539 "threads: $thr objects: $nobj" >> ${vmstatf}_${host}
541 print_summary -n "$test "
543 # create per-host script files
544 for host in ${unique_hosts[@]}; do
545 echo -n > ${cmdsf}_${host}
547 for ((idx = 0; idx < $ndevs; idx++)); do
548 host=${host_names[$idx]}
549 devno=${devnos[$idx]}
551 first_obj=${first_objs[$idx]}
552 thr_per_obj=$((${thr}/${nobj}))
553 echo >> ${cmdsf}_${host} \
554 "$lctl > $tmpfi 2>&1 \\
555 --threads $thr -$snap $devno \\
556 test_brw $count $(testname2type $test) q $pages \\
557 ${thr_per_obj}t${first_obj} $(testcase2mode)$pages &"
560 for host in ${unique_hosts[@]}; do
561 echo "wait" >> ${cmdsf}_${host}
562 pidarray[$pidcount]=0
563 pidcount=$((pidcount + 1))
565 # timed run of all the per-host script files
568 for host in ${unique_hosts[@]}; do
569 remote_shell $host bash < ${cmdsf}_${host} &
570 pidarray[$pidcount]=$!
571 pidcount=$((pidcount + 1))
574 for host in ${unique_hosts[@]}; do
575 wait ${pidarray[$pidcount]}
576 pidcount=$((pidcount + 1))
580 # clean up per-host script files
581 for host in ${unique_hosts[@]}; do
585 # compute bandwidth from total data / elapsed time
586 str=$(awk "BEGIN {printf \"%7.2f \",\
587 $total_size / (( $t1 - $t0 ) * 1024)}")
588 print_summary -n "$str"
589 # collect/check individual OST stats
591 for ((idx = 0; idx < $ndevs; idx++)); do
592 client_name="${host_names[$idx]}:${client_names[$idx]}"
594 echo "=============> $test $client_name" >> $workf
595 host="${host_names[$idx]}"
596 remote_shell $host cat $tmpfi > ${tmpfi}_local
597 cat ${tmpfi}_local >> $workf
598 get_stats ${tmpfi}_local >> $tmpf
599 rm -f $tmpfi ${tmpfi}_local
602 # compute/display global min/max stats
603 echo "=============> $test global" >> $workf
605 stats=($(get_global_stats $tmpf))
607 if ((stats[0] <= 0)); then
608 if ((stats[0] < 0)); then
609 str=$(printf "%17s " ERROR)
611 str=$(printf "%17s " SHORT)
614 str=$(awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
615 (${stats[1]} * $actual_rsz)/1024,\
616 (${stats[2]} * $actual_rsz)/1024; exit}")
618 print_summary -n "$str"
622 # destroy objects we created
623 for ((idx = 0; idx < $ndevs; idx++)); do
624 host=${host_names[$idx]}
625 devno=${devnos[$idx]}
626 client_name="${host}:${client_names[$idx]}"
627 first_obj=${first_objs[$idx]}
628 echo "=============> Destroy $nobj on $client_name" >> $workf
629 destroy_objects $host $devno $first_obj $nobj $tmpf
636 cleanup 0 $clean_srv_OSS $cleanup_oscs