Whamcloud - gitweb
LU-1347 style: removes obsolete EXPORT_SYMTAB macros
[fs/lustre-release.git] / lustre / tests / mds-survey.sh
1 #!/bin/bash
2 #set -x
3 set -e
4
5 LUSTRE=${LUSTRE:-`dirname $0`/..}
6 . $LUSTRE/tests/test-framework.sh
7 init_test_env $@
8 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
9 init_logging
10
11 build_test_filter
12 check_and_setup_lustre
13
14 file_count=${file_count:-150000}
15 dir_count=${dir_count:-4}
16 thrhi=${thrhi:-8}
17 thrlo=${thrlo:-1}
18
19 [ "$SLOW" = no ] && { file_count=50000; dir_count=2; thrhi=4; }
20
21 # Skip these tests
22 ALWAYS_EXCEPT="$MDS_SURVEY_EXCEPT"
23
24 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
25 if [ -z ${MDSSURVEY} ]; then
26     skip_env "mds-survey not found" && exit
27 fi
28
29 adjust_inode() {
30     local require_inode=0
31     local avail_mdt_inode=0
32     local avail_ost_inode=0
33
34     require_inode=$((file_count * thrhi))
35     # get available inode for mdt
36     avail_mdt_inode=$($LFS df -i $MOUNT | grep "filesystem summary:"  | \
37         awk '{print $5}')
38     avail_mdt_inode=$((avail_mdt_inode * 9 / 10))
39
40     # get available inode for ost
41     for i in $($LFS df -i | grep ${FSNAME}-OST | awk '{print $4}'); do
42         avail_ost_inode=$((avail_ost_inode + i))
43     done
44     avail_ost_inode=$((avail_ost_inode * 9 / 10))
45
46     ((require_inode > avail_mdt_inode)) && require_inode=$avail_mdt_inode
47     ((require_inode > avail_ost_inode)) && require_inode=$avail_ost_inode
48
49     if ((require_inode == 0)); then
50         error "Fail to get the inode count"
51     fi
52     # convert it back to per thread inode
53     require_inode=$((require_inode / thrhi))
54
55     echo $require_inode
56 }
57
58
59 file_count=$(adjust_inode)
60 ost_count=$($LCTL dl | grep -c osc)
61
62 # first unmount all the lustre clients
63 cleanup_mount $MOUNT
64 cleanup_mount $MOUNT2
65
66 get_target() {
67     local mds=$(facet_host $SINGLEMDS)
68     echo $(do_nodes $mds 'lctl dl' | \
69         awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
70 }
71
72 mds_survey_run() {
73     local layer=${1:-mdd}
74     local stripe_count=${2:-0}
75     local mds=$(facet_host $SINGLEMDS)
76     local rc=0
77
78     rm -f ${TMP}/mds_survey*
79
80     local target=$(get_target)
81     local cmd="file_count=$file_count thrlo=$thrlo thrhi=$thrhi"
82     local cmd+=" dir_count=$dir_count layer=$layer stripe_count=$stripe_count"
83     local cmd+=" rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
84
85     echo + $cmd
86     eval $cmd || rc=$?
87     cat ${TMP}/mds_survey*
88     rm -f ${TMP}/mds_survey*
89     ((rc == 0)) || error "mds-survey failed"
90 }
91
92 test_1() {
93     mds_survey_run "mdd" "0"
94 }
95 run_test 1 "Metadata survey with zero-stripe"
96
97 test_2() {
98     if [ $ost_count -eq 0 ]; then
99         skip_env "Need to mount OST to test" && return
100     fi
101     mds_survey_run "mdd" "1"
102 }
103 run_test 2 "Metadata survey with stripe_count = 1"
104
105 # remount the clients
106 restore_mount $MOUNT
107
108 complete $(basename $0) $SECONDS
109 cleanup_echo_devs
110 check_and_cleanup_lustre
111 exit_status