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)
71 # create a set of objects, check there are 'n' contiguous ones and
72 # return the first or 'ERROR'
73 # parameter: 1. hostname
75 # 3. number of object to be created (specified by user)
82 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
88 echo "$line" | grep -q 'is object id'
92 if [ $first -eq 0 ]; then
93 first=$(echo $line | awk '{print $6}')
94 first=$(printf "%d" $first)
98 obj=$(echo $line | awk '{print $6}')
99 obj=$(printf "%d" $obj)
100 diff=$((obj - (prev+1)))
101 if [ $diff -ne 0 ]; then
108 if [ $nobj -ne $count ]; then
109 echo "ERROR: $nobj != $count" >&2
112 elif [ $error -ne 0 ]; then
113 echo "ERROR: non contiguous objs found" >&2
119 # destroys all objects created in create_objects routine
120 # parameter: 3. start obj id.
127 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
133 '/^Selected device [0-9]+$/ {n = 0; next}\
134 /error/ {n = -1; exit}\
135 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
136 if (n == 1 || v < min) min = v;\
137 if (n == 1 || v > max) max = v;\
139 {if (n != 0) {n = -1; exit}}\
140 END {printf "%d %f %f\n", n, min, max}'
143 get_global_stats () {
145 awk < $rfile 'BEGIN {n = 0;}\
146 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
147 {if ($1 < err) err = $1;\
148 if ($2 < min) min = $2;\
149 if ($3 > max) max = $3}}\
150 END {if (n == 0) err = 0;\
151 printf "%d %f %f\n", err, min, max}'
154 # enable or disable data check.
155 # parameter: 1. read/write
157 # 'x' disables data check
164 *write*) echo "w$x";;
170 if [ "$1" = "-n" ]; then
175 echo $minusn "$*" >> $rsltf
179 # Customisation variables
180 #####################################################################
181 # One can change variable values in this section as per requirements
183 targets=${targets:-""}
185 if [ -n "$targets" ]; then
187 declare -a client_names
189 for name in $targets; do
190 if [ $case == "disk" ]; then
191 ost_names[$count]=$name
193 client_names[$count]=$name
199 # what tests to run (first must be write)
200 tests_str=${tests_str:-""}
201 if [ -n "$tests_str" ]; then
204 for name in $tests_str; do
209 #tests=(write rewrite read reread rewrite_again)
210 tests=(write rewrite read)
213 # restart from here iff all are defined
218 # machine's page size (K)
219 if [ -z "$PAGE_SIZE" ]; then
220 if which python >/dev/null; then
221 PAGE_SIZE=`echo 'import resource; print resource.getpagesize()/1024;' |python`
224 PAGE_SIZE=${PAGE_SIZE:-4}
226 # max buffer_mem (total_threads * buffer size)
227 # (to avoid lctl ENOMEM problems)
228 max_buffer_mem=$((1024 * 1024))
231 # Customisation variables ends here.
232 #####################################################################
233 # leave the rest of this alone unless you know what you're doing...
235 # check and insert obdecho module
236 if ! lsmod | grep obdecho > /dev/null; then
239 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
240 echo "tests: ${tests[@]}"
241 echo "First test must be 'write'" 1>&2
245 rsltf="${rslt}.summary"
246 workf="${rslt}.detail"
247 cmdsf="${rslt}.script"
248 vmstatf="${rslt}.vmstat"
252 # hide a little trick to unset this from the command line
253 if [ "$lustre_root" == " " ]; then
257 if [ -z "$lustre_root" ]; then
260 lctl=${lustre_root}/utils/lctl
263 # split out hostnames from client/ost names
265 for trgt in $targets; do
266 str=(`split_hostname $trgt`)
267 host_names[$ndevs]=${str[0]}
268 client_names[$ndevs]=${str[1]}
271 if [ $case == "netdisk" ]; then
272 if [ "$targets" ]; then
273 for ((i = 0; i < $ndevs; i++)); do
274 setup_osc_for_remote_ost ${host_names[$i]} ${client_names[$i]} $i
275 cleanup_oscs="$cleanup_oscs ${client_names[$i]}_osc"
276 host_names[$i]=localhost
281 osc_names_str=$(lctl dl |grep osc | awk "{if (\$2 == \"UP\" && \$3 == \"osc\") {print \$4} }")
283 for name in $osc_names_str; do
284 osc_names[$count]=$name
287 osc_uuid_str=$(lctl dl |grep osc | awk "{if (\$2 == \"UP\" && \$3 == \"osc\") {print \$5} }")
289 for uuid in $osc_uuid_str; do
290 osc_uuids[$count]=$uuid
293 for (( i = 0; i < $count; i++ ))
295 ec_using_osc ${osc_names[$i]}
297 echo_clients=$(lctl dl | grep echo_client | awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") {print \$4} }")
299 for name in $echo_clients; do
300 client_names[$cnt]=$name
301 host_names[$cnt]=localhost
304 ndevs=${#client_names[@]}
306 if [ $case == "network" ]; then
308 if [ -z "$server_nid" ]; then
309 echo "Specify hostname or ip-address of server"
312 # check for obdecho module on server
313 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
314 dsh $server_nid root "modprobe obdecho"
316 # Now do the server setup
317 setup_srv_obd $server_nid "echo_srv"
318 oss_on_srv=`dsh $server_nid root "lctl dl | grep OSS" | awk '{ print $4 }'`
319 if [ -z $oss_on_srv ]; then
320 setup_OSS $server_nid
323 if ! dsh $server_nid root "lctl dl | grep obdecho > /dev/null 2>&1"; then
324 echo "obdecho not setup on server"
327 if ! dsh $server_nid root "lctl dl | grep ost > /dev/null 2>&1"; then
328 echo "ost not setup on server"
331 # Now start client setup
332 osc_names_str=$(lctl dl)
333 if [ -n "$osc_names_str" ]; then
334 echo "The existing setup must be cleaned";
337 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
338 client_names[0]="echotmp_ecc"
340 if [ -z "$targets" ]; then
341 if [ $case == "disk" ]; then
343 ndevs=${#ost_names[@]}
347 # disable portals debug and get obdecho loaded on all relevant hosts
348 unique_hosts=(`unique ${host_names[@]}`)
350 for host in ${unique_hosts[@]}; do
351 host_vmstatf=${vmstatf}_${host}
352 echo -n > $host_vmstatf
353 remote_shell $host "vmstat 5 >> $host_vmstatf" &
355 vmstatpids[$pidcount]=$pid
356 pidcount=$((pidcount+1))
357 do_unload_obdecho[$host]=0
358 if obdecho_loaded $host; then
362 if obdecho_loaded $host; then
363 do_unload_obdecho[$host]=1
366 echo "Can't load obdecho on $host" 1>&2
369 # get all the echo_client device numbers and names
370 for ((i=0; i < $ndevs; i++)); do
371 host=${host_names[$i]}
372 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
373 if ((${#devno[@]} != 3)); then
376 devnos[$i]=${devno[0]}
377 client_names[$i]=${devno[1]}
378 do_teardown_ec[$i]=${devno[2]}
380 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
381 echo "no devices or hosts specified"
382 cleanup 0 $clean_srv_OSS $cleanup_oscs
384 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
385 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
386 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
387 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
388 if ((thr % nobj)); then
392 if [ -n "$restart_rsz" -a\
393 -n "$restart_nobj" -a\
394 -n "$restart_thr" ]; then
395 if ((rsz < restart_rsz ||\
396 (rsz == restart_rsz &&\
397 (nobj < restart_nobj ||\
398 (nobj == restart_nobj &&\
399 thr < restart_thr))))); then
404 total_thr=$((ndevs*thr))
405 total_nobj=$((ndevs*nobj))
406 pages=$((rsz/PAGE_SIZE))
407 actual_rsz=$((pages*PAGE_SIZE))
408 count=$((size*1024/(actual_rsz*thr)))
409 actual_size=$((actual_rsz*count*thr))
410 total_size=$((actual_size*ndevs))
411 # show computed parameters
412 str=`printf 'ost %2d sz %8dK rsz %4d obj %4d thr %4d ' \
413 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
414 echo "=======================> $str" >> $workf
415 print_summary -n "$str"
416 if ((total_thr * actual_rsz > max_buffer_mem)); then
417 print_summary "Too much buffer space"
422 for ((idx = 0; idx < $ndevs; idx++)); do
423 host=${host_names[$idx]}
424 devno=${devnos[$idx]}
425 client_name="${host}:${client_names[$idx]}"
426 echo "=============> Create $nobj on $client_name" >> $workf
427 first_obj=`create_objects $host $devno $nobj $tmpf`
430 if [ $first_obj = "ERROR" ]; then
431 print_summary "created object #s on $client_name not contiguous"
434 first_objs[$idx]=$first_obj
437 for test in ${tests[@]}; do
439 for host in ${unique_hosts[@]}; do
440 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
442 print_summary -n "$test "
443 # create per-host script files
444 for host in ${unique_hosts[@]}; do
445 echo -n > ${cmdsf}_${host}
447 for ((idx = 0; idx < $ndevs; idx++)); do
448 host=${host_names[$idx]}
449 devno=${devnos[$idx]}
451 first_obj=${first_objs[$idx]}
452 thr_per_obj=$((${thr}/${nobj}))
453 echo >> ${cmdsf}_${host} \
454 "$lctl > $tmpfi 2>&1 \\
455 --threads $thr -$snap $devno \\
456 test_brw $count `testname2type $test` q $pages ${thr_per_obj}t${first_obj} &"
459 for host in ${unique_hosts[@]}; do
460 echo "wait" >> ${cmdsf}_${host}
461 pidarray[$pidcount]=0
462 pidcount=$((pidcount+1))
464 # timed run of all the per-host script files
467 for host in ${unique_hosts[@]}; do
468 remote_shell $host bash < ${cmdsf}_${host} &
469 pidarray[$pidcount]=$!
470 pidcount=$((pidcount+1))
473 for host in ${unique_hosts[@]}; do
474 wait ${pidarray[$pidcount]}
475 pidcount=$((pidcount+1))
479 # clean up per-host script files
480 for host in ${unique_hosts[@]}; do
483 # compute bandwidth from total data / elapsed time
484 str=`awk "BEGIN {printf \"%7.2f \",\
485 $total_size / (( $t1 - $t0 ) * 1024)}"`
486 print_summary -n "$str"
487 # collect/check individual OST stats
489 for ((idx = 0; idx < $ndevs; idx++)); do
490 client_name="${host_names[$idx]}:${client_names[$idx]}"
492 echo "=============> $test $client_name" >> $workf
493 host="${host_names[$idx]}"
494 remote_shell $host cat $tmpfi >> $workf
495 get_stats $tmpfi >> $tmpf
498 # compute/display global min/max stats
499 echo "=============> $test global" >> $workf
501 stats=(`get_global_stats $tmpf`)
503 if ((stats[0] <= 0)); then
504 if ((stats[0] < 0)); then
505 str=`printf "%17s " ERROR`
507 str=`printf "%17s " SHORT`
510 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
511 (${stats[1]} * $actual_rsz)/1024,\
512 (${stats[2]} * $actual_rsz)/1024; exit}"`
514 print_summary -n "$str"
517 # destroy objects we created
518 for ((idx = 0; idx < $ndevs; idx++)); do
519 host=${host_names[$idx]}
520 devno=${devnos[$idx]}
521 client_name="${host}:${client_names[$idx]}"
522 first_obj=${first_objs[$idx]}
523 echo "=============> Destroy $nobj on $client_name" >> $workf
524 destroy_objects $host $devno $first_obj $nobj $tmpf
531 cleanup 0 $clean_srv_OSS $cleanup_oscs