3 ######################################################################
6 # Prerequisite: For "stripe_count > 0" you need to have ost setup and mounted.
9 # case 1 (stripe_count=0 default):
10 # $ thrhi=8 dir_count=4 sh mds-survey
11 # one can also run test with user defined targets as follows,
12 # $ thrhi=8 dir_count=4 file_count=50000 targets="lustre-MDT0000" sh mds-survey
13 # case 2 (stripe_count > 0, must have ost mounted):
14 # $ thrhi=8 dir_count=4 file_count=50000 stripe_count=2
15 # targets="lustre-MDT0000" sh mds-survey
16 # [ NOTE: It is advised to have automated login (passwordless entry) on server ]
19 source $(dirname $0)/iokit-libecho
21 # Customisation variables
22 #####################################################################
23 # One can change variable values in this section as per requirements
24 # The following variables can be set in the environment, or on the
26 # result file prefix (date/time + hostname makes unique)
27 # NB ensure path to it exists
28 rslt_loc=${rslt_loc:-"/tmp"}
29 rslt=${rslt:-"$rslt_loc/mds_survey_`date +%F@%R`_`uname -n`"}
31 # min and max thread count
35 # number of directories to test
36 dir_count=${dir_count:-$thrlo}
37 # number of files per thread
38 file_count=${file_count:-100000}
40 targets=${targets:-""}
41 stripe_count=${stripe_count:-0}
42 # what tests to run (first must be create, and last must be destroy)
43 # default=(create lookup md_getattr setxattr destroy)
44 tests_str=${tests_str:-"create lookup md_getattr setxattr destroy"}
46 # start number for each thread
47 start_number=${start_number:-2}
51 # Customisation variables ends here.
52 #####################################################################
53 # leave the rest of this alone unless you know what you're doing...
58 create_directories () {
67 for ((idx = 0; idx < $ndir; idx++)); do
68 if (( idx == 0 )); then
69 dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}"
71 dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}${idx}"
73 remote_shell $host $lctl --device $devno test_mkdir /$dirname \
74 -c $dir_stripes --stripe_index $mdtidx > $rfile 2>&1
76 echo "$line" | grep -q 'error: test_mkdir'
79 echo "ERROR: fail test_mkdir" >&2
88 destroy_directories () {
96 for ((idx = 0; idx < $ndir; idx++)); do
97 if (( idx == 0 )); then
98 dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}"
100 dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}${idx}"
102 remote_shell $host $lctl --device $devno test_rmdir /$dirname > $rfile 2>&1
117 /^Total: total [0-9]+ threads [0-9]+ sec [0-9\.]+ [0-9]+\.[0-9]+\/second$/ { \
118 ave = strtonum($8); \
122 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ { \
123 n++; v = strtonum($3); \
124 if (n == 1 || v < min) min = v; \
125 if (n == 1 || v > max) max = v; \
139 printf "%d %f %f %f\n", n, ave, min, max \
143 get_global_stats () {
170 printf "%d %f %f %f\n", err, ave/n, min, max \
175 if [ "$1" = "-n" ]; then
180 echo $minusn "$*" >> $rsltf
186 for name in $tests_str; do
191 # hide a little trick to unset this from the command line
192 if [ "$lustre_root" == " " ]; then
196 if [ -z "$lustre_root" ]; then
199 lctl=${lustre_root}/utils/lctl
202 declare -a client_names
203 declare -a host_names
204 declare -a client_indexes
205 if [ -z "$targets" ]; then
206 targets=$($lctl device_list | awk "{if (\$2 == \"UP\" && \
207 \$3 == \"mdt\") {print \$4} }")
208 if [ -z "$targets" ]; then
209 echo "Can't find any MDT to test. Please set targets=..."
214 # split out hostnames from mdt names
216 for trgt in $targets; do
217 str=($(split_hostname $trgt))
218 host_names[$ndevs]=${str[0]}
219 client_names[$ndevs]=${str[1]}
220 client_indexes[$ndevs]=0x$(echo ${str[1]} |
221 sed 's/.*MDT\([0-9a-f][0-9a-f][0-9a-f][0-9a-f]\).*/\1/')
226 if (( $stripe_count > 0 )); then
227 for ((i=0; i < $ndevs; i++)); do
228 host=${host_names[$i]}
229 obd=$(remote_shell $host $lctl device_list |
230 awk "{ if (\$2 == \"UP\" &&
231 (\$3 == \"osc\" || \$3 == \"osp\"))
233 if [ -z "$obd" ]; then
234 echo "Need obdfilter to test stripe_count"
240 # check and insert obdecho module
241 if ! lsmod | grep obdecho > /dev/null; then
245 if [ $count -eq 0 -o "${tests[0]}" != "create" -o "${tests[(($count - 1))]}" != "destroy" ]; then
246 echo "tests: ${tests[@]}"
247 echo "First test must be 'create', and last test must be 'destroy'" 1>&2
251 rsltf="${rslt}.summary"
252 workf="${rslt}.detail"
253 cmdsf="${rslt}.script"
254 vmstatf="${rslt}.vmstat"
259 # disable portals debug and get obdecho loaded on all relevant hosts
260 unique_hosts=($(unique ${host_names[@]}))
263 for host in ${unique_hosts[@]}; do
264 host_vmstatf=${vmstatf}_${host}
265 echo -n > $host_vmstatf
266 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
268 vmstatpids[$pidcount]=$pid
269 pidcount=$((pidcount+1))
271 # get all the echo_client device numbers and names
272 for ((i=0; i < $ndevs; i++)); do
273 host=${host_names[$i]}
274 devno=($(get_ec_devno $host "${client_names[$i]}" "${client_names[$i]}" "mdt" $layer))
275 if ((${#devno[@]} != 3)); then
278 devnos[$i]=${devno[0]}
279 client_names[$i]=${devno[1]}
280 do_teardown_ec[$i]=${devno[2]}
282 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
283 echo "no devices or hosts specified"
286 print_summary "$(date) $0 from $(hostname)"
289 for ((idx = 0; idx < $ndevs; idx++)); do
290 host=${host_names[$idx]}
291 devno=${devnos[$idx]}
292 client_name="${host}:${client_names[$idx]}"
293 mdtidx=${client_indexes[$idx]}
294 echo "=======> Create $dir_count directories on $client_name" >> $workf
295 destroy_directories $host $devno $dir_count $tmpf $mdtidx
296 ret=$(create_directories $host $devno $dir_count $tmpf $mdtidx $ndevs)
299 if [ $ret = "ERROR" ]; then
300 print_summary "created directories on $client_name failed"
307 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
308 thr_per_dir=$((${thr}/${dir_count}))
309 # skip if no enough thread
310 if (( thr_per_dir <= 0 )); then
313 file_count_per_thread=$((${file_count}/${thr}))
314 str=$(printf 'mdt %1d file %7d dir %4d thr %4d ' \
315 $ndevs $file_count $dir_count $thr)
316 echo "=======> $str" >> $workf
317 print_summary -n "$str"
319 for test in ${tests[@]}; do
321 for host in ${unique_hosts[@]}; do
322 echo "starting run for config: $config test: $test " \
323 "file: $file_count threads: $thr " \
324 "directories: $dir_count" >> ${vmstatf}_${host}
326 print_summary -n "$test "
327 # create per-host script files
328 for host in ${unique_hosts[@]}; do
329 echo -n > ${cmdsf}_${host}
331 for ((idx = 0; idx < $ndevs; idx++)); do
332 host=${host_names[$idx]}
333 devno=${devnos[$idx]}
334 dirname="$(printf "${mdtbasedir}" ${client_indexes[$idx]})$basedir"
336 [ "$test" = "create" ] && test="create -c $stripe_count"
337 echo >> ${cmdsf}_${host} \
338 "$lctl > $tmpfi 2>&1 \
339 --threads $thr -$snap $devno test_$test \
340 -d /$dirname -D $dir_count \
341 -b $start_number -n $file_count_per_thread"
344 for host in ${unique_hosts[@]}; do
345 echo "wait" >> ${cmdsf}_${host}
346 pidarray[$pidcount]=0
347 pidcount=$((pidcount+1))
350 for host in ${unique_hosts[@]}; do
351 remote_shell $host bash < ${cmdsf}_${host} &
352 pidarray[$pidcount]=$!
353 pidcount=$((pidcount+1))
356 for host in ${unique_hosts[@]}; do
357 wait ${pidarray[$pidcount]}
358 pidcount=$((pidcount+1))
361 # clean up per-host script files
362 for host in ${unique_hosts[@]}; do
366 # collect/check individual MDT stats
368 for ((idx = 0; idx < $ndevs; idx++)); do
369 client_name="${host_names[$idx]}:${client_names[$idx]}"
371 echo "=============> $test $client_name" >> $workf
372 host="${host_names[$idx]}"
373 remote_shell $host cat $tmpfi > ${tmpfi}_local
374 cat ${tmpfi}_local >> $workf
375 get_stats ${tmpfi}_local >> $tmpf
376 rm -f $tmpfi ${tmpfi}_local
378 # compute/display global min/max stats
379 echo "=============> $test global" >> $workf
381 stats=($(get_global_stats $tmpf))
383 if ((stats[0] <= 0)); then
384 str=$(printf "%17s " ERROR)
387 str=$(awk "BEGIN {printf \"%7.2f [ %7.2f, %7.2f] \", \
388 ${stats[1]}, ${stats[2]}, ${stats[3]}; exit}")
390 print_summary -n "$str"
395 # destroy directories
397 for ((idx = 0; idx < $ndevs; idx++)); do
398 host=${host_names[$idx]}
399 devno=${devnos[$idx]}
400 mdtidx=${client_indexes[$idx]}
401 client_name="${host}:${client_names[$idx]}"
402 echo "====> Destroy $dir_count directories on $client_name" >> $workf
403 destroy_directories $host $devno $dir_count $tmpf $mdtidx