+test_51a() {
+ local filesize
+ local origfile=/etc/hosts
+
+ filesize=`stat -c %s $origfile`
+
+ # create an empty file
+ $MCREATE $DIR1/$tfile
+ # cache layout lock on both mount point
+ stat $DIR1/$tfile > /dev/null
+ stat $DIR2/$tfile > /dev/null
+
+ # open and sleep 2 seconds then read
+ $MULTIOP $DIR2/$tfile o_2r${filesize}c &
+ local pid=$!
+ sleep 0.1
+
+ # create the layout of testing file
+ dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
+
+ # MULTIOP proc should be able to read enough bytes and exit
+ sleep 2
+ kill -0 $pid && error "multiop is still there"
+ cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
+
+ rm -f $DIR1/$tfile
+}
+run_test 51a "layout lock: refresh layout should work"
+
+test_51b() {
+ local tmpfile=`mktemp`
+
+ # create an empty file
+ $MCREATE $DIR1/$tfile
+
+ # delay glimpse so that layout has changed when glimpse finish
+#define OBD_FAIL_GLIMPSE_DELAY 0x1404
+ $LCTL set_param fail_loc=0x1404
+ stat -c %s $DIR2/$tfile |tee $tmpfile &
+ local pid=$!
+ sleep 0.1
+
+ # create layout of testing file
+ dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
+
+ wait $pid
+ local fsize=`cat $tmpfile`
+
+ [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
+
+ rm -f $DIR1/$tfile $tmpfile
+}
+run_test 51b "layout lock: glimpse should be able to restart if layout changed"
+
+test_51c() {
+ # create an empty file
+ $MCREATE $DIR1/$tfile
+
+#define OBD_FAIL_MDS_LL_BLOCK 0x172
+ $LCTL set_param fail_loc=0x172
+
+ # change the layout of testing file
+ echo "Setting layout ..."
+ $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
+ pid=$!
+ sleep 0.1
+
+ # get layout of this file should wait until dd is finished
+ local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
+ [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
+
+ rm -f $DIR1/$tfile
+}
+run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
+
+test_60() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ # Create a file
+ test_mkdir -p $DIR1/$tdir
+ file1=$DIR1/$tdir/file
+ file2=$DIR2/$tdir/file
+
+ echo orig > $file2 || error "Could not create $file2"
+ version=$($LFS data_version $file1)
+
+ # Append data
+ echo append >> $file2 || error "Could not append to $file2"
+ version2=$($LFS data_version $file1)
+ [ "$version" != "$version2" ] ||
+ error "append did not change data version: $version"
+
+ # Overwrite data
+ echo overwrite > $file2 || error "Could not overwrite $file2"
+ version3=$($LFS data_version $file1)
+ [ "$version2" != "$version3" ] ||
+ error "overwrite did not change data version: $version2"
+
+ # Truncate before EOF
+ $TRUNCATE $file2 3 || error "Could not truncate $file2"
+ version4=$($LFS data_version $file1)
+ [ "$version3" != "$version4" ] ||
+ error "truncate did not change data version: $version3"
+
+ # Truncate after EOF
+ $TRUNCATE $file2 123456 || error "Could not truncate $file2"
+ version5=$($LFS data_version $file1)
+ [ "$version4" != "$version5" ] ||
+ error "truncate did not change data version: $version4"
+
+ # Chmod do not change version
+ chmod 400 $file2 || error "Could not chmod 400 $file2"
+ version6=$($LFS data_version $file1)
+ [ "$version5" == "$version6" ] ||
+ error "chmod should not change data version: $version5 != $version6"
+
+ # Chown do not change version
+ chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
+ version7=$($LFS data_version $file1)
+ [ "$version5" == "$version7" ] ||
+ error "chown should not change data version: $version5 != $version7"
+}
+run_test 60 "Verify data_version behaviour"
+
+test_70() {
+ local test_dir=$tdir/test_dir
+
+ mkdir -p $DIR1/$tdir
+ if [ $MDSCOUNT -ge 2 ]; then
+ local MDTIDX=1
+ $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
+ error "Create remote directory failed"
+ else
+ mkdir -p $DIR1/$test_dir
+ fi
+ cd $DIR2/$test_dir || error "cd directory failed"
+ rm -rf $DIR1/$test_dir || error "unlink directory failed"
+
+ cd $DIR2/$tdir || error "exit directory"
+}
+run_test 70 "cd directory && rm directory"
+