set -e
ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 5188/5749 13310 10764
-ALWAYS_EXCEPT=" 27o 27q 42a 42b 42c 42d 45 68 74b 75 $SANITY_EXCEPT"
+# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 13310 10764
+ALWAYS_EXCEPT=" 27o 27q 42a 42b 42c 42d 45 74b 75 $SANITY_EXCEPT"
# bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
#ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
}
run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
-if [ $STRIPECOUNT -eq 0 ]; then
- sc=1
-elif [ $STRIPECOUNT -gt 160 ]; then
-#LOV_MAX_STRIPE_COUNT is 160, 4294967295(-1) is included.
- [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
-else
- sc=$(($STRIPECOUNT - 1))
-fi
-
test_65d() {
mkdir -p $DIR/d65
+ if [ $STRIPECOUNT -le 0 ]; then
+ sc=1
+ elif [ $STRIPECOUNT -gt 160 ]; then
+#LOV_MAX_STRIPE_COUNT is 160
+ [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
+ else
+ sc=$(($STRIPECOUNT - 1))
+ fi
$SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
touch $DIR/d65/f4 $DIR/d65/f5
$LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
}
-run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
+run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
test_65e() {
mkdir -p $DIR/d65
}
run_test 67 "security test ====================================="
+LLOOP=
cleanup_68() {
trap 0
- if [ "$LOOPDEV" ]; then
- swapoff $LOOPDEV || error "swapoff failed"
- losetup -d $LOOPDEV || error "losetup -d failed"
- unset LOOPDEV LOOPNUM
+ if [ ! -z "$LLOOP" ]; then
+ swapoff $LLOOP || error "swapoff failed"
+ $LCTL blockdev_detach $LLOOP || error "detach failed"
+ rm -f $LLOOP
+ unset LLOOP
fi
rm -f $DIR/f68
}
swapon -s | awk '($1 == "'$1'") { print $4 }'
}
+
# excercise swapping to lustre by adding a high priority swapfile entry
# and then consuming memory until it is used.
test_68() {
grep -q obdfilter $LPROC/devices && \
skip "local OST" && return
- find_loop_dev
- dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
+ grep -q llite_lloop /proc/modules
+ [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
+
+ LLOOP=$TMP/lloop.`date +%s`.`date +%N`
+ dd if=/dev/zero of=$DIR/f68 bs=64k seek=2047 count=1
+ mkswap $DIR/f68
+
+ $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
trap cleanup_68 EXIT
- losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
- mkswap $LOOPDEV
- swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
+ swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
- echo "before: `swapon -s | grep $LOOPDEV`"
- KBFREE=`meminfo MemTotal`
- $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
- echo "after: `swapon -s | grep $LOOPDEV`"
- SWAPUSED=`swap_used $LOOPDEV`
+ echo "before: `swapon -s | grep $LLOOP`"
+ MEMTOTAL=`meminfo MemTotal`
+ $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
+ echo "after: `swapon -s | grep $LLOOP`"
+ SWAPUSED=`swap_used $LLOOP`
cleanup_68
run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
test_102c() {
- # b10930: get/set/list trusted.lov xattr
- echo "get/set/list trusted.lov xattr ..."
+ # b10930: get/set/list lustre.lov xattr
+ echo "get/set/list lustre.lov xattr ..."
[ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
mkdir -p $DIR/$tdir
chown $RUNAS_ID $DIR/$tdir
local testfile=$DIR/$tdir/$tfile
$RUNAS $SETSTRIPE $testfile 65536 1 2
- $RUNAS getfattr -d -m "^trusted" $testfile 2> /dev/null | \
- grep "trusted.lov" || error "can't get trusted.lov from $testfile"
+ $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
+ grep "lustre.lov" || error "can't get lustre.lov from $testfile"
local testfile2=${testfile}2
- local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
- grep "trusted.lov" |sed -e 's/[^=]\+=//' `
+ local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
+ grep "lustre.lov" |sed -e 's/[^=]\+=//' `
$RUNAS $MCREATE $testfile2
- $RUNAS setfattr -n trusted.lov -v $value $testfile2
+ $RUNAS setfattr -n lustre.lov -v $value $testfile2
local tmp_file=${testfile}3
$RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
[ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
[ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
}
-run_test 102c "non-root getfattr/setfattr for trusted.lov EAs ==========="
+run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
get_stripe_info() {
stripe_size=0
}
run_test 119b "Sparse directIO read must return actual read amount"
+LDLM_POOL_CTL_RECALC=1
+LDLM_POOL_CTL_SHRINK=2
+
+disable_pool_recalc() {
+ for NSD in $LPROC/ldlm/namespaces/*$1*; do
+ if test -f $NSD/pool/control; then
+ CONTROL=`cat $NSD/pool/control`
+ CONTROL=$((CONTROL & ~LDLM_POOL_CTL_RECALC))
+ echo "$CONTROL" > $NSD/pool/control
+ fi
+ done
+}
+
+enable_pool_recalc() {
+ for NSD in $LPROC/ldlm/namespaces/*$1*; do
+ if test -f $NSD/pool/control; then
+ CONTROL=`cat $NSD/pool/control`
+ CONTROL=$((CONTROL | LDLM_POOL_CTL_RECALC))
+ echo "$CONTROL" > $NSD/pool/control
+ fi
+ done
+}
+
+disable_pool_shrink() {
+ for NSD in $LPROC/ldlm/namespaces/*$1*; do
+ if test -f $NSD/pool/control; then
+ CONTROL=`cat $NSD/pool/control`
+ CONTROL=$((CONTROL & ~LDLM_POOL_CTL_SHRINK))
+ echo "$CONTROL" > $NSD/pool/control
+ fi
+ done
+}
+
+enable_pool_shrink() {
+ for NSD in $LPROC/ldlm/namespaces/*$1*; do
+ if test -f $NSD/pool/control; then
+ CONTROL=`cat $NSD/pool/control`
+ CONTROL=$((CONTROL | LDLM_POOL_CTL_SHRINK))
+ echo "$CONTROL" > $NSD/pool/control
+ fi
+ done
+}
+
+disable_pool() {
+ disable_pool_shrink $1
+ disable_pool_recalc $1
+}
+
+enable_pool() {
+ enable_pool_shrink $1
+ enable_pool_recalc $1
+}
+
+lru_resize_enable()
+{
+ enable_pool osc
+ enable_pool "filter-$FSNAME"
+ enable_pool mdc
+ enable_pool "mds-$FSNAME"
+}
+
+lru_resize_disable()
+{
+ disable_pool osc
+ disable_pool "filter-$FSNAME"
+ disable_pool mdc
+ disable_pool "mds-$FSNAME"
+}
+
test_120a() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
mkdir $DIR/$tdir
cancel_lru_locks mdc
stat $DIR/$tdir > /dev/null
blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120a "Early Lock Cancel: mkdir test"
test_120b() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
mkdir $DIR/$tdir
cancel_lru_locks mdc
stat $DIR/$tdir > /dev/null
can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120b "Early Lock Cancel: create test"
test_120c() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
touch $DIR/$tdir/d1/f1
cancel_lru_locks mdc
blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120c "Early Lock Cancel: link test"
test_120d() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
touch $DIR/$tdir
cancel_lru_locks mdc
stat $DIR/$tdir > /dev/null
blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120d "Early Lock Cancel: setattr test"
test_120e() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
mkdir $DIR/$tdir
dd if=/dev/zero of=$DIR/$tdir/f1 count=1
cancel_lru_locks mdc
blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120e "Early Lock Cancel: unlink test"
test_120f() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
[ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
[ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+ lru_resize_enable
}
run_test 120f "Early Lock Cancel: rename test"
test_120g() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable
count=10000
echo create $count files
- mkdir $DIR/$tdir
+ mkdir -p $DIR/$tdir
cancel_lru_locks mdc
cancel_lru_locks osc
t0=`date +%s`
echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
sleep 2
# wait for commitment of removal
+ lru_resize_enable
}
run_test 120g "Early Lock Cancel: performance test"
}
run_test 121 "read cancel race ========="
+test_124() {
+ [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no lru resize on server" && return 0
+ cancel_lru_locks mdc
+ lru_resize_enable
+ NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
+
+ # we want to test main pool functionality, that is cancel based on SLV
+ # this is why shrinkers are disabled
+ disable_pool_shrink "mds-$FSNAME"
+ disable_pool_shrink mdc
+
+ NR=2000
+ mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+
+ LRU_SIZE=`cat $NSDIR/lru_size`
+
+ # use touch to produce $NR new locks
+ log "create $NR files at $DIR/$tdir"
+ for ((i=0;i<$NR;i++)); do touch $DIR/$tdir/f$i; done
+
+ LRU_SIZE_B=`cat $NSDIR/lru_size`
+ if test $LRU_SIZE -ge $LRU_SIZE_B; then
+ skip "No cached locks created!"
+ cat $NSDIR/pool/state
+ return 0
+ fi
+ LRU_SIZE_B=$((LRU_SIZE_B-LRU_SIZE))
+ log "created $LRU_SIZE_B lock(s)"
+
+ # we want to sleep 30s to not make test too long
+ SLEEP=30
+ SLEEP_ADD=10
+
+ # we know that lru resize allows one client to hold $LIMIT locks for 10h
+ MAX_HRS=10
+
+ # get the pool limit
+ LIMIT=`cat $NSDIR/pool/limit`
+
+ # calculate lock volume factor taking into account sleep and data set
+ # use $LRU_SIZE_B here to take into account real number of locks created
+ # in the case of CMD, LRU_SIZE_B != $NR in most of cases
+ LVF=$(($LIMIT * $MAX_HRS * 60 * 60 / $LRU_SIZE_B / $SLEEP))
+
+ log "make client drop locks $LVF times faster so that ${SLEEP}s is enough to cancel $LRU_SIZE_B lock(s)"
+ OLD_LVF=`cat $NSDIR/pool/lock_volume_factor`
+ echo "$LVF" > $NSDIR/pool/lock_volume_factor
+ log "sleep for "$((SLEEP+SLEEP_ADD))"s"
+ sleep $((SLEEP+SLEEP_ADD))
+ echo "$OLD_LVF" > $NSDIR/pool/lock_volume_factor
+ LRU_SIZE_A=`cat $NSDIR/lru_size`
+
+ [ $LRU_SIZE_B -ge $LRU_SIZE_A ] || {
+ error "No locks dropped in "$((SLEEP+SLEEP_ADD))"s. LRU size: $LRU_SIZE_A"
+ lru_resize_enable
+ unlinkmany $DIR/$tdir/f $NR
+ return
+ }
+
+ log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in "$((SLEEP+SLEEP_ADD))"s"
+ lru_resize_enable
+ log "unlink $NR files at $DIR/$tdir"
+ unlinkmany $DIR/$tdir/f $NR
+}
+run_test 124 "lru resize ======================================="
test_125() { # 13358
mkdir -p $DIR/d125 || error "mkdir failed"