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"
echo "PATH=$PATH"
sh oos2.sh $MOUNT1 $MOUNT2
wait_delete_completed
- grant_error=`dmesg | grep "> available"`
+ grant_error=$(dmesg | grep "< tot_grant")
[ -z "$grant_error" ] || error "$grant_error"
}
run_test 15 "test out-of-space with multiple writers ==========="
pdo_sched() {
# how long 40-47 take with specific delay
# sleep 0.1 # 78s
- sleep 0.2 # 103s
+ # sleep 0.2 # 103s
# sleep 0.3 # 124s
- # sleep 0.5 # 164s
+ sleep 0.5 # 164s
}
# for pdo testing, we must cancel MDT-MDT locks as well as client locks to
mkdir -p $DIR1/$tfile-1/
mkdir -p $DIR2/$tfile-2/
- local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
- 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
- do_facet $SINGLEMDS lctl set_param -n \
- 'lod.lustre-MDT*/qos_threshold_rr' 100
+ local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
+ lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
+ do_facet $SINGLEMDS "$LCTL set_param -n \
+ lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
#define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
- do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
+ do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
$LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
local PID1=$!
local PID2=$!
wait $PID2
wait $PID1
- do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
- do_facet $SINGLEMDS "lctl set_param -n \
- 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
+ do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
+ do_facet $SINGLEMDS "$LCTL set_param -n \
+ lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
$LFS getstripe $DIR1/$tfile-1/file1
rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
}
run_test 93 "alloc_rr should not allocate on same ost"
+test_94() {
+ $LCTL set_param osc.*.idle_timeout=0
+ dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
+
+ local before=$(date +%s)
+ local evict
+
+ $LCTL mark write
+#define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
+ $LCTL set_param fail_val=5 fail_loc=0x80000312
+ dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
+ local pid=$!
+ sleep 2
+
+#define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
+ $LCTL set_param fail_val=6 fail_loc=0x80000329
+ $LCTL mark kill $pid
+ kill -ALRM $pid
+
+ dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
+
+ wait $pid
+ dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
+
+ evict=$(do_facet client $LCTL get_param \
+ osc.$FSNAME-OST*-osc-*/state |
+ awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
+
+ [ -z "$evict" ] || [[ $evict -le $before ]] ||
+ (do_facet client $LCTL get_param \
+ osc.$FSNAME-OST*-osc-*/state;
+ error "eviction happened: $evict before:$before")
+ $LCTL set_param osc.*.idle_timeout=debug
+}
+run_test 94 "signal vs CP callback race"
+
# Data-on-MDT tests
test_100a() {
skip "Reserved for glimpse-ahead" && return
}
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"
+ [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
+ skip "Need MDS version at least 2.12.4"
+
+ 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"
+
+test_105() {
+ test_mkdir -p $DIR/$tdir
+ echo test > $DIR/$tdir/$tfile
+ $LCTL set_param fail_loc=0x416
+ cancel_lru_locks osc & sleep 1
+ fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
+ wait
+ [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
+}
+run_test 105 "Glimpse and lock cancel race"
+
log "cleanup: ======================================================"
# kill and wait in each test only guarentee script finish, but command in script