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}
17 skip "skip scrub performance test under non-SLOW mode" && exit 0
19 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
20 skip "OI scrub performance only for ldiskfs" && exit 0
21 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.2.90) ]] &&
22 skip "Need MDS version at least 2.2.90" && exit 0
23 require_dsh_mds || exit 0
25 NTHREADS=${NTHREADS:-0}
28 MINCOUNT=${MINCOUNT:-8192}
29 MAXCOUNT=${MAXCOUNT:-32768}
32 RCMD="do_facet ${SINGLEMDS}"
33 RLCTL="${RCMD} ${LCTL}"
34 MDT_DEV="${FSNAME}-MDT0000"
35 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
36 SHOW_SCRUB="${RLCTL} get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
37 remote_mds && ECHOCMD=${RCMD} || ECHOCMD="eval"
39 if [ ${NTHREADS} -eq 0 ]; then
40 CPUCORE=$(${RCMD} cat /proc/cpuinfo | grep "processor.*:" | wc -l)
41 NTHREADS=$((CPUCORE * 2))
46 if ! combined_mgs_mds ; then
47 do_rpc_nodes $(facet_active_host mgs) load_modules_local
48 add mgs $(mkfs_opts mgs $(mgsdevname)) --backfstype ldiskfs \
49 --reformat $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} ||
52 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "Fail to start MGS!"
55 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
56 reformat_external_journal ${SINGLEMDS}
57 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype ldiskfs \
58 --reformat ${MDT_DEVNAME} $(mdsvdevname 1) ${quiet:+>/dev/null} ||
62 ${ECHOCMD} "${LCTL} <<-EOF
63 attach echo_client scrub-MDT0000 scrub-MDT0000_UUID
69 ${ECHOCMD} "${LCTL} <<-EOF
77 local echodev=$(${RLCTL} dl | grep echo_client|awk '{print $1}')
80 ${ECHOCMD} "${LCTL} <<-EOF
85 for ((j=1; j<${threads}; j++)); do
86 ${ECHOCMD} "${LCTL} <<-EOF
88 test_mkdir ${tdir}${j}
92 ${ECHOCMD} "${LCTL} <<-EOF
94 --threads ${threads} 0 ${echodev} test_create \
95 -d ${tdir} -D ${threads} -b ${lbase} -c 0 -n ${usize}
101 do_rpc_nodes $(facet_active_host $SINGLEMDS) unload_modules
102 if ! combined_mgs_mds ; then
103 do_rpc_nodes $(facet_active_host mgs) unload_modules
108 scrub_create_nfiles() {
112 local ldir="/test-${lbase}"
117 [ ${count} -eq 0 -o ${count} -gt ${total} ] && count=${total}
118 local usize=$((count / NTHREADS))
119 [ ${usize} -eq 0 ] && break
120 local tdir=${ldir}-${cycle}-
122 echo "[cycle: ${cycle}] [threads: ${threads}]"\
123 "[files: ${count}] [basedir: ${tdir}]"
124 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS ||
125 error "Fail to start MDS!"
129 stop ${SINGLEMDS} || error "Fail to stop MDS!"
131 total=$((total - usize * NTHREADS))
132 [ ${total} -eq 0 ] && break
133 lbase=$((lbase + usize))
144 for ((i=$MINCOUNT; i<=$MAXCOUNT; i=$((i * FACTOR)))); do
145 local nfiles=$((i - BASECOUNT))
146 local stime=$(date +%s)
148 echo "+++ start to create for ${i} files set at: $(date) +++"
149 scrub_create_nfiles ${nfiles} ${BASECOUNT} ${NTHREADS} ||
150 error "Fail to create files!"
151 echo "+++ end to create for ${i} files set at: $(date) +++"
152 local etime=$(date +%s)
153 local delta=$((etime - stime))
154 [ $delta -gt 0 ] || delta=1
155 echo "create ${nfiles} files used ${delta} seconds"
156 echo "create speed is $((nfiles / delta))/sec"
159 if [ ${BACKUP} -ne 0 ]; then
161 echo "backup/restore ${i} files start at: $(date)"
162 mds_backup_restore $SINGLEMDS ||
163 error "Fail to backup/restore!"
164 echo "backup/restore ${i} files end at: $(date)"
166 delta=$((etime - stime))
167 [ $delta -gt 0 ] || delta=1
168 echo "backup/restore ${i} files used ${delta} seconds"
169 echo "backup/restore speed is $((i / delta))/sec"
171 mds_remove_ois $SINGLEMDS ||
172 error "Fail to remove/recreate!"
175 echo "--- start to rebuild OI for $i files set at: $(date) ---"
176 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS > /dev/null ||
177 error "Fail to start MDS!"
180 local STATUS=$($SHOW_SCRUB |
181 awk '/^status/ { print $2 }')
182 [ "$STATUS" == "completed" ] && break
183 sleep 3 # check status every 3 seconds
186 echo "--- end to rebuild OI for ${i} files set at: $(date) ---"
187 local RTIME=$($SHOW_SCRUB | awk '/^run_time/ { print $2 }')
188 echo "rebuild OI for ${i} files used ${RTIME} seconds"
189 local SPEED=$($SHOW_SCRUB | awk '/^average_speed/ { print $2 }')
190 echo "rebuild speed is ${SPEED}/sec"
191 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
194 run_test 0 "OI scrub performance test"
196 # cleanup the system at last