set -e
ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 9977/LU-7105
-# LU-7105
-ALWAYS_EXCEPT=" 28 $SANITYN_EXCEPT"
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-SRCDIR=$(dirname $0)
-PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
SIZE=${SIZE:-40960}
-CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
OPENFILE=${OPENFILE:-openfile}
OPENUNLINK=${OPENUNLINK:-openunlink}
-export MULTIOP=${MULTIOP:-multiop}
export TMP=${TMP:-/tmp}
MOUNT_2=${MOUNT_2:-"yes"}
CHECK_GRANT=${CHECK_GRANT:-"yes"}
GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
-SAVE_PWD=$PWD
-
-export NAME=${NAME:-local}
-
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
. $LUSTRE/tests/test-framework.sh
-CLEANUP=${CLEANUP:-:}
-SETUP=${SETUP:-:}
init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-get_lustre_env
init_logging
+ALWAYS_EXCEPT="$SANITYN_EXCEPT "
+# bug number for skipped test: LU-7105
+ALWAYS_EXCEPT+=" 28"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
-# bug number for skipped test:
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
-# LU-2829 / LU-2887 - make allowances for ZFS slowness
+ # LU-2829 / LU-2887 - make allowances for ZFS slowness
TEST33_NFILES=${TEST33_NFILES:-1000}
fi
+
# 23 (min)"
[ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
+build_test_filter
+
FAIL_ON_ERROR=false
SETUP=${SETUP:-:}
check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
-build_test_filter
-
test_1() {
touch $DIR1/$tfile
[ -f $DIR2/$tfile ] || error "Check create"
}
run_test 102 "Test open by handle of unlinked file"
+# Compare file size between first & second mount, ensuring the client correctly
+# glimpses even with unused speculative locks - LU-11670
+test_103() {
+ [ $(lustre_version_code $ost1) -lt $(version_code 2.10.50) ] &&
+ skip "Lockahead needs OST version at least 2.10.50"
+
+ local testnum=23
+
+ test_mkdir -p $DIR/$tdir
+
+ # Force file on to OST0
+ $LFS setstripe -i 0 $DIR/$tdir
+
+ # Do not check multiple locks on glimpse
+ # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
+ $LCTL set_param fail_loc=0x415
+
+ # Delay write commit by 2 seconds to guarantee glimpse wins race
+ # The same fail_loc is used on client & server so it can work in the
+ # single node sanity setup
+ do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
+
+ echo "Incorrect size expected (no glimpse fix):"
+ lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
+ fi
+
+ # guarantee write commit timeout has expired
+ sleep 2
+
+ # Clear fail_loc on client
+ $LCTL set_param fail_loc=0
+
+ # Delay write commit by 2 seconds to guarantee glimpse wins race
+ # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
+ do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
+
+ # Write commit is still delayed by 2 seconds
+ lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
+ rc=$?
+ [ $rc -eq 0 ] || error "Lockahead test${testnum} failed, ${rc}"
+
+ # guarantee write commit timeout has expired
+ sleep 2
+
+ rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
+}
+run_test 103 "Test size correctness with lockahead"
+
+get_stat_xtimes()
+{
+ local xtimes
+
+ xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
+
+ echo ${xtimes[*]}
+}
+
+get_mdt_xtimes()
+{
+ local mdtdev=$1
+ local output
+ local xtimes
+
+ output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
+ ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
+ ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
+ ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
+
+ echo ${xtimes[*]}
+}
+
+check_mdt_xtimes()
+{
+ local mdtdev=$1
+ local xtimes=($(get_stat_xtimes))
+ local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
+
+ echo "STAT a|m|ctime ${xtimes[*]}"
+ echo "MDT a|m|ctime ${xtimes[*]}"
+ [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
+ error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
+ [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
+ error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
+ [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
+ error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
+}
+
+test_104() {
+ [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
+
+ local pid
+ local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
+ local atime_diff=$(do_facet $SINGLEMDS \
+ lctl get_param -n mdd.*MDT0000*.atime_diff)
+
+ do_facet $SINGLEMDS \
+ lctl set_param -n mdd.*MDT0000*.atime_diff=0
+
+ stack_trap "do_facet $SINGLEMDS \
+ lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
+
+ dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+ check_mdt_xtimes $mdtdev
+ sleep 2
+
+ dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+ check_mdt_xtimes $mdtdev
+ sleep 2
+ $MULTIOP $DIR2/$tfile Oz8192w8192_c &
+ pid=$!
+ sleep 2
+ dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+ sleep 2
+ kill -USR1 $pid && wait $pid || error "multiop failure"
+ check_mdt_xtimes $mdtdev
+
+ local xtimes
+ local mdt_xtimes
+
+ # Verify mtime/ctime is NOT upated on MDS when there is no modification
+ # on the client side
+ xtimes=($(get_stat_xtimes))
+ $MULTIOP $DIR/$tfile O_c &
+ pid=$!
+ sleep 2
+ kill -USR1 $pid && wait $pid || error "multiop failure"
+ mdt_xtimes=($(get_mdt_xtimes $mdtdev))
+ [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
+ error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
+ [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
+ error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
+ check_mdt_xtimes $mdtdev
+
+ sleep 2
+ # Change ctime via chmod
+ $MULTIOP $DIR/$tfile o_tc &
+ pid=$!
+ sleep 2
+ kill -USR1 $pid && wait $pid || error "multiop failure"
+ check_mdt_xtimes $mdtdev
+}
+run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
+
log "cleanup: ======================================================"
# kill and wait in each test only guarentee script finish, but command in script