+ 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))
+ 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"
+}
+
+test_33h() {
+ (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
+ (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
+ skip "Need MDS version at least 2.13.50"
+
+ sub_33h crush
+}
+run_test 33h "temp file is located on the same MDT as target (crush)"
+
+test_33hh() {
+ (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
+ echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
+ (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
+ skip "Need MDS version at least 2.15.0 for crush2"
+
+ sub_33h crush2