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)/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
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) ( 7168 max)
60 # number of objects per OST
62 #was nobjhi=${nobjhi:-512}
65 # threads per OST (1024 max)
73 # create a set of objects, check there are 'n' contiguous ones and
74 # echo out the first or 'ERROR'
75 # parameter: 1. hostname
77 # 3. number of object to be created (specified by user)
84 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
90 # Count number of objects (lines containing " is object id "), and
91 # ensure that the objects numbers are sequential.
94 while read -u3 line; do
96 ( *' is object id '* )
98 if test $(( count += 1 )) -gt 1 ; then
99 (( $6 != prev + 1 )) && error=1
109 if [ $nobj -ne $count ]; then
110 echo "ERROR: $nobj != $count" >&2
113 elif [ $error -ne 0 ]; then
114 echo "ERROR: non contiguous objs found" >&2
122 # destroys all objects created in create_objects routine
123 # parameter: 3. start obj id.
130 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
136 '/^Selected device [0-9]+$/ {n = 0; next}\
137 /error/ {n = -1; exit}\
138 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
139 if (n == 1 || v < min) min = v;\
140 if (n == 1 || v > max) max = v;\
142 {if (n != 0) {n = -1; exit}}\
143 END {printf "%d %f %f\n", n, min, max}'
146 get_global_stats () {
148 awk < $rfile 'BEGIN {n = 0;}\
149 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
150 {if ($1 < err) err = $1;\
151 if ($2 < min) min = $2;\
152 if ($3 > max) max = $3}}\
153 END {if (n == 0) err = 0;\
154 printf "%d %f %f\n", err, min, max}'
157 # enable or disable data check.
158 # parameter: 1. read/write
160 # 'x' disables data check
167 *write*) echo "w$x";;
173 if [ "$1" = "-n" ]; then
178 echo $minusn "$*" >> $rsltf
182 # Customisation variables
183 #####################################################################
184 # One can change variable values in this section as per requirements
186 targets=${targets:-""}
188 if [ -n "$targets" ]; then
190 declare -a client_names
192 for name in $targets; do
193 if [ $case == "disk" ]; then
194 ost_names[$count]=$name
196 client_names[$count]=$name
202 # what tests to run (first must be write)
203 tests_str=${tests_str:-""}
204 if [ -n "$tests_str" ]; then
207 for name in $tests_str; do
212 #tests=(write rewrite read reread rewrite_again)
213 tests=(write rewrite read)
216 # restart from here iff all are defined
221 # machine's page size (K)
222 if [ -z "$PAGE_SIZE" ]; then
223 if which python >/dev/null; then
224 PAGE_SIZE=`echo 'import resource; print resource.getpagesize()/1024;' |python`
227 PAGE_SIZE=${PAGE_SIZE:-4}
229 # max buffer_mem (total_threads * buffer size)
230 # (to avoid lctl ENOMEM problems)
231 max_buffer_mem=$((1024 * 1024))
234 # Customisation variables ends here.
235 #####################################################################
236 # leave the rest of this alone unless you know what you're doing...
238 # check and insert obdecho module
239 if ! lsmod | grep obdecho > /dev/null; then
242 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
243 echo "tests: ${tests[@]}"
244 echo "First test must be 'write'" 1>&2
248 rsltf="${rslt}.summary"
249 workf="${rslt}.detail"
250 cmdsf="${rslt}.script"
251 vmstatf="${rslt}.vmstat"
255 # hide a little trick to unset this from the command line
256 if [ "$lustre_root" == " " ]; then
260 if [ -z "$lustre_root" ]; then
263 lctl=${lustre_root}/utils/lctl
266 # split out hostnames from client/ost names
268 for trgt in $targets; do
269 str=(`split_hostname $trgt`)
270 host_names[$ndevs]=${str[0]}
271 client_names[$ndevs]=${str[1]}
274 if [ $case == "disk" ]; then
275 for ((i = 0; i < $ndevs; i++)); do
276 ost_names[$i]=${client_names[$i]}
279 if [ $case == "netdisk" ]; then
280 if [ "$targets" ]; then
281 for ((i = 0; i < $ndevs; i++)); do
282 setup_osc_for_remote_ost ${host_names[$i]} \
283 ${client_names[$i]} $i
284 osc_name=${client_names[$i]}_osc
285 ec_using_osc $osc_name
286 cleanup_oscs="$cleanup_oscs $osc_name"
289 client_names_str=$($lctl dl | grep -v mdt | \
290 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
292 for name in $client_names_str; do
293 client_names[$count]=`echo $name | sed 's/-osc-.*$//'`
297 host_names_str=$($lctl dl -t | grep -v mdt | \
298 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
300 for name in $host_names_str; do
301 host_names[$count]=`echo $name | sed 's/@.*$//'`
305 for (( i = 0; i < $count; i++ )) do
306 setup_osc_for_remote_ost ${host_names[$i]} \
307 ${client_names[$i]} $i
308 osc_name=${client_names[$i]}_osc
309 ec_using_osc $osc_name
310 cleanup_oscs="$cleanup_oscs $osc_name"
314 echo_clients=$($lctl dl | grep echo_client | awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") {print \$4} }")
316 for name in $echo_clients; do
317 client_names[$cnt]=$name
318 host_names[$cnt]=localhost
321 ndevs=${#client_names[@]}
323 if [ $case == "network" ]; then
325 if [ -z "$server_nid" ]; then
326 echo "Specify hostname or ip-address of server"
329 # check for obdecho module on server
330 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
331 dsh $server_nid root "modprobe obdecho"
333 # Now do the server setup
334 setup_srv_obd $server_nid "echo_srv"
335 oss_on_srv=`dsh $server_nid root "$lctl dl | grep OSS" | awk '{ print $4 }'`
336 if [ -z $oss_on_srv ]; then
337 setup_OSS $server_nid
340 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
341 echo "obdecho not setup on server"
344 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
345 echo "ost not setup on server"
348 # Now start client setup
349 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
350 if [ -n "$osc_names_str" ]; then
351 echo "The existing setup must be cleaned";
354 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
355 client_names[0]="echotmp_ecc"
357 if [ -z "$targets" ]; then
358 if [ $case == "disk" ]; then
360 ndevs=${#ost_names[@]}
364 # disable portals debug and get obdecho loaded on all relevant hosts
365 unique_hosts=(`unique ${host_names[@]}`)
368 for host in ${unique_hosts[@]}; do
369 host_vmstatf=${vmstatf}_${host}
370 echo -n > $host_vmstatf
371 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
373 vmstatpids[$pidcount]=$pid
374 pidcount=$((pidcount+1))
376 # get all the echo_client device numbers and names
377 for ((i=0; i < $ndevs; i++)); do
378 host=${host_names[$i]}
379 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
380 if ((${#devno[@]} != 3)); then
383 devnos[$i]=${devno[0]}
384 client_names[$i]=${devno[1]}
385 do_teardown_ec[$i]=${devno[2]}
387 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
388 echo "no devices or hosts specified"
389 cleanup 0 $clean_srv_OSS $cleanup_oscs
391 # Buffers will be spread out among all hosts, so allow for that
392 max_buffer_mem=$(( ${max_buffer_mem} * ${#unique_hosts[@]} ))
393 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
394 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
395 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
396 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
397 if ((thr % nobj)); then
401 if [ -n "$restart_rsz" -a\
402 -n "$restart_nobj" -a\
403 -n "$restart_thr" ]; then
404 if ((rsz < restart_rsz ||\
405 (rsz == restart_rsz &&\
406 (nobj < restart_nobj ||\
407 (nobj == restart_nobj &&\
408 thr < restart_thr))))); then
413 total_thr=$((ndevs*thr))
414 total_nobj=$((ndevs*nobj))
415 pages=$((rsz/PAGE_SIZE))
416 actual_rsz=$((pages*PAGE_SIZE))
417 count=$((size*1024/(actual_rsz*thr)))
418 actual_size=$((actual_rsz*count*thr))
419 total_size=$((actual_size*ndevs))
420 # show computed parameters
421 str=`printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
422 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
423 echo "=======================> $str" >> $workf
424 print_summary -n "$str"
425 if ((total_thr * actual_rsz > max_buffer_mem)); then
426 print_summary "Too much buffer space"
431 for ((idx = 0; idx < $ndevs; idx++)); do
432 host=${host_names[$idx]}
433 devno=${devnos[$idx]}
434 client_name="${host}:${client_names[$idx]}"
435 echo "=============> Create $nobj on $client_name" >> $workf
436 first_obj=`create_objects $host $devno $nobj $tmpf`
439 if [ $first_obj = "ERROR" ]; then
440 print_summary "created object #s on $client_name not contiguous"
443 first_objs[$idx]=$first_obj
446 for test in ${tests[@]}; do
448 for host in ${unique_hosts[@]}; do
449 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
451 print_summary -n "$test "
452 # create per-host script files
453 for host in ${unique_hosts[@]}; do
454 echo -n > ${cmdsf}_${host}
456 for ((idx = 0; idx < $ndevs; idx++)); do
457 host=${host_names[$idx]}
458 devno=${devnos[$idx]}
460 first_obj=${first_objs[$idx]}
461 thr_per_obj=$((${thr}/${nobj}))
462 echo >> ${cmdsf}_${host} \
463 "$lctl > $tmpfi 2>&1 \\
464 --threads $thr -$snap $devno \\
465 test_brw $count `testname2type $test` q $pages ${thr_per_obj}t${first_obj} &"
468 for host in ${unique_hosts[@]}; do
469 echo "wait" >> ${cmdsf}_${host}
470 pidarray[$pidcount]=0
471 pidcount=$((pidcount+1))
473 # timed run of all the per-host script files
476 for host in ${unique_hosts[@]}; do
477 remote_shell $host bash < ${cmdsf}_${host} &
478 pidarray[$pidcount]=$!
479 pidcount=$((pidcount+1))
482 for host in ${unique_hosts[@]}; do
483 wait ${pidarray[$pidcount]}
484 pidcount=$((pidcount+1))
488 # clean up per-host script files
489 for host in ${unique_hosts[@]}; do
493 # compute bandwidth from total data / elapsed time
494 str=`awk "BEGIN {printf \"%7.2f \",\
495 $total_size / (( $t1 - $t0 ) * 1024)}"`
496 print_summary -n "$str"
497 # collect/check individual OST stats
499 for ((idx = 0; idx < $ndevs; idx++)); do
500 client_name="${host_names[$idx]}:${client_names[$idx]}"
502 echo "=============> $test $client_name" >> $workf
503 host="${host_names[$idx]}"
504 remote_shell $host cat $tmpfi > ${tmpfi}_local
505 cat ${tmpfi}_local >> $workf
506 get_stats ${tmpfi}_local >> $tmpf
507 rm -f $tmpfi ${tmpfi}_local
509 # compute/display global min/max stats
510 echo "=============> $test global" >> $workf
512 stats=(`get_global_stats $tmpf`)
514 if ((stats[0] <= 0)); then
515 if ((stats[0] < 0)); then
516 str=`printf "%17s " ERROR`
518 str=`printf "%17s " SHORT`
521 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
522 (${stats[1]} * $actual_rsz)/1024,\
523 (${stats[2]} * $actual_rsz)/1024; exit}"`
525 print_summary -n "$str"
528 # destroy objects we created
529 for ((idx = 0; idx < $ndevs; idx++)); do
530 host=${host_names[$idx]}
531 devno=${devnos[$idx]}
532 client_name="${host}:${client_names[$idx]}"
533 first_obj=${first_objs[$idx]}
534 echo "=============> Destroy $nobj on $client_name" >> $workf
535 destroy_objects $host $devno $first_obj $nobj $tmpf
542 cleanup 0 $clean_srv_OSS $cleanup_oscs