6 ALWAYS_EXCEPT="$SCRUB_PERFORMANCE_EXCEPT"
7 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 [ "${MDSFSTYPE:-$FSTYPE}" != "ldiskfs" ] &&
17 skip "OI scrub performance only for ldiskfs" && exit 0
18 require_dsh_mds || exit 0
20 NTHREADS=${NTHREADS:-0}
23 MINCOUNT=${MINCOUNT:-8192}
24 MAXCOUNT=${MAXCOUNT:-32768}
27 RCMD="do_facet ${SINGLEMDS}"
28 RLCTL="${RCMD} ${LCTL}"
29 MDT_DEV="${FSNAME}-MDT0000"
30 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
31 SHOW_SCRUB="${RLCTL} get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
32 remote_mds && ECHOCMD=${RCMD} || ECHOCMD="eval"
34 if [ ${NTHREADS} -eq 0 ]; then
35 CPUCORE=$(${RCMD} cat /proc/cpuinfo | grep "processor.*:" | wc -l)
36 NTHREADS=$((CPUCORE * 3))
40 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
41 reformat_external_journal
42 add $SINGLEMDS $(mkfs_opts $SINGLEMDS) --backfstype ldiskfs --reformat \
43 $MDT_DEVNAME > /dev/null || exit 2
46 ${ECHOCMD} "${LCTL} <<-EOF
47 attach echo_client scrub-MDT0000 scrub-MDT0000_UUID
53 ${ECHOCMD} "${LCTL} <<-EOF
61 local echodev=$(${RLCTL} dl | grep echo_client|awk '{print $1}')
64 ${ECHOCMD} "${LCTL} <<-EOF
69 for ((j=1; j<${threads}; j++)); do
70 ${ECHOCMD} "${LCTL} <<-EOF
72 test_mkdir ${tdir}${j}
76 ${ECHOCMD} "${LCTL} <<-EOF
78 --threads ${threads} 0 ${echodev} test_create \
79 -d ${tdir} -D ${threads} -b ${lbase} -c 0 -n ${usize}
84 do_rpc_nodes $(facet_active_host $SINGLEMDS) unload_modules
88 scrub_create_nfiles() {
92 local ldir="/test-${lbase}"
97 [ ${count} -eq 0 -o ${count} -gt ${total} ] && count=${total}
98 local usize=$((count / NTHREADS))
99 [ ${usize} -eq 0 ] && break
100 local tdir=${ldir}-${cycle}-
102 echo "[cycle: ${cycle}] [threads: ${threads}]"\
103 "[files: ${count}] [basedir: ${tdir}]"
104 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS ||
105 error "Fail to start MDS!"
109 stop ${SINGLEMDS} || error "Fail to stop MDS!"
111 total=$((total - usize * NTHREADS))
112 [ ${total} -eq 0 ] && break
113 lbase=$((lbase + usize))
124 for ((i=$MINCOUNT; i<=$MAXCOUNT; i=$((i * FACTOR)))); do
125 local nfiles=$((i - BASECOUNT))
126 local stime=$(date +%s)
128 echo "+++ start to create for ${i} files set at: $(date) +++"
129 scrub_create_nfiles ${nfiles} ${BASECOUNT} ${NTHREADS} ||
130 error "Fail to create files!"
131 echo "+++ end to create for ${i} files set at: $(date) +++"
132 local etime=$(date +%s)
133 local delta=$((etime - stime))
134 [ $delta -gt 0 ] || delta=1
135 echo "create ${nfiles} files used ${delta} seconds"
136 echo "create speed is $((nfiles / delta))/sec"
139 if [ ${BACKUP} -ne 0 ]; then
141 echo "backup/restore ${i} files start at: $(date)"
142 mds_backup_restore || error "Fail to backup/restore!"
143 echo "backup/restore ${i} files end at: $(date)"
145 delta=$((etime - stime))
146 [ $delta -gt 0 ] || delta=1
147 echo "backup/restore ${i} files used ${delta} seconds"
148 echo "backup/restore speed is $((i / delta))/sec"
150 mds_remove_ois || error "Fail to remove/recreate!"
153 echo "--- start to rebuild OI for $i files set at: $(date) ---"
154 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS > /dev/null ||
155 error "Fail to start MDS!"
158 local STATUS=$($SHOW_SCRUB |
159 awk '/^status/ { print $2 }')
160 [ "$STATUS" == "completed" ] && break
161 sleep 3 # check status every 3 seconds
164 echo "--- end to rebuild OI for ${i} files set at: $(date) ---"
165 local RTIME=$($SHOW_SCRUB | awk '/^run_time/ { print $2 }')
166 echo "rebuild OI for ${i} files used ${RTIME} seconds"
167 local SPEED=$($SHOW_SCRUB | awk '/^average_speed/ { print $2 }')
168 echo "rebuild speed is ${SPEED}/sec"
169 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
172 run_test 0 "OI scrub performance test"
174 # cleanup the system at last
176 complete $(basename $0) $SECONDS