+ netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
+ [ "$PROT" != "tcp" ] && continue
+ RPORT=`echo $REMOTE | cut -d: -f2`
+ [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
+ LPORT=`echo $LOCAL | cut -d: -f2`
+ if [ $LPORT -ge 1024 ]; then
+ echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
+ netstat -tna
+ error "local: $LPORT > 1024, remote: $RPORT"
+ fi
+ done
+ true
+}
+run_test 100 "check local port using privileged port ==========="
+
+function get_named_value()
+{
+ local tag
+
+ tag=$1
+ while read ;do
+ line=$REPLY
+ case $line in
+ $tag*)
+ echo $line | sed "s/^$tag//"
+ break
+ ;;
+ esac
+ done
+}
+
+export CACHE_MAX=`cat $LPROC/llite/*/max_cached_mb | head -n 1`
+cleanup_101() {
+ for s in $LPROC/llite/*/max_cached_mb; do
+ echo $CACHE_MAX > $s
+ done
+ trap 0
+}
+
+test_101() {
+ local s
+ local discard
+ local nreads=10000
+ [ "$CPU" = "UML" ] && nreads=1000
+ local cache_limit=32
+
+ for s in $LPROC/osc/*-osc*/rpc_stats; do
+ echo 0 > $s
+ done
+ trap cleanup_101 EXIT
+ for s in $LPROC/llite/*; do
+ echo 0 > $s/read_ahead_stats
+ echo $cache_limit > $s/max_cached_mb
+ done
+
+ #
+ # randomly read 10000 of 64K chunks from file 3x 32MB in size
+ #
+ echo "nreads: $nreads file size: $((cache_limit * 3))MB"
+ $RANDOM_READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
+
+ discard=0
+ for s in $LPROC/llite/*; do
+ discard=$(($discard + $(cat $s/read_ahead_stats | get_named_value 'read but discarded')))
+ done
+ cleanup_101
+
+ if [ $(($discard * 10)) -gt $nreads ] ;then
+ for s in $LPROC/osc/*-osc*/rpc_stats; do
+ echo $s; cat $s
+ done
+ for s in $LPROC/llite/*/read_ahead_stats; do
+ echo $s; cat $s
+ done
+ error "too many ($discard) discarded pages"
+ fi
+ rm -f $DIR/$tfile || true
+}
+run_test 101 "check read-ahead for random reads ================"
+
+export SETUP_TEST102=no
+setup_test102() {
+ [ "$SETUP_TEST102" = "yes" ] && return
+ mkdir -p $DIR/$tdir
+ STRIPE_SIZE=65536
+ STRIPE_COUNT=4
+ STRIPE_OFFSET=2
+
+ trap cleanup_test102 EXIT
+ cd $DIR
+ $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
+ cd $DIR/$tdir
+ for num in 1 2 3 4
+ do
+ for count in 1 2 3 4
+ do
+ for offset in 0 1 2 3
+ do
+ local stripe_size=`expr $STRIPE_SIZE \* $num`
+ local file=file"$num-$offset-$count"
+ $SETSTRIPE $file -s $stripe_size -i $offset -c $count
+ done
+ done
+ done
+
+ cd $DIR
+ star -c f=$TMP/f102.tar $tdir
+ SETUP_TEST102=yes
+}
+
+cleanup_test102() {
+ [ "$SETUP_TEST102" = "yes" ] || return
+ trap 0
+ rm -f $TMP/f102.tar
+ rm -rf $DIR/$tdir
+ SETUP_TEST102=no
+}
+
+test_102a() {
+ local testfile=$DIR/xattr_testfile
+
+ rm -f $testfile
+ touch $testfile
+
+ [ "$UID" != 0 ] && skip "must run as root" && return
+ [ -z "`grep xattr $LPROC/mdc/*-mdc-*/connect_flags`" ] && skip "must have user_xattr" && return
+
+ [ -z "$(which setfattr 2>/dev/null)" ] && skip "could not find setfattr" && return
+
+ echo "set/get xattr..."
+ setfattr -n trusted.name1 -v value1 $testfile || error
+ [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
+ grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
+
+ setfattr -n user.author1 -v author1 $testfile || error
+ [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
+ grep "user.author1"`" == "user.author1=\"author1\"" ] || error
+
+ echo "listxattr..."
+ setfattr -n trusted.name2 -v value2 $testfile || error
+ setfattr -n trusted.name3 -v value3 $testfile || error
+ [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
+ grep "trusted.name" | wc -l` -eq 3 ] || error
+
+
+ setfattr -n user.author2 -v author2 $testfile || error
+ setfattr -n user.author3 -v author3 $testfile || error
+ [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
+ grep "user" | wc -l` -eq 3 ] || error
+
+ echo "remove xattr..."
+ setfattr -x trusted.name1 $testfile || error
+ getfattr -d -m trusted $testfile 2> /dev/null | \
+ grep "trusted.name1" && error || true
+
+ setfattr -x user.author1 $testfile || error
+ getfattr -d -m user $testfile 2> /dev/null | \
+ grep "user.author1" && error || true
+
+ # b10667: setting lustre special xattr be silently discarded
+ echo "set lustre special xattr ..."
+ setfattr -n "trusted.lov" -v "invalid value" $testfile || error
+
+ rm -f $testfile
+}
+run_test 102a "user xattr test =================================="
+
+test_102b() {
+ # b10930: get/set/list trusted.lov xattr
+ echo "get/set/list trusted.lov xattr ..."
+ [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
+ local testfile=$DIR/$tfile
+ $SETSTRIPE $testfile -s 65536 -i 1 -c 2
+ getfattr -d -m "^trusted" $testfile 2> /dev/null | \
+ grep "trusted.lov" || error "can't get trusted.lov from $testfile"
+
+ local testfile2=${testfile}2
+ local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
+ grep "trusted.lov" |sed -e 's/[^=]\+=//'`
+
+ $MCREATE $testfile2
+ setfattr -n trusted.lov -v $value $testfile2
+ local tmp_file=${testfile}3
+ $GETSTRIPE -v $testfile2 > $tmp_file
+ local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
+ local stripe_count=`grep "count" $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 102b "getfattr/setfattr for trusted.lov EAs ============"
+
+test_102c() {
+ # 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 -s 65536 -i 1 -c 2
+ $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 lustre.lov $testfile 2> /dev/null | \
+ grep "lustre.lov" |sed -e 's/[^=]\+=//' `
+
+ $RUNAS $MCREATE $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}'`
+ local stripe_count=`grep "count" $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 lustre.lov EAs ==========="
+
+get_stripe_info() {
+ stripe_size=0
+ stripe_count=0
+ stripe_offset=0
+ local lines=`sed -n '/obdidx/=' $1`
+ stripe_size=`awk '{if($1~/size/) print $2}' $1`
+ stripe_count=`awk '{if($1~/count/) print $2}' $1`
+ lines=`expr $lines + 1`
+ stripe_offset=`sed -n ${lines}p $1 |awk '{print $1}'`
+}
+
+compare_stripe_info1() {
+ for num in 1 2 3 4
+ do
+ for count in 1 2 3 4
+ do
+ for offset in 0 1 2 3
+ do
+ local size=`expr $STRIPE_SIZE \* $num`
+ local file=file"$num-$offset-$count"
+ local tmp_file=out
+ $GETSTRIPE -v $file > $tmp_file
+ get_stripe_info $tmp_file
+ if test $stripe_size -ne $size
+ then
+ error "$file: different stripe size" && return
+ fi
+ if test $stripe_count -ne $count
+ then
+ error "$file: different stripe count" && return
+ fi
+ if test $stripe_offset -ne 0
+ then
+ error "$file: different stripe offset" && return
+ fi
+ rm -f $tmp_file
+ done
+ done
+ done
+}
+
+compare_stripe_info2() {
+ for num in 1 2 3 4
+ do
+ for count in 1 2 3 4
+ do
+ for offset in 0 1 2 3
+ do
+ local size=`expr $STRIPE_SIZE \* $num`
+ local file=file"$num-$offset-$count"
+ local tmp_file=out
+ $GETSTRIPE -v $file > $tmp_file
+ get_stripe_info $tmp_file
+ if test $stripe_size -ne $size
+ then
+ error "$file: different stripe size" && return
+ fi
+ if test $stripe_count -ne $count
+ then
+ error "$file: different stripe count" && return
+ fi
+ if test $stripe_offset -ne $offset
+ then
+ error "$file: different stripe offset" && return
+ fi
+ rm -f $tmp_file
+ done
+ done
+ done
+}
+
+test_102d() {
+ # b10930: star test for trusted.lov xattr
+ star --xhelp 2>&1 | grep -q nolustre
+ if [ $? -ne 0 ]
+ then
+ skip "being skipped because a lustre-aware star is not installed." && return
+ fi
+ [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+ setup_test102
+ mkdir -p $DIR/d102d
+ star -x f=$TMP/f102.tar -C $DIR/d102d
+ cd $DIR/d102d/$tdir
+ compare_stripe_info1
+
+}
+run_test 102d "star restore stripe info from tarfile,not keep osts ==========="
+
+test_102e() {
+ # b10930: star test for trusted.lov xattr
+ star --xhelp 2>&1 | grep -q nolustre
+ [ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
+ [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+ setup_test102
+ mkdir -p $DIR/d102e
+ star -x -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
+ cd $DIR/d102e/$tdir
+ compare_stripe_info2
+}
+run_test 102e "star restore stripe info from tarfile, keep osts ==========="
+
+test_102f() {
+ # b10930: star test for trusted.lov xattr
+ star --xhelp 2>&1 | grep -q nolustre
+ [ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
+ [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+ setup_test102
+ mkdir -p $DIR/d102f
+ cd $DIR
+ star -copy $tdir $DIR/d102f
+ cd $DIR/d102f/$tdir
+ compare_stripe_info1
+}
+run_test 102f "star copy files, not keep osts ==========="
+
+test_102g() {
+ # b10930: star test for trusted.lov xattr
+ star --xhelp 2>&1 | grep -q nolustre
+ [ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
+ [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+ setup_test102
+ mkdir -p $DIR/d102g
+ cd $DIR
+ star -copy -preserve-osts $tdir $DIR/d102g
+ cd $DIR/d102g/$tdir
+ compare_stripe_info2
+ cleanup_test102
+}
+run_test 102g "star copy files, keep osts ==========="
+
+run_acl_subtest()
+{
+ $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
+ return $?
+}
+
+test_103 () {
+ [ "$UID" != 0 ] && skip "must run as root" && return
+ [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && skip "must have acl enabled" && return
+ [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
+ $GSS && skip "could not run under gss" && return
+
+ declare -a identity_old
+
+ for num in `seq $MDSCOUNT`; do
+ switch_identity $num true || identity_old[$num]=$?
+ done
+
+ SAVE_UMASK=`umask`
+ umask 0022
+ cd $DIR
+
+ echo "performing cp ..."
+ run_acl_subtest cp || error
+ echo "performing getfacl-noacl..."
+ run_acl_subtest getfacl-noacl || error
+ echo "performing misc..."
+ run_acl_subtest misc || error
+ echo "performing permissions..."
+ run_acl_subtest permissions || error
+ echo "performing setfacl..."
+ run_acl_subtest setfacl || error
+
+ # inheritance test got from HP
+ echo "performing inheritance..."
+ cp $LUSTRE/tests/acl/make-tree . || error
+ chmod +x make-tree || error
+ run_acl_subtest inheritance || error
+ rm -f make-tree
+
+ cd $SAVE_PWD
+ umask $SAVE_UMASK
+
+ for num in `seq $MDSCOUNT`; do
+ if [ "${identity_old[$num]}" = 1 ]; then
+ switch_identity $num false || identity_old[$num]=$?
+ fi
+ done
+}
+run_test 103 "acl test ========================================="
+
+test_104() {
+ touch $DIR/$tfile
+ lfs df || error "lfs df failed"
+ lfs df -ih || error "lfs df -ih failed"
+ lfs df -h $DIR || error "lfs df -h $DIR failed"
+ lfs df -i $DIR || error "lfs df -i $DIR failed"
+ lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
+ lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
+
+ OSC=`awk '/-osc-/ {print $4}' $LPROC/devices | head -n 1`
+ lctl --device %$OSC deactivate
+ lfs df || error "lfs df with deactivated OSC failed"
+ lctl --device %$OSC recover
+ lfs df || error "lfs df with reactivated OSC failed"
+}
+run_test 104 "lfs df [-ih] [path] test ========================="
+
+test_105a() {
+ # doesn't work on 2.4 kernels
+ touch $DIR/$tfile
+ if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
+ then
+ flocks_test on -f $DIR/$tfile || error "fail flock on"
+ else
+ flocks_test off -f $DIR/$tfile || error "fail flock off"
+ fi
+}
+run_test 105a "flock when mounted without -o flock test ========"
+
+test_105b() {
+ touch $DIR/$tfile
+ if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
+ then
+ flocks_test on -c $DIR/$tfile || error "fail flock on"
+ else
+ flocks_test off -c $DIR/$tfile || error "fail flock off"
+ fi
+}
+run_test 105b "fcntl when mounted without -o flock test ========"
+
+test_105c() {
+ touch $DIR/$tfile
+ if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
+ then
+ flocks_test on -l $DIR/$tfile || error "fail flock on"
+ else
+ flocks_test off -l $DIR/$tfile || error "fail flock off"
+ fi
+}
+run_test 105c "lockf when mounted without -o flock test ========"
+
+test_106() { #bug 10921
+ $DIR/$tdir && error "exec $DIR/$tdir succeeded"
+ chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
+}
+run_test 106 "attempt exec of dir followed by chown of that dir"
+
+test_107() {
+ CDIR=`pwd`
+ cd $DIR
+ ulimit -c unlimited
+ sleep 60 &
+ SLEEPPID=$!
+
+ file=`cat /proc/sys/kernel/core_pattern`
+ core_pid=`cat /proc/sys/kernel/core_uses_pid`
+ [ $core_pid -eq 1 ] && file=$file.$SLEEPPID
+ rm -f $file
+ sleep 1
+
+ kill -s 11 $SLEEPPID
+ wait $SLEEPPID
+ if [ -e $file ]; then
+ size=`stat -c%s $file`
+ [ $size -eq 0 ] && error "Fail to create core file $file"
+ else
+ error "Fail to create core file $file"
+ fi
+ rm -f $file
+ cd $CDIR
+}
+run_test 107 "Coredump on SIG"
+
+test_110() {
+ mkdir -p $DIR/d110
+ mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
+ mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
+ touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
+ touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
+
+ ls -l $DIR/d110
+}
+run_test 110 "filename length checking"
+
+test_115() {
+ OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
+ cut -c11-20)
+ [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
+ return
+ echo "Starting with $OSTIO_pre threads"
+
+ NUMTEST=20000
+ NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
+ [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
+ echo "$NUMTEST creates/unlinks"
+ mkdir -p $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile $NUMTEST
+ unlinkmany $DIR/$tdir/$tfile $NUMTEST
+
+ OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
+ cut -c11-20)
+
+ # don't return an error
+ [ $OSTIO_post -eq $OSTIO_pre ] && echo \
+ "FAIL: No addition ll_ost_io threads were created ($OSTIO_pre)" &&\
+ echo "This may be fine, depending on what ran before this test" &&\
+ echo "and how fast this system is." && return
+
+ echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
+}
+run_test 115 "verify dynamic thread creation===================="
+
+free_min_max () {
+ wait_delete_completed
+ AVAIL=($(cat $LPROC/osc/*[oO][sS][cC]-[^M]*/kbytesavail))
+ echo OST kbytes available: ${AVAIL[@]}
+ MAXI=0; MAXV=${AVAIL[0]}
+ MINI=0; MINV=${AVAIL[0]}
+ for ((i = 0; i < ${#AVAIL[@]}; i++)); do
+ #echo OST $i: ${AVAIL[i]}kb
+ if [ ${AVAIL[i]} -gt $MAXV ]; then
+ MAXV=${AVAIL[i]}; MAXI=$i
+ fi
+ if [ ${AVAIL[i]} -lt $MINV ]; then
+ MINV=${AVAIL[i]}; MINI=$i
+ fi
+ done
+ echo Min free space: OST $MINI: $MINV
+ echo Max free space: OST $MAXI: $MAXV
+}
+
+test_116() {
+ [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs" && return
+ remote_mds && skip "remote MDS" && return
+
+ echo -n "Free space priority "
+ cat $LPROC/lov/*-clilov-*/qos_prio_free
+ DELAY=$(cat $LPROC/lov/*-clilov-*/qos_maxage | head -1 | awk '{print $1}')
+ declare -a AVAIL
+ free_min_max
+ [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
+ return
+
+ # generate uneven OSTs
+ mkdir -p $DIR/$tdir/OST${MINI}
+ declare -i FILL
+ FILL=$(($MINV / 4))
+ echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
+ $SETSTRIPE $DIR/$tdir/OST${MINI} -i $MINI -c 1
+ i=0
+ while [ $FILL -gt 0 ]; do
+ i=$(($i + 1))
+ dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
+ FILL=$(($FILL - 2048))
+ echo -n .
+ done
+ FILL=$(($MINV / 4))
+ sync
+ sleep $DELAY
+
+ free_min_max
+ DIFF=$(($MAXV - $MINV))
+ DIFF2=$(($DIFF * 100 / $MINV))
+ echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
+ if [ $DIFF2 -gt 20 ]; then
+ echo "ok"
+ else
+ echo "failed - QOS mode won't be used"
+ error "QOS imbalance criteria not met"
+ return
+ fi
+
+ MINI1=$MINI; MINV1=$MINV
+ MAXI1=$MAXI; MAXV1=$MAXV
+
+ # now fill using QOS
+ echo writing a bunch of files to QOS-assigned OSTs
+ $SETSTRIPE $DIR/$tdir -c 1
+ i=0
+ while [ $FILL -gt 0 ]; do
+ i=$(($i + 1))
+ dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
+ FILL=$(($FILL - 200))
+ echo -n .
+ done
+ echo "wrote $i 200k files"
+ sync
+ sleep $DELAY
+
+ echo "Note: free space may not be updated, so measurements might be off"
+ free_min_max
+ DIFF2=$(($MAXV - $MINV))
+ echo "free space delta: orig $DIFF final $DIFF2"
+ [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
+ DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
+ echo "Wrote $DIFF to smaller OST $MINI1"
+ DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
+ echo "Wrote $DIFF2 to larger OST $MAXI1"
+ [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
+
+ # Figure out which files were written where
+ UUID=$(awk '/'$MINI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
+ echo $UUID
+ MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
+ echo "$MINC files created on smaller OST $MINI1"
+ UUID=$(awk '/'$MAXI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
+ echo $UUID
+ MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
+ echo "$MAXC files created on larger OST $MAXI1"
+ [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
+ [ $MAXC -gt $MINC ] || error "stripe QOS didn't balance free space"
+}
+run_test 116 "stripe QOS: free space balance ==================="
+
+test_117() # bug 10891
+{
+ dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
+ #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
+ sysctl -w lustre.fail_loc=0x21e
+ > $DIR/$tfile || error "truncate failed"
+ sysctl -w lustre.fail_loc=0
+ echo "Truncate succeeded."
+}
+run_test 117 "verify fsfilt_extend =========="
+
+# Reset async IO behavior after error case
+reset_async() {
+ FILE=$DIR/reset_async
+
+ # Ensure all OSCs are cleared
+ $LSTRIPE $FILE 0 -1 -1
+ dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
+ sync
+ rm $FILE
+}
+
+test_118a() #bug 11710
+{
+ reset_async
+
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ return 1;
+ fi
+}
+run_test 118a "verify O_SYNC works =========="
+
+test_118b()
+{
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_ENOENT 0x217
+ do_facet ost sysctl -w lustre.fail_loc=0x217
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ RC=$?
+ do_facet ost sysctl -w lustre.fail_loc=0
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+
+ if [[ $RC -eq 0 ]]; then
+ error "Must return error due to dropped pages, rc=$RC"
+ return 1;
+ fi
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ return 1;
+ fi
+
+ echo "Dirty pages not leaked on ENOENT"
+
+ # Due to the above error the OSC will issue all RPCs syncronously
+ # until a subsequent RPC completes successfully without error.
+ multiop $DIR/$tfile Ow4096yc
+ rm -f $DIR/$tfile
+
+ return 0
+}
+run_test 118b "Reclaim dirty pages on fatal error =========="
+
+test_118c()
+{
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_EROFS 0x216
+ do_facet ost sysctl -w lustre.fail_loc=0x216
+
+ # multiop should block due to fsync until pages are written
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
+ MULTIPID=$!
+ sleep 1
+
+ if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
+ error "Multiop failed to block on fsync, pid=$MULTIPID"
+ fi
+
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $WRITEBACK -eq 0 ]]; then
+ error "No page in writeback, writeback=$WRITEBACK"
+ fi
+
+ do_facet ost sysctl -w lustre.fail_loc=0
+ wait $MULTIPID
+ RC=$?
+ if [[ $RC -ne 0 ]]; then
+ error "Multiop fsync failed, rc=$RC"
+ fi
+
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "Dirty pages flushed via fsync on EROFS"
+ return 0
+}
+run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
+
+test_118d()
+{
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_BRW_PAUSE_BULK
+ do_facet ost sysctl -w lustre.fail_loc=0x214
+ # multiop should block due to fsync until pages are written
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
+ MULTIPID=$!
+ sleep 1
+
+ if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
+ error "Multiop failed to block on fsync, pid=$MULTIPID"
+ fi
+
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $WRITEBACK -eq 0 ]]; then
+ error "No page in writeback, writeback=$WRITEBACK"
+ fi
+
+ wait $MULTIPID || error "Multiop fsync failed, rc=$?"
+ do_facet ost sysctl -w lustre.fail_loc=0
+
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "Dirty pages gaurenteed flushed via fsync"
+ return 0
+}
+run_test 118d "Fsync validation inject a delay of the bulk =========="
+
+test_118f() {
+ reset_async
+
+ #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
+ sysctl -w lustre.fail_loc=0x8000040a
+
+ # Should simulate EINVAL error which is fatal
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ RC=$?
+ if [[ $RC -eq 0 ]]; then
+ error "Must return error due to dropped pages, rc=$RC"
+ fi
+
+ sysctl -w lustre.fail_loc=0x0
+
+ LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $LOCKED -ne 0 ]]; then
+ error "Locked pages remain in cache, locked=$LOCKED"
+ fi
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "No pages locked after fsync"
+
+ reset_async
+ return 0
+}
+run_test 118f "Simulate unrecoverable OSC side error =========="
+
+test_118g() {
+ reset_async
+
+ #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
+ sysctl -w lustre.fail_loc=0x406
+
+ # simulate local -ENOMEM
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ RC=$?
+
+ sysctl -w lustre.fail_loc=0
+ if [[ $RC -eq 0 ]]; then
+ error "Must return error due to dropped pages, rc=$RC"
+ fi
+
+ LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $LOCKED -ne 0 ]]; then
+ error "Locked pages remain in cache, locked=$LOCKED"
+ fi
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "No pages locked after fsync"
+
+ reset_async
+ return 0
+}
+run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
+
+test_118h() {
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
+ do_facet ost sysctl -w lustre.fail_loc=0x20e
+ # Should simulate ENOMEM error which is recoverable and should be handled by timeout
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ RC=$?
+
+ do_facet ost sysctl -w lustre.fail_loc=0
+ if [[ $RC -eq 0 ]]; then
+ error "Must return error due to dropped pages, rc=$RC"
+ fi
+
+ LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $LOCKED -ne 0 ]]; then
+ error "Locked pages remain in cache, locked=$LOCKED"
+ fi
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "No pages locked after fsync"
+
+ return 0
+}
+run_test 118h "Verify timeout in handling recoverables errors =========="
+
+test_118i() {
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
+ do_facet ost sysctl -w lustre.fail_loc=0x20e
+
+ # Should simulate ENOMEM error which is recoverable and should be handled by timeout
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
+ PID=$!
+ sleep 5
+ do_facet ost sysctl -w lustre.fail_loc=0
+
+ wait $PID
+ RC=$?
+ if [[ $RC -ne 0 ]]; then
+ error "got error, but should be not, rc=$RC"
+ fi
+
+ LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $LOCKED -ne 0 ]]; then
+ error "Locked pages remain in cache, locked=$LOCKED"
+ fi
+
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "No pages locked after fsync"
+
+ return 0
+}
+run_test 118i "Fix error before timeout in recoverable error =========="
+
+test_118j() {
+ remote_ost_nodsh && skip "remote OST" && return
+
+ reset_async
+
+ #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
+ do_facet ost sysctl -w lustre.fail_loc=0x220
+
+ # return -EIO from OST
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+ RC=$?
+ do_facet ost sysctl -w lustre.fail_loc=0x0
+ if [[ $RC -eq 0 ]]; then
+ error "Must return error due to dropped pages, rc=$RC"
+ fi
+
+ LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
+ DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+ WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
+ if [[ $LOCKED -ne 0 ]]; then
+ error "Locked pages remain in cache, locked=$LOCKED"
+ fi
+
+ # in recoverable error on OST we want resend and stay until it finished
+ if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
+ error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
+ fi
+
+ rm -f $DIR/$tfile
+ echo "No pages locked after fsync"
+
+ return 0
+}
+run_test 118j "Simulate unrecoverable OST side error =========="
+
+test_118k()
+{
+ #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
+ do_facet ost sysctl -w lustre.fail_loc=0x20e
+ mkdir -p $DIR/$tdir
+
+ for ((i=0;i<10;i++)); do
+ (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
+ error "dd to $DIR/$tdir/$tfile-$i failed" )&
+ SLEEPPID=$!
+ sleep 0.500s
+ kill $SLEEPPID
+ wait $SLEEPPID
+ done
+
+ sysctl -w lustre.fail_loc=0
+}
+run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
+
+test_119a() # bug 11737
+{
+ BSIZE=$((512 * 1024))
+ directio write $DIR/$tfile 0 1 $BSIZE
+ # We ask to read two blocks, which is more than a file size.
+ # directio will indicate an error when requested and actual
+ # sizes aren't equeal (a normal situation in this case) and
+ # print actual read amount.
+ NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
+ if [ "$NOB" != "$BSIZE" ]; then
+ error "read $NOB bytes instead of $BSIZE"
+ fi
+ rm -f $DIR/$tfile
+}
+run_test 119a "Short directIO read must return actual read amount"
+
+test_119b() # bug 11737
+{
+ [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
+
+ $SETSTRIPE $DIR/$tfile -c 2
+ dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
+ sync
+ multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
+ error "direct read failed"
+ rm -f $DIR/$tfile
+}
+run_test 119b "Sparse directIO read must return actual read amount"
+
+test_119c() # bug 13099
+{
+ BSIZE=1048576
+ directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
+ directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
+ rm -f $DIR/$tfile
+}
+run_test 119c "Testing for direct read hitting hole"
+
+test_120a() {
+ [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no early lock cancel on server" && return 0
+ lru_resize_disable mdc
+ lru_resize_disable osc
+ cancel_lru_locks mdc
+ stat $DIR/$tdir > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ mkdir $DIR/$tdir/d1
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ cancel_lru_locks mdc
+ stat $DIR/$tdir > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ touch $DIR/$tdir/f1
+ blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
+ touch $DIR/$tdir/d1/f1
+ cancel_lru_locks mdc
+ stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ touch $DIR/$tdir
+ cancel_lru_locks mdc
+ stat $DIR/$tdir > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ chmod a+x $DIR/$tdir
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ dd if=/dev/zero of=$DIR/$tdir/f1 count=1
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ dd if=$DIR/$tdir/f1 of=/dev/null
+ stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ unlink $DIR/$tdir/f1
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ 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
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ dd if=$DIR/$tdir/d1/f1 of=/dev/null
+ dd if=$DIR/$tdir/d2/f2 of=/dev/null
+ stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ 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 mdc
+ lru_resize_enable osc
+}
+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 mdc
+ lru_resize_disable osc
+ count=10000
+ echo create $count files
+ mkdir -p $DIR/$tdir
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ t0=`date +%s`
+
+ can0=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk0=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ createmany -o $DIR/$tdir/f $count
+ sync
+ can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ t1=`date +%s`
+ echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
+ echo rm $count files
+ rm -r $DIR/$tdir
+ sync
+ can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+ blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+ t2=`date +%s`
+ echo total: $count removes in $((t2-t1))
+ echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
+ sleep 2
+ # wait for commitment of removal
+ lru_resize_enable mdc
+ lru_resize_enable osc
+}
+run_test 120g "Early Lock Cancel: performance test"
+
+test_121() { #bug #10589
+ rm -rf $DIR/$tfile
+ writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out/ {print $1}')
+#define OBD_FAIL_LDLM_CANCEL_RACE 0x310
+ sysctl -w lustre.fail_loc=0x310
+ cancel_lru_locks osc > /dev/null
+ reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in/ {print $1}')
+ sysctl -w lustre.fail_loc=0
+ [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
+}
+run_test 121 "read cancel race ========="
+
+test_124a() {
+ [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
+ skip "no lru resize on server" && return 0
+ NR=2000
+ mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+
+ # use touch to produce $NR new locks
+ log "create $NR files at $DIR/$tdir"
+ createmany -o $DIR/$tdir/f $NR ||
+ error "failed to create $NR files in $DIR/$tdir"
+
+ cancel_lru_locks mdc
+ ls -l $DIR/$tdir > /dev/null
+
+ NSDIR=""
+ LRU_SIZE=0
+ for F in $LPROC/ldlm/namespaces/*mdc-*/lru_size; do
+ LRU_SIZE=$(cat $F)
+ if [ $LRU_SIZE -gt $(default_lru_size) ]; then
+ NSDIR=$(dirname $F)
+ log "using $(basename $NSDIR) namespace"
+ break