+test_4() {
+ local before=0
+ local after=0
+
+ dd if=/dev/zero of=$DIR1/$tfile bs=2M count=1
+ cancel_lru_locks mdc
+
+ #define OBD_FAIL_MDC_GLIMPSE_DDOS 0x808
+ $LCTL set_param fail_loc=0x80000808
+ before=$(lctl get_param -n ldlm.namespaces.*mdc*.lock_count |
+ gawk '{cnt=cnt+$1} END{print cnt}')
+ for ((i=1; i < 100; i++))
+ do
+ tail -n100 $DIR1/$tfile > /dev/null
+ stat -f $DIR2/$tfile > /dev/null
+ done
+ after=$(lctl get_param -n ldlm.namespaces.*mdc*.lock_count |
+ gawk '{cnt=cnt+$1} END{print cnt}')
+ [[ $((after - before)) -ge 20 ]] &&
+ error "Too many locks found $((after - before))"
+ return 0
+}
+run_test 4 "DoM: glimpse doesn't produce duplicated locks"
+
+test_5() {
+ local before=$(date +%s)
+ local evict
+
+ dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 || return 1
+
+ multiop_bg_pause $DIR/$tfile O_Ac || return 1
+ setxattr=$!
+
+ multiop_bg_pause $DIR/$tfile O_Tc || return 1
+ truncate=$!
+
+ multiop $DIR2/$tfile Ow10 || return 1
+
+ getfattr -d $DIR2/$tfile
+
+#define OBD_FAIL_LLITE_TRUNCATE_INODE_PAUSE 0x1415
+ $LCTL set_param fail_loc=0x80001415 fail_val=5
+ kill -USR1 $truncate
+ sleep 1
+ multiop $DIR2/$tfile Ow10 &
+ sleep 1
+ kill -USR1 $setxattr
+
+ wait
+
+ evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
+
+ [ -z "$evict" ] || [[ $evict -le $before ]] ||
+ (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
+ error "eviction happened: $evict before:$before")
+}
+run_test 5 "DoM truncate deadlock"
+
+test_6() {
+ $MULTIOP $DIR1/$tfile Oz40960w100_z200w100c &
+ MULTIPID=$!
+
+ # let MULTIPID to create the file
+ sleep 1
+ $MULTIOP $DIR2/$tfile oO_RDWR:Tw100c
+ kill -USR1 $MULTIPID
+ wait
+ $MULTIOP $DIR2/$tfile oO_RDWR:z400w100c
+ $CHECKSTAT -s 500 $DIR2/$tfile || error "wrong size"
+}
+run_test 6 "Race two writes, check file size"
+
+test_7() {
+ dd if=/dev/zero of=$DIR1/$tfile bs=1000 count=1
+ cancel_lru_locks
+
+ $MULTIOP $DIR1/$tfile or1000c
+ dd if=/dev/urandom of=$DIR2/$tfile bs=1000 count=1
+ local md5_1=$(md5sum $DIR/$tfile | awk '{ print $1 }')
+ local md5_2=$(md5sum $DIR2/$tfile | awk '{ print $1 }')
+ [[ $md5_1 == $md5_2 ]] ||
+ error "Client reads stale page"
+}
+run_test 7 "Stale pages after read-on-open"
+