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.]
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 # return 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 echo "$line" | grep -q 'is object id'
94 if [ $first -eq 0 ]; then
95 first=$(echo $line | awk '{print $6}')
96 first=$(printf "%d" $first)
100 obj=$(echo $line | awk '{print $6}')
101 obj=$(printf "%d" $obj)
102 diff=$((obj - (prev+1)))
103 if [ $diff -ne 0 ]; then
110 if [ $nobj -ne $count ]; then
111 echo "ERROR: $nobj != $count" >&2
114 elif [ $error -ne 0 ]; then
115 echo "ERROR: non contiguous objs found" >&2
121 # destroys all objects created in create_objects routine
122 # parameter: 3. start obj id.
129 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
135 '/^Selected device [0-9]+$/ {n = 0; next}\
136 /error/ {n = -1; exit}\
137 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
138 if (n == 1 || v < min) min = v;\
139 if (n == 1 || v > max) max = v;\
141 {if (n != 0) {n = -1; exit}}\
142 END {printf "%d %f %f\n", n, min, max}'
145 get_global_stats () {
147 awk < $rfile 'BEGIN {n = 0;}\
148 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
149 {if ($1 < err) err = $1;\
150 if ($2 < min) min = $2;\
151 if ($3 > max) max = $3}}\
152 END {if (n == 0) err = 0;\
153 printf "%d %f %f\n", err, min, max}'
156 # enable or disable data check.
157 # parameter: 1. read/write
159 # 'x' disables data check
166 *write*) echo "w$x";;
172 if [ "$1" = "-n" ]; then
177 echo $minusn "$*" >> $rsltf
181 # Customisation variables
182 #####################################################################
183 # One can change variable values in this section as per requirements
185 targets=${targets:-""}
187 if [ -n "$targets" ]; then
189 declare -a client_names
191 for name in $targets; do
192 if [ $case == "disk" ]; then
193 ost_names[$count]=$name
195 client_names[$count]=$name
201 # what tests to run (first must be write)
202 tests_str=${tests_str:-""}
203 if [ -n "$tests_str" ]; then
206 for name in $tests_str; do
211 #tests=(write rewrite read reread rewrite_again)
212 tests=(write rewrite read)
215 # restart from here iff all are defined
220 # machine's page size (K)
221 if [ -z "$PAGE_SIZE" ]; then
222 if which python >/dev/null; then
223 PAGE_SIZE=`echo 'import resource; print resource.getpagesize()/1024;' |python`
226 PAGE_SIZE=${PAGE_SIZE:-4}
228 # max buffer_mem (total_threads * buffer size)
229 # (to avoid lctl ENOMEM problems)
230 max_buffer_mem=$((1024 * 1024))
233 # Customisation variables ends here.
234 #####################################################################
235 # leave the rest of this alone unless you know what you're doing...
237 # check and insert obdecho module
238 if ! lsmod | grep obdecho > /dev/null; then
241 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
242 echo "tests: ${tests[@]}"
243 echo "First test must be 'write'" 1>&2
247 rsltf="${rslt}.summary"
248 workf="${rslt}.detail"
249 cmdsf="${rslt}.script"
250 vmstatf="${rslt}.vmstat"
254 # hide a little trick to unset this from the command line
255 if [ "$lustre_root" == " " ]; then
259 if [ -z "$lustre_root" ]; then
262 lctl=${lustre_root}/utils/lctl
265 # split out hostnames from client/ost names
267 for trgt in $targets; do
268 str=(`split_hostname $trgt`)
269 host_names[$ndevs]=${str[0]}
270 client_names[$ndevs]=${str[1]}
273 if [ $case == "disk" ]; then
274 for ((i = 0; i < $ndevs; i++)); do
275 ost_names[$i]=${client_names[$i]}
278 if [ $case == "netdisk" ]; then
279 if [ "$targets" ]; then
280 for ((i = 0; i < $ndevs; i++)); do
281 setup_osc_for_remote_ost ${host_names[$i]} \
282 ${client_names[$i]} $i
283 osc_name=${client_names[$i]}_osc
284 ec_using_osc $osc_name
285 cleanup_oscs="$cleanup_oscs $osc_name"
288 client_names_str=$($lctl dl | grep -v mdt | \
289 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
291 for name in $client_names_str; do
292 client_names[$count]=`echo $name | sed 's/-osc-.*$//'`
296 host_names_str=$($lctl dl -t | grep -v mdt | \
297 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
299 for name in $host_names_str; do
300 host_names[$count]=`echo $name | sed 's/@.*$//'`
304 for (( i = 0; i < $count; i++ )) do
305 setup_osc_for_remote_ost ${host_names[$i]} \
306 ${client_names[$i]} $i
307 osc_name=${client_names[$i]}_osc
308 ec_using_osc $osc_name
309 cleanup_oscs="$cleanup_oscs $osc_name"
313 echo_clients=$($lctl dl | grep echo_client | awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") {print \$4} }")
315 for name in $echo_clients; do
316 client_names[$cnt]=$name
317 host_names[$cnt]=localhost
320 ndevs=${#client_names[@]}
322 if [ $case == "network" ]; then
324 if [ -z "$server_nid" ]; then
325 echo "Specify hostname or ip-address of server"
328 # check for obdecho module on server
329 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
330 dsh $server_nid root "modprobe obdecho"
332 # Now do the server setup
333 setup_srv_obd $server_nid "echo_srv"
334 oss_on_srv=`dsh $server_nid root "$lctl dl | grep OSS" | awk '{ print $4 }'`
335 if [ -z $oss_on_srv ]; then
336 setup_OSS $server_nid
339 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
340 echo "obdecho not setup on server"
343 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
344 echo "ost not setup on server"
347 # Now start client setup
348 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
349 if [ -n "$osc_names_str" ]; then
350 echo "The existing setup must be cleaned";
353 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
354 client_names[0]="echotmp_ecc"
356 if [ -z "$targets" ]; then
357 if [ $case == "disk" ]; then
359 ndevs=${#ost_names[@]}
363 # disable portals debug and get obdecho loaded on all relevant hosts
364 unique_hosts=(`unique ${host_names[@]}`)
367 for host in ${unique_hosts[@]}; do
368 host_vmstatf=${vmstatf}_${host}
369 echo -n > $host_vmstatf
370 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
372 vmstatpids[$pidcount]=$pid
373 pidcount=$((pidcount+1))
375 # get all the echo_client device numbers and names
376 for ((i=0; i < $ndevs; i++)); do
377 host=${host_names[$i]}
378 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
379 if ((${#devno[@]} != 3)); then
382 devnos[$i]=${devno[0]}
383 client_names[$i]=${devno[1]}
384 do_teardown_ec[$i]=${devno[2]}
386 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
387 echo "no devices or hosts specified"
388 cleanup 0 $clean_srv_OSS $cleanup_oscs
390 # Buffers will be spread out among all hosts, so allow for that
391 max_buffer_mem=$(( ${max_buffer_mem} * ${#unique_hosts[@]} ))
392 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
393 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
394 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
395 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
396 if ((thr % nobj)); then
400 if [ -n "$restart_rsz" -a\
401 -n "$restart_nobj" -a\
402 -n "$restart_thr" ]; then
403 if ((rsz < restart_rsz ||\
404 (rsz == restart_rsz &&\
405 (nobj < restart_nobj ||\
406 (nobj == restart_nobj &&\
407 thr < restart_thr))))); then
412 total_thr=$((ndevs*thr))
413 total_nobj=$((ndevs*nobj))
414 pages=$((rsz/PAGE_SIZE))
415 actual_rsz=$((pages*PAGE_SIZE))
416 count=$((size*1024/(actual_rsz*thr)))
417 actual_size=$((actual_rsz*count*thr))
418 total_size=$((actual_size*ndevs))
419 # show computed parameters
420 str=`printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
421 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
422 echo "=======================> $str" >> $workf
423 print_summary -n "$str"
424 if ((total_thr * actual_rsz > max_buffer_mem)); then
425 print_summary "Too much buffer space"
430 for ((idx = 0; idx < $ndevs; idx++)); do
431 host=${host_names[$idx]}
432 devno=${devnos[$idx]}
433 client_name="${host}:${client_names[$idx]}"
434 echo "=============> Create $nobj on $client_name" >> $workf
435 first_obj=`create_objects $host $devno $nobj $tmpf`
438 if [ $first_obj = "ERROR" ]; then
439 print_summary "created object #s on $client_name not contiguous"
442 first_objs[$idx]=$first_obj
445 for test in ${tests[@]}; do
447 for host in ${unique_hosts[@]}; do
448 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
450 print_summary -n "$test "
451 # create per-host script files
452 for host in ${unique_hosts[@]}; do
453 echo -n > ${cmdsf}_${host}
455 for ((idx = 0; idx < $ndevs; idx++)); do
456 host=${host_names[$idx]}
457 devno=${devnos[$idx]}
459 first_obj=${first_objs[$idx]}
460 thr_per_obj=$((${thr}/${nobj}))
461 echo >> ${cmdsf}_${host} \
462 "$lctl > $tmpfi 2>&1 \\
463 --threads $thr -$snap $devno \\
464 test_brw $count `testname2type $test` q $pages ${thr_per_obj}t${first_obj} &"
467 for host in ${unique_hosts[@]}; do
468 echo "wait" >> ${cmdsf}_${host}
469 pidarray[$pidcount]=0
470 pidcount=$((pidcount+1))
472 # timed run of all the per-host script files
475 for host in ${unique_hosts[@]}; do
476 remote_shell $host bash < ${cmdsf}_${host} &
477 pidarray[$pidcount]=$!
478 pidcount=$((pidcount+1))
481 for host in ${unique_hosts[@]}; do
482 wait ${pidarray[$pidcount]}
483 pidcount=$((pidcount+1))
487 # clean up per-host script files
488 for host in ${unique_hosts[@]}; do
492 # compute bandwidth from total data / elapsed time
493 str=`awk "BEGIN {printf \"%7.2f \",\
494 $total_size / (( $t1 - $t0 ) * 1024)}"`
495 print_summary -n "$str"
496 # collect/check individual OST stats
498 for ((idx = 0; idx < $ndevs; idx++)); do
499 client_name="${host_names[$idx]}:${client_names[$idx]}"
501 echo "=============> $test $client_name" >> $workf
502 host="${host_names[$idx]}"
503 remote_shell $host cat $tmpfi > ${tmpfi}_local
504 cat ${tmpfi}_local >> $workf
505 get_stats ${tmpfi}_local >> $tmpf
506 rm -f $tmpfi ${tmpfi}_local
508 # compute/display global min/max stats
509 echo "=============> $test global" >> $workf
511 stats=(`get_global_stats $tmpf`)
513 if ((stats[0] <= 0)); then
514 if ((stats[0] < 0)); then
515 str=`printf "%17s " ERROR`
517 str=`printf "%17s " SHORT`
520 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
521 (${stats[1]} * $actual_rsz)/1024,\
522 (${stats[2]} * $actual_rsz)/1024; exit}"`
524 print_summary -n "$str"
527 # destroy objects we created
528 for ((idx = 0; idx < $ndevs; idx++)); do
529 host=${host_names[$idx]}
530 devno=${devnos[$idx]}
531 client_name="${host}:${client_names[$idx]}"
532 first_obj=${first_objs[$idx]}
533 echo "=============> Destroy $nobj on $client_name" >> $workf
534 destroy_objects $host $devno $first_obj $nobj $tmpf
541 cleanup 0 $clean_srv_OSS $cleanup_oscs