Whamcloud - gitweb
b=24360 fix NULL pointer deref in mds_verify_child() when ll_lookup_one_len() fails
[fs/lustre-release.git] / lustre / tests / obdfilter-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
9 nobjhi=${nobjhi:-1}
10 thrhi=${thrhi:-16} 
11 size=${size:-1024}
12
13 # the summary file a bit smaller than OSTSIZE  
14 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
15
16 [ "$SLOW" = no ] && { nobjhi=1; thrhi=4; }
17 thrlo=${thrlo:-$(( thrhi / 2))}
18
19 # Skip these tests
20 ALWAYS_EXCEPT="$OBDFILTER_SURVEY_EXCEPT"
21
22 OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)}
23
24 build_test_filter
25 check_and_setup_lustre
26
27 # FIXME: the summary file a bit smaller than OSTSIZE, add estimation
28 minsize=$(min_ost_size)
29 if [ $(( size * 1024 )) -ge $minsize  ]; then
30     size=$((minsize * 10 / 1024 / 12 ))
31     echo min kbytesavail: $minsize using size=${size} MBytes per obd instance
32 fi
33
34 get_targets () {
35         local targets
36         local devs
37         local oss
38
39         for oss in $(osts_nodes); do
40                 devs=$(do_node $oss "lctl dl |grep obdfilter |sort" | awk '{print $4}')
41                 for d in $devs; do
42                         # if oss is local -- obdfilter-survey needs dev wo/ host
43                         target=$d
44                         [[ $oss = `hostname` ]] || target=$oss:$target
45                         targets="$targets $target"
46                 done
47         done
48
49         echo $targets
50 }
51
52 obdflter_survey_targets () {
53         local case=$1
54         local targets
55
56         case $case in
57                 disk)    targets=$(get_targets);;
58                 netdisk) targets=$(get_targets);;
59                 network) targets="$(osts_nodes)";;
60                 *) error "unknown obdflter-survey case!" ;;
61         esac
62         echo $targets
63 }
64
65 obdflter_survey_run () {
66         local case=$1
67
68         rm -f ${TMP}/obdfilter_survey*
69
70         local targets=$(obdflter_survey_targets $case)
71         local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY"
72         echo + $cmd
73         eval $cmd
74
75         cat ${TMP}/obdfilter_survey*
76 }
77 test_1a () {
78         obdflter_survey_run disk
79 }
80 run_test 1a "Object Storage Targets survey"
81
82 print_jbd () {
83         local file=$1
84         local facet=$2
85         local varsvc=${facet}_svc
86         local dev=$(ldiskfs_canon "*.${!varsvc}.mntdev" $facet)
87
88         # ext4: /proc/fs/jbd2/sda1:8/history 
89         # ext3: /proc/fs/jbd/sdb1/history
90
91         do_facet $facet cat /proc/fs/jbd*/${dev}*/$file
92 }
93
94 check_jbd_values () {
95         local facet=$1
96         local thrhi=$2
97
98         # last two lines from history
99         # $4: run >= 5000
100         # $8: hndls >= thrhi * 2
101         local hist=("$(print_jbd history $facet | tail -3 | head -2)")
102         echo "$hist"
103         local run=($(echo "${hist[*]}" | awk '{print $4}'))
104         local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
105
106         local rc=0
107         for (( i=0; i<1; i++)); do
108                 [[ ${run[i]} -lt 5000 ]] && \
109                         error "$facet: run expected 5000, have ${run[i]}" && rc=1
110                 [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
111                         error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
112         done
113         return $rc
114 }
115
116 check_jbd_values_facets () {
117         local facets=$1
118         local thrhi=$2
119         local facet
120         local rc=0
121         for facet in  ${facets//,/ }; do
122                 check_jbd_values $facet $thrhi || rc=$((rc+$?))
123         done
124         return $rc
125 }
126
127 test_1b () {
128         local major=$(get_mds_kernel_major)
129         local minor=$(get_mds_kernel_minor)
130         [ "$major"=="2.6" -a $minor -eq 32 ]  && \
131                 skip "There is no jbd history in this kernel version." && return
132         local param_file=$TMP/$tfile-params
133
134         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
135
136         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
137         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
138
139         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
140
141         check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
142
143         restore_lustre_params < $param_file
144
145         rm -f $param_file
146         return $rc
147 }
148 run_test 1b "Object Storage Targets survey, async journal"
149
150 test_2a () {
151         obdflter_survey_run netdisk
152 }
153 run_test 2a "Stripe F/S over the Network"
154
155 test_2b () {
156         local major=$(get_mds_kernel_major)
157         local minor=$(get_mds_kernel_minor)
158         [ "$major"=="2.6" -a $minor -eq 32 ]  && \
159                 skip "There is no jbd history in this kernel version." && return
160         local param_file=$TMP/$tfile-params
161
162         do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
163
164         save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
165         do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
166
167         thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run netdisk
168
169         check_jbd_values_facets $(get_facets OST) 4 || rc=$((rc+$?))
170
171         restore_lustre_params < $param_file
172
173         rm -f $param_file
174         return $rc
175 }
176 run_test 2b "Stripe F/S over the Network, async journal"
177
178
179 # README.obdfilter-survey: In network test only automated run is supported.
180 test_3a () {
181         remote_servers || { skip "Local servers" && return 0; }
182
183         # The Network survey test needs:
184         # Start lctl and check for the device list. The device list must be empty.
185         cleanupall
186
187         obdflter_survey_run network
188
189         setupall
190 }
191 run_test 3a "Network survey"
192
193 complete $(basename $0) $SECONDS
194 cleanup_echo_devs
195 check_and_cleanup_lustre
196 exit_status