+ (( $index == $index2 )) && continue
+
+ failed=$((failed + 1))
+ echo "$fname MDT index mismatch $index != $index2"
+ done
+ done
+
+ echo "$failed/$count MDT index mismatches, expect ~2-4"
+ (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
+
+ local same=0
+ local expect
+
+ # verify that "crush" is still broken with all files on same MDT,
+ # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
+ [[ "$hash_type" == "crush" ]] && expect=$count ||
+ expect=$((count / MDSCOUNT))
+
+ # crush2 doesn't put all-numeric suffixes on the same MDT,
+ # filename like $tfile.12345678 should *not* be considered temp
+ for pattern in ${patterns[*]}; do
+ local base=${pattern%%X*}
+ local suff=${pattern#$base}
+
+ echo "pattern $pattern"
+ for (( i = 0; i < $count; i++ )); do
+ fname=$DIR/$tdir/$base$((${suff//X/1} + i))
+ touch $fname || error "touch $fname failed"
+ index2=$($LFS getstripe -m $fname)
+ (( $index != $index2 )) && continue
+
+ same=$((same + 1))
+ done
+ done
+
+ echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
+ (( same / ${#patterns[*]} < expect * 5 / 4 &&
+ same / ${#patterns[*]} > expect * 4 / 5 )) ||
+ error "MDT index match $((same / ${#patterns[*]}))/$count times"
+ same=0
+
+ # crush2 doesn't put suffixes with special characters on the same MDT
+ # filename like $tfile.txt.1234 should *not* be considered temp
+ for pattern in ${patterns[*]}; do
+ local base=${pattern%%X*}
+ local suff=${pattern#$base}
+
+ pattern=$base...${suff/XXX}
+ echo "pattern=$pattern"
+ for (( i = 0; i < $count; i++ )); do
+ fname=$(mktemp $DIR/$tdir/$pattern) ||
+ error "touch $fname failed"
+ index2=$($LFS getstripe -m $fname)
+ (( $index != $index2 )) && continue
+
+ same=$((same + 1))