+print_jbd () {
+ local file=$1
+ local facet=$2
+ local varsvc=${facet}_svc
+ local dev=$(ldiskfs_canon "*.${!varsvc}.mntdev" $facet)
+
+ # ext4: /proc/fs/jbd2/sda1:8/history
+ # ext3: /proc/fs/jbd/sdb1/history
+
+ do_facet $facet cat /proc/fs/jbd*/${dev}*/$file
+}
+
+check_jbd_values () {
+ local facet=$1
+ local thrhi=$2
+ local rtime=$3
+
+ # last two lines from history
+ # $4: run >= 5000
+ # $8: hndls >= thrhi * 2
+ # display history of rtime/4 before, in case obd cleanup consumes time
+ local tlines=$((rtime / 5 / 4 + 1))
+ local hist=("$(print_jbd history $facet | tail -$tlines | head -1)")
+ echo "$hist"
+ local run=($(echo "${hist[*]}" | awk '{print $4}'))
+ local hndls=($(echo "${hist[*]}" | awk '{print $8}'))
+
+ local rc=0
+ for (( i=0; i<1; i++)); do
+ [[ ${run[i]} -lt 5000 ]] && \
+ error "$facet: run expected 5000, have ${run[i]}" && rc=1
+ [[ ${hndls[i]} -lt $((thrhi * 2)) ]] && \
+ error "$facet: hndls expected > $((thrhi * 2)), have ${hndls[i]}" && rc=2
+ done
+ return $rc
+}
+
+check_jbd_values_facets () {
+ local facets=$1
+ local thrhi=$2
+ local rtime=$3
+ local facet
+ local rc=0
+ for facet in ${facets//,/ }; do
+ check_jbd_values $facet $thrhi $rtime || rc=$((rc+$?))
+ done
+ return $rc
+}
+
+test_1b () {
+ local param_file=$TMP/$tfile-params
+
+ do_nodesv $(comma_list $(osts_nodes)) lctl get_param obdfilter.${FSNAME}-*.sync_journal
+
+ save_lustre_params $(comma_list $(osts_nodes)) "obdfilter.${FSNAME}-*.sync_journal" >$param_file
+ do_nodesv $(comma_list $(osts_nodes)) lctl set_param obdfilter.${FSNAME}-*.sync_journal=0
+
+ local stime=$(date +%s)
+ thrlo=4 nobjhi=1 thrhi=4 obdflter_survey_run disk
+ local etime=$(date +%s)
+ # run time of obd survey
+ local rtime=$((etime - stime))
+
+ echo "obd survey finished in $rtime seconds"
+ check_jbd_values_facets $(get_facets OST) 4 $rtime || rc=$((rc+$?))
+
+ restore_lustre_params < $param_file
+
+ rm -f $param_file
+ return $rc
+}
+run_test 1b "Object Storage Targets survey, async journal"
+
+test_1c () {
+ nobjlo=1 nobjhi=1 thrlo=128 thrhi=128 rszlo=1024 rszhi=1024 size=8192\
+ obdflter_survey_run disk
+}
+run_test 1c "Object Storage Targets survey, big batch"
+