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 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
17 skip "OI scrub performance only for ldiskfs" && exit 0
18 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.2.90) ]] &&
19 skip "Need MDS version at least 2.2.90" && exit 0
20 require_dsh_mds || exit 0
21 [ "$SLOW" = "no" ] && skip "skip scrub performance test under non-SLOW mode"
24 NTHREADS=${NTHREADS:-0}
27 MINCOUNT=${MINCOUNT:-8192}
28 MAXCOUNT=${MAXCOUNT:-32768}
31 RCMD="do_facet ${SINGLEMDS}"
32 RLCTL="${RCMD} ${LCTL}"
33 MDT_DEV="${FSNAME}-MDT0000"
34 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
35 SHOW_SCRUB="${RLCTL} get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
36 remote_mds && ECHOCMD=${RCMD} || ECHOCMD="eval"
38 if [ ${NTHREADS} -eq 0 ]; then
39 CPUCORE=$(${RCMD} cat /proc/cpuinfo | grep "processor.*:" | wc -l)
40 NTHREADS=$((CPUCORE * 2))
44 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
45 reformat_external_journal ${SINGLEMDS}
46 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype ldiskfs \
47 --reformat ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null || exit 2
50 ${ECHOCMD} "${LCTL} <<-EOF
51 attach echo_client scrub-MDT0000 scrub-MDT0000_UUID
57 ${ECHOCMD} "${LCTL} <<-EOF
65 local echodev=$(${RLCTL} dl | grep echo_client|awk '{print $1}')
68 ${ECHOCMD} "${LCTL} <<-EOF
73 for ((j=1; j<${threads}; j++)); do
74 ${ECHOCMD} "${LCTL} <<-EOF
76 test_mkdir ${tdir}${j}
80 ${ECHOCMD} "${LCTL} <<-EOF
82 --threads ${threads} 0 ${echodev} test_create \
83 -d ${tdir} -D ${threads} -b ${lbase} -c 0 -n ${usize}
88 do_rpc_nodes $(facet_active_host $SINGLEMDS) unload_modules
92 scrub_create_nfiles() {
96 local ldir="/test-${lbase}"
101 [ ${count} -eq 0 -o ${count} -gt ${total} ] && count=${total}
102 local usize=$((count / NTHREADS))
103 [ ${usize} -eq 0 ] && break
104 local tdir=${ldir}-${cycle}-
106 echo "[cycle: ${cycle}] [threads: ${threads}]"\
107 "[files: ${count}] [basedir: ${tdir}]"
108 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS ||
109 error "Fail to start MDS!"
113 stop ${SINGLEMDS} || error "Fail to stop MDS!"
115 total=$((total - usize * NTHREADS))
116 [ ${total} -eq 0 ] && break
117 lbase=$((lbase + usize))
128 for ((i=$MINCOUNT; i<=$MAXCOUNT; i=$((i * FACTOR)))); do
129 local nfiles=$((i - BASECOUNT))
130 local stime=$(date +%s)
132 echo "+++ start to create for ${i} files set at: $(date) +++"
133 scrub_create_nfiles ${nfiles} ${BASECOUNT} ${NTHREADS} ||
134 error "Fail to create files!"
135 echo "+++ end to create for ${i} files set at: $(date) +++"
136 local etime=$(date +%s)
137 local delta=$((etime - stime))
138 [ $delta -gt 0 ] || delta=1
139 echo "create ${nfiles} files used ${delta} seconds"
140 echo "create speed is $((nfiles / delta))/sec"
143 if [ ${BACKUP} -ne 0 ]; then
145 echo "backup/restore ${i} files start at: $(date)"
146 mds_backup_restore $SINGLEMDS ||
147 error "Fail to backup/restore!"
148 echo "backup/restore ${i} files end at: $(date)"
150 delta=$((etime - stime))
151 [ $delta -gt 0 ] || delta=1
152 echo "backup/restore ${i} files used ${delta} seconds"
153 echo "backup/restore speed is $((i / delta))/sec"
155 mds_remove_ois $SINGLEMDS ||
156 error "Fail to remove/recreate!"
159 echo "--- start to rebuild OI for $i files set at: $(date) ---"
160 start ${SINGLEMDS} $MDT_DEVNAME $MDS_MOUNT_OPTS > /dev/null ||
161 error "Fail to start MDS!"
164 local STATUS=$($SHOW_SCRUB |
165 awk '/^status/ { print $2 }')
166 [ "$STATUS" == "completed" ] && break
167 sleep 3 # check status every 3 seconds
170 echo "--- end to rebuild OI for ${i} files set at: $(date) ---"
171 local RTIME=$($SHOW_SCRUB | awk '/^run_time/ { print $2 }')
172 echo "rebuild OI for ${i} files used ${RTIME} seconds"
173 local SPEED=$($SHOW_SCRUB | awk '/^average_speed/ { print $2 }')
174 echo "rebuild speed is ${SPEED}/sec"
175 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
178 run_test 0 "OI scrub performance test"
180 # cleanup the system at last