+test_42c() {
+ trunc_test 42c 1024
+ [ $BEFOREWRITES -eq $AFTERWRITES ] && \
+ error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
+ rm $file
+}
+run_test 42c "test partial truncate of file with cached dirty data"
+
+test_42d() {
+ trunc_test 42d 0
+ [ $BEFOREWRITES -eq $AFTERWRITES ] || \
+ error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
+ rm $file
+}
+run_test 42d "test complete truncate of file with cached dirty data"
+
+test_43() {
+ mkdir $DIR/$tdir
+ cp -p /bin/ls $DIR/$tdir/$tfile
+ exec 9>> $DIR/$tdir/$tfile
+ $DIR/$tdir/$tfile && error || true
+ exec 9<&-
+}
+run_test 43 "execution of file opened for write should return -ETXTBSY"
+
+test_43a() {
+ mkdir -p $DIR/d43
+ cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
+ $DIR/d43/multiop $TMP/test43.junk O_c &
+ MULTIPID=$!
+ sleep 1
+ multiop $DIR/d43/multiop Oc && error "expected error, got success"
+ kill -USR1 $MULTIPID || return 2
+ wait $MULTIPID || return 3
+ rm $TMP/test43.junk
+}
+run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
+
+test_43b() {
+ mkdir -p $DIR/d43
+ cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
+ $DIR/d43/multiop $TMP/test43.junk O_c &
+ MULTIPID=$!
+ sleep 1
+ truncate $DIR/d43/multiop 0 && error "expected error, got success"
+ kill -USR1 $MULTIPID || return 2
+ wait $MULTIPID || return 3
+ rm $TMP/test43.junk
+}
+run_test 43b "truncate of file being executed should return -ETXTBSY"
+
+test_43c() {
+ local testdir="$DIR/d43c"
+ mkdir -p $testdir
+ cp $SHELL $testdir/
+ ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
+ ( cd $testdir && md5sum -c)
+}
+run_test 43c "md5sum of copy into lustre========================"
+
+test_44() {
+ [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
+ dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
+ dd if=$DIR/f1 bs=4k count=1
+}
+run_test 44 "zero length read from a sparse stripe ============="
+
+test_44a() {
+ local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
+ awk '{print $2}'`
+ [ -z "$nstripe" ] && skip "can't get stripe info" && return
+ [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
+ local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
+ awk '{print $2}'`
+ if [ $nstripe -eq 0 -o $nstripe -gt 1024 ] ; then
+ nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
+ fi
+
+ OFFSETS="0 $((stride/2)) $((stride-1))"
+ for offset in $OFFSETS ; do
+ for i in `seq 0 $((nstripe-1))`; do
+ local GLOBALOFFSETS=""
+ local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
+ local myfn=$DIR/d44a-$size
+ echo "--------writing $myfn at $size"
+ ll_sparseness_write $myfn $size || error "ll_sparseness_write"
+ GLOBALOFFSETS="$GLOBALOFFSETS $size"
+ ll_sparseness_verify $myfn $GLOBALOFFSETS \
+ || error "ll_sparseness_verify $GLOBALOFFSETS"
+
+ for j in `seq 0 $((nstripe-1))`; do
+ size=$((((j + $nstripe )*$stride + $offset))) # Bytes
+ ll_sparseness_write $myfn $size || error "ll_sparseness_write"
+ GLOBALOFFSETS="$GLOBALOFFSETS $size"
+ done
+ ll_sparseness_verify $myfn $GLOBALOFFSETS \
+ || error "ll_sparseness_verify $GLOBALOFFSETS"
+ rm -f $myfn
+ done
+ done
+}
+run_test 44a "test sparse pwrite ==============================="
+
+dirty_osc_total() {
+ tot=0
+ for d in $LPROC/osc/*/cur_dirty_bytes; do
+ tot=$(($tot + `cat $d`))
+ done
+ echo $tot
+}
+do_dirty_record() {
+ before=`dirty_osc_total`
+ echo executing "\"$*\""
+ eval $*
+ after=`dirty_osc_total`
+ echo before $before, after $after
+}
+test_45() {
+ f="$DIR/f45"
+ # Obtain grants from OST if it supports it
+ echo blah > ${f}_grant
+ stop_writeback
+ sync
+ do_dirty_record "echo blah > $f"
+ [ $before -eq $after ] && error "write wasn't cached"
+ do_dirty_record "> $f"
+ [ $before -gt $after ] || error "truncate didn't lower dirty count"
+ do_dirty_record "echo blah > $f"
+ [ $before -eq $after ] && error "write wasn't cached"
+ do_dirty_record "sync"
+ [ $before -gt $after ] || error "writeback didn't lower dirty count"
+ do_dirty_record "echo blah > $f"
+ [ $before -eq $after ] && error "write wasn't cached"
+ do_dirty_record "cancel_lru_locks osc"
+ [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
+ start_writeback
+}
+run_test 45 "osc io page accounting ============================"
+
+page_size() {
+ getconf PAGE_SIZE
+}
+
+# in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
+# test tickles a bug where re-dirtying a page was failing to be mapped to the
+# objects offset and an assert hit when an rpc was built with 1023's mapped
+# offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
+test_46() {
+ f="$DIR/f46"
+ stop_writeback
+ sync
+ dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
+ sync
+ dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
+ dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
+ sync
+ start_writeback
+}
+run_test 46 "dirtying a previously written page ================"
+
+# Check that device nodes are created and then visible correctly (#2091)
+test_47() {
+ cmknod $DIR/test_47_node || error
+}
+run_test 47 "Device nodes check ================================"
+
+test_48a() { # bug 2399
+ check_kernel_version 34 || return 0
+ mkdir -p $DIR/d48a
+ cd $DIR/d48a
+ mv $DIR/d48a $DIR/d48.new || error "move directory failed"
+ mkdir $DIR/d48a || error "recreate directory failed"
+ touch foo || error "'touch foo' failed after recreating cwd"
+ mkdir bar || error "'mkdir foo' failed after recreating cwd"
+ if check_kernel_version 44; then
+ touch .foo || error "'touch .foo' failed after recreating cwd"
+ mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
+ fi
+ ls . || error "'ls .' failed after recreating cwd"
+ ls .. || error "'ls ..' failed after removing cwd"
+ cd . || error "'cd .' failed after recreating cwd"
+ mkdir . && error "'mkdir .' worked after recreating cwd"
+ rmdir . && error "'rmdir .' worked after recreating cwd"
+ ln -s . baz || error "'ln -s .' failed after recreating cwd"
+ cd .. || error "'cd ..' failed after recreating cwd"
+}
+run_test 48a "Access renamed working dir (should return errors)="
+
+test_48b() { # bug 2399
+ check_kernel_version 34 || return 0
+ mkdir -p $DIR/d48b
+ cd $DIR/d48b
+ rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
+ touch foo && error "'touch foo' worked after removing cwd"
+ mkdir foo && error "'mkdir foo' worked after removing cwd"
+ if check_kernel_version 44; then
+ touch .foo && error "'touch .foo' worked after removing cwd"
+ mkdir .foo && error "'mkdir .foo' worked after removing cwd"
+ fi
+ ls . && error "'ls .' worked after removing cwd"
+ ls .. || error "'ls ..' failed after removing cwd"
+ cd . && error "'cd .' worked after removing cwd"
+ mkdir . && error "'mkdir .' worked after removing cwd"
+ rmdir . && error "'rmdir .' worked after removing cwd"
+ ln -s . foo && error "'ln -s .' worked after removing cwd"
+ cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
+}
+run_test 48b "Access removed working dir (should return errors)="
+
+test_48c() { # bug 2350
+ check_kernel_version 36 || return 0
+ #sysctl -w lnet.debug=-1
+ #set -vx
+ mkdir -p $DIR/d48c/dir
+ cd $DIR/d48c/dir
+ $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
+ $TRACE touch foo && error "'touch foo' worked after removing cwd"
+ $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
+ if check_kernel_version 44; then
+ touch .foo && error "'touch .foo' worked after removing cwd"
+ mkdir .foo && error "'mkdir .foo' worked after removing cwd"
+ fi
+ $TRACE ls . && error "'ls .' worked after removing cwd"
+ $TRACE ls .. || error "'ls ..' failed after removing cwd"
+ $TRACE cd . && error "'cd .' worked after removing cwd"
+ $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
+ $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
+ $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
+ $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
+}
+run_test 48c "Access removed working subdir (should return errors)"
+
+test_48d() { # bug 2350
+ check_kernel_version 36 || return 0
+ #sysctl -w lnet.debug=-1
+ #set -vx
+ mkdir -p $DIR/d48d/dir
+ cd $DIR/d48d/dir
+ $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
+ $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
+ $TRACE touch foo && error "'touch foo' worked after removing parent"
+ $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
+ if check_kernel_version 44; then
+ touch .foo && error "'touch .foo' worked after removing parent"
+ mkdir .foo && error "'mkdir .foo' worked after removing parent"
+ fi
+ $TRACE ls . && error "'ls .' worked after removing parent"
+ $TRACE ls .. && error "'ls ..' worked after removing parent"
+ $TRACE cd . && error "'cd .' worked after recreate parent"
+ $TRACE mkdir . && error "'mkdir .' worked after removing parent"
+ $TRACE rmdir . && error "'rmdir .' worked after removing parent"
+ $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
+ $TRACE cd .. && error "'cd ..' worked after removing parent" || true
+}
+run_test 48d "Access removed parent subdir (should return errors)"
+
+test_48e() { # bug 4134
+ check_kernel_version 41 || return 0
+ #sysctl -w lnet.debug=-1
+ #set -vx
+ mkdir -p $DIR/d48e/dir
+ cd $DIR/d48e/dir
+ $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
+ $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
+ $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
+ $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
+ # On a buggy kernel addition of "touch foo" after cd .. will
+ # produce kernel oops in lookup_hash_it
+ touch ../foo && error "'cd ..' worked after recreate parent"
+ cd $DIR
+ $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
+}
+run_test 48e "Access to recreated parent subdir (should return errors)"
+
+test_50() {
+ # bug 1485
+ mkdir $DIR/d50
+ cd $DIR/d50
+ ls /proc/$$/cwd || error
+}
+run_test 50 "special situations: /proc symlinks ==============="
+
+test_51() {
+ # bug 1516 - create an empty entry right after ".." then split dir
+ mkdir $DIR/d51
+ touch $DIR/d51/foo
+ $MCREATE $DIR/d51/bar
+ rm $DIR/d51/foo
+ createmany -m $DIR/d51/longfile 201
+ FNUM=202
+ while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
+ $MCREATE $DIR/d51/longfile$FNUM
+ FNUM=$(($FNUM + 1))
+ echo -n "+"
+ done
+ ls -l $DIR/d51 > /dev/null || error
+}
+run_test 51 "special situations: split htree with empty entry =="
+
+#export NUMTEST=70000
+# FIXME: I select a relatively small number to do basic test.
+# large number may give panic(). debugging on this is going on.
+export NUMTEST=70
+test_51b() {
+ NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
+ [ $NUMFREE -lt 21000 ] && \
+ skip "not enough free inodes ($NUMFREE)" && \
+ return
+
+ check_kernel_version 40 || NUMTEST=31000
+ [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
+
+ mkdir -p $DIR/d51b
+ createmany -d $DIR/d51b/t- $NUMTEST
+}
+run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
+
+test_51c() {
+ [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
+ return
+
+ unlinkmany -d $DIR/d51b/t- $NUMTEST
+}
+run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
+
+test_51d() {
+ [ "$OSTCOUNT" -lt "3" ] && skip "skipping test with few OSTs" && return
+ mkdir -p $DIR/d51d
+ createmany -o $DIR/d51d/t- 1000
+ $LFS getstripe $DIR/d51d > $TMP/files
+ for N in `seq 0 $((OSTCOUNT - 1))`; do
+ OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
+ OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
+ log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
+ done
+ unlinkmany $DIR/d51d/t- 1000
+
+ NLAST=0
+ for N in `seq 1 $((OSTCOUNT - 1))`; do
+ [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
+ error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
+ [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
+ error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
+
+ [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
+ error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
+ [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
+ error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
+ NLAST=$N
+ done
+}
+run_test 51d "check object distribution ===================="
+
+test_52a() {
+ [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
+ mkdir -p $DIR/d52a
+ touch $DIR/d52a/foo
+ chattr =a $DIR/d52a/foo || error "chattr =a failed"
+ echo bar >> $DIR/d52a/foo || error "append bar failed"
+ cp /etc/hosts $DIR/d52a/foo && error "cp worked"
+ rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
+ link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
+ echo foo >> $DIR/d52a/foo || error "append foo failed"
+ mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
+ lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
+ chattr -a $DIR/d52a/foo || error "chattr -a failed"
+
+ rm -fr $DIR/d52a || error "cleanup rm failed"
+}
+run_test 52a "append-only flag test (should return errors) ====="
+
+test_52b() {
+ [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
+ mkdir -p $DIR/d52b
+ touch $DIR/d52b/foo
+ chattr =i $DIR/d52b/foo || error
+ cat test > $DIR/d52b/foo && error
+ cp /etc/hosts $DIR/d52b/foo && error
+ rm -f $DIR/d52b/foo 2>/dev/null && error
+ link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
+ echo foo >> $DIR/d52b/foo && error
+ mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
+ [ -f $DIR/d52b/foo ] || error
+ [ -f $DIR/d52b/foo_ren ] && error
+ lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
+ chattr -i $DIR/d52b/foo || error
+
+ rm -fr $DIR/d52b || error
+}
+run_test 52b "immutable flag test (should return errors) ======="
+
+test_53() {
+ # only test MDT0000
+ for i in `ls -d $LPROC/osc/*-osc-MDT0000 2> /dev/null` ; do
+ ostname=`basename $i | cut -d - -f 1-2`
+ ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
+ mds_last=`cat $i/prealloc_last_id`
+ echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
+ if [ $ost_last != $mds_last ]; then
+ error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
+ fi
+ done
+}
+run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
+
+test_54a() {
+ [ ! -f "$SOCKETSERVER" ] && skip "no socketserver, skipping" && return
+ [ ! -f "$SOCKETCLIENT" ] && skip "no socketclient, skipping" && return
+ $SOCKETSERVER $DIR/socket
+ $SOCKETCLIENT $DIR/socket || error
+ $MUNLINK $DIR/socket
+}
+run_test 54a "unix domain socket test =========================="
+
+test_54b() {
+ f="$DIR/f54b"
+ mknod $f c 1 3
+ chmod 0666 $f
+ dd if=/dev/zero of=$f bs=`page_size` count=1
+}
+run_test 54b "char device works in lustre ======================"
+
+find_loop_dev() {
+ [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
+ [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
+ [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
+
+ for i in `seq 3 7`; do
+ losetup $LOOPBASE$i > /dev/null 2>&1 && continue
+ LOOPDEV=$LOOPBASE$i
+ LOOPNUM=$i
+ break
+ done
+}
+
+test_54c() {
+ tfile="$DIR/f54c"
+ tdir="$DIR/d54c"
+ loopdev="$DIR/loop54c"
+
+ find_loop_dev
+ [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
+ mknod $loopdev b 7 $LOOPNUM
+ echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
+ dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
+ losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
+ mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
+ mkdir -p $tdir
+ mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
+ dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
+ df $tdir
+ dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
+ $UMOUNT $tdir
+ losetup -d $loopdev
+ rm $loopdev
+}
+run_test 54c "block device works in lustre ====================="
+
+test_54d() {
+ f="$DIR/f54d"
+ string="aaaaaa"
+ mknod $f p
+ [ "$string" = `echo $string > $f | cat $f` ] || error
+}
+run_test 54d "fifo device works in lustre ======================"
+
+test_54e() {
+ check_kernel_version 46 || return 0
+ f="$DIR/f54e"
+ string="aaaaaa"
+ mknod $f c 4 0
+ echo $string > $f || error
+}
+run_test 54e "console/tty device works in lustre ======================"
+
+check_fstype() {
+ grep -q $FSTYPE /proc/filesystems && return 1
+ modprobe $FSTYPE
+ grep -q $FSTYPE /proc/filesystems && return 1
+ insmod ../$FSTYPE/$FSTYPE.o
+ grep -q $FSTYPE /proc/filesystems && return 1
+ insmod ../$FSTYPE/$FSTYPE.ko
+ grep -q $FSTYPE /proc/filesystems && return 1
+ return 0
+}
+
+test_55() {
+ rm -rf $DIR/d55
+ mkdir $DIR/d55
+ check_fstype && skip "can't find fs $FSTYPE" && return
+ mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
+ touch $DIR/d55/foo
+ $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
+ $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
+ echo "check for $EXT2_DEV. Please wait..."
+ rm -rf $DIR/d55/*
+ $UMOUNT $DIR/d55 || error "unmounting"
+}
+run_test 55 "check iopen_connect_dentry() ======================"
+
+test_56() {
+ rm -rf $DIR/d56
+ $SETSTRIPE -d $DIR
+ mkdir $DIR/d56
+ mkdir $DIR/d56/dir
+ NUMFILES=3
+ NUMFILESx2=$(($NUMFILES * 2))
+ for i in `seq 1 $NUMFILES` ; do
+ touch $DIR/d56/file$i
+ touch $DIR/d56/dir/file$i
+ done
+
+ # test lfs getstripe with --recursive
+ FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
+ [ $FILENUM -eq $NUMFILESx2 ] || error \
+ "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
+ FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
+ [ $FILENUM -eq $NUMFILES ] || error \
+ "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
+ echo "lfs getstripe --recursive passed."
+
+ # test lfs getstripe with file instead of dir
+ FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
+ [ $FILENUM -eq 1 ] || error \
+ "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
+ echo "lfs getstripe file passed."
+
+ #test lfs getstripe with --verbose
+ [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
+ error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
+ [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
+ "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
+ echo "lfs getstripe --verbose passed."
+
+ #test lfs getstripe with --obd
+ $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
+ error "lfs getstripe --obd wrong_uuid should return error message"
+
+ [ "$OSTCOUNT" -lt 2 ] && \
+ skip "skipping other lfs getstripe --obd test" && return
+ FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
+ OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
+ FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
+ [ $FOUND -eq $FILENUM ] || \
+ error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
+ [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
+ sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
+ error "lfs getstripe --obd wrong: should not show file on other obd"
+ echo "lfs getstripe --obd passed."
+}
+run_test 56 "check lfs getstripe ===================================="
+
+NUMFILES=3
+NUMDIRS=3
+setup_56() {
+ LOCAL_NUMFILES=$1
+ LOCAL_NUMDIRS=$2
+ if [ ! -d "$DIR/${tdir}g" ] ; then
+ mkdir -p $DIR/${tdir}g
+ for i in `seq 1 $LOCAL_NUMFILES` ; do
+ touch $DIR/${tdir}g/file$i
+ done
+ for i in `seq 1 $LOCAL_NUMDIRS` ; do
+ mkdir $DIR/${tdir}g/dir$i
+ for j in `seq 1 $LOCAL_NUMFILES` ; do
+ touch $DIR/${tdir}g/dir$i/file$j
+ done
+ done
+ fi
+}
+
+test_56g() {
+ $LSTRIPE -d $DIR
+
+ setup_56 $NUMFILES $NUMDIRS
+
+ EXPECTED=$(($NUMDIRS + 2))
+ # test lfs find with -name
+ for i in `seq 1 $NUMFILES` ; do
+ NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
+ [ $NUMS -eq $EXPECTED ] || error \
+ "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+ done
+ echo "lfs find -name passed."
+}
+run_test 56g "check lfs find -name ============================="
+
+test_56h() {
+ $LSTRIPE -d $DIR
+
+ setup_56 $NUMFILES $NUMDIRS
+
+ EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
+ # test lfs find with ! -name
+ for i in `seq 1 $NUMFILES` ; do
+ NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
+ [ $NUMS -eq $EXPECTED ] || error \
+ "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+ done
+ echo "lfs find ! -name passed."
+}
+run_test 56h "check lfs find ! -name ============================="
+
+test_57a() {
+ # note test will not do anything if MDS is not local
+ [ -z "$MDS" ] && skip "skipping test for remote MDS" && return
+ for DEV in `cat $LPROC/mds/*/mntdev`; do
+ dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
+ DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
+ [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
+ rm $TMP/t57a.dump
+ done
+}
+run_test 57a "verify MDS filesystem created with large inodes =="
+
+test_57b() {
+ FILECOUNT=100
+ FILE1=$DIR/d57b/f1
+ FILEN=$DIR/d57b/f$FILECOUNT
+ rm -rf $DIR/d57b || error "removing $DIR/d57b"
+ mkdir -p $DIR/d57b || error "creating $DIR/d57b"
+ echo "mcreating $FILECOUNT files"
+ createmany -m $DIR/d57b/f 1 $FILECOUNT || \
+ error "creating files in $DIR/d57b"
+
+ # verify that files do not have EAs yet
+ $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
+ $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
+
+ MDSFREE="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
+ MDCFREE="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
+ echo "opening files to create objects/EAs"
+ for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
+ $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
+ done
+
+ # verify that files have EAs now
+ $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
+ $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
+
+ sleep 1 # make sure we get new statfs data
+# MDSFREE2="`cat $LPROC/mds/*/kbytesfree`"
+# MDCFREE2="`cat $LPROC/mdc/*/kbytesfree`"
+# if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
+# if [ "$MDSFREE" != "$MDSFREE2" ]; then
+# error "MDC before $MDCFREE != after $MDCFREE2"
+# else
+# echo "MDC before $MDCFREE != after $MDCFREE2"
+# echo "unable to confirm if MDS has large inodes"
+# fi
+# fi
+ rm -rf $DIR/d57b
+}
+run_test 57b "default LOV EAs are stored inside large inodes ==="
+
+test_58() {
+ [ -z "$(which wiretest 2>/dev/null)" ] && skip "could not find wiretest" && return
+ wiretest
+}
+run_test 58 "verify cross-platform wire constants =============="
+
+test_59() {
+ echo "touch 130 files"
+ createmany -o $DIR/f59- 130
+ echo "rm 130 files"
+ unlinkmany $DIR/f59- 130
+ sync
+ sleep 2
+ # wait for commitment of removal
+}
+run_test 59 "verify cancellation of llog records async ========="
+
+TEST60_HEAD="test_60 run $RANDOM"
+test_60a() {
+ [ ! -f run-llog.sh ] && skip "missing subtest run-llog.sh" && return
+ log "$TEST60_HEAD - from kernel mode"
+# sh run-llog.sh
+}
+run_test 60a "llog sanity tests run from kernel module =========="
+
+test_60b() { # bug 6411
+ dmesg > $DIR/$tfile
+ LLOG_COUNT=`dmesg | grep -A 1000 "$TEST60_HEAD" | grep -c llog_test`
+ [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
+}
+run_test 60b "limit repeated messages from CERROR/CWARN ========"
+
+test_60c() {
+ echo "create 5000 files"
+ createmany -o $DIR/f60c- 5000
+#define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x13c
+ sysctl -w lustre.fail_loc=0x8000013c
+ unlinkmany $DIR/f60c- 5000
+ sysctl -w lustre.fail_loc=0
+}
+run_test 60c "unlink file when mds full"
+
+test_61() {
+ f="$DIR/f61"
+ dd if=/dev/zero of=$f bs=`page_size` count=1
+ cancel_lru_locks osc
+ multiop $f OSMWUc || error
+ sync
+}
+run_test 61 "mmap() writes don't make sync hang ================"
+
+# bug 2330 - insufficient obd_match error checking causes LBUG
+test_62() {
+ f="$DIR/f62"
+ echo foo > $f
+ cancel_lru_locks osc
+ sysctl -w lustre.fail_loc=0x405
+ cat $f && error "cat succeeded, expect -EIO"
+ sysctl -w lustre.fail_loc=0
+}
+run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
+
+# bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
+test_63() {
+ MAX_DIRTY_MB=`cat $LPROC/osc/*/max_dirty_mb | head -n 1`
+ for i in $LPROC/osc/*/max_dirty_mb ; do
+ echo 0 > $i
+ done
+ for i in `seq 10` ; do
+ dd if=/dev/zero of=$DIR/f63 bs=8k &
+ sleep 5
+ kill $!
+ sleep 1
+ done
+
+ for i in $LPROC/osc/*/max_dirty_mb ; do
+ echo $MAX_DIRTY_MB > $i
+ done
+ rm -f $DIR/f63 || true
+}
+run_test 63 "Verify oig_wait interruption does not crash ======="
+
+# bug 2248 - async write errors didn't return to application on sync
+# bug 3677 - async write errors left page locked
+test_63b() {
+ DBG_SAVE="`sysctl -n lnet.debug`"
+ sysctl -w lnet.debug=-1
+
+ # ensure we have a grant to do async writes
+ dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
+ rm $DIR/$tfile
+
+ #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
+ sysctl -w lustre.fail_loc=0x80000406
+ multiop $DIR/$tfile Owy && \
+ $LCTL dk /tmp/test63b.debug && \
+ sysctl -w lnet.debug="$DBG_SAVE" && \
+ error "sync didn't return ENOMEM"
+ sync; sleep 2; sync # do a real sync this time to flush page
+ grep locked $LPROC/llite/*/dump_page_cache && \
+ $LCTL dk /tmp/test63b.debug && \
+ sysctl -w lnet.debug="$DBG_SAVE" && \
+ error "locked page left in cache after async error" || true
+ sysctl -w lnet.debug="$DBG_SAVE"
+}
+run_test 63b "async write errors should be returned to fsync ==="
+
+test_64a () {
+ df $DIR
+ grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur*
+}
+run_test 64a "verify filter grant calculations (in kernel) ====="
+
+test_64b () {
+ [ ! -f oos.sh ] && skip "missing subtest oos.sh" && return
+ sh oos.sh $MOUNT
+}
+run_test 64b "check out-of-space detection on client ==========="
+
+# bug 1414 - set/get directories' stripe info
+test_65a() {
+ mkdir -p $DIR/d65
+ touch $DIR/d65/f1
+ $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
+}
+run_test 65a "directory with no stripe info ===================="
+
+test_65b() {
+ mkdir -p $DIR/d65
+ $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
+ touch $DIR/d65/f2
+ $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
+}
+run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
+
+test_65c() {
+ if [ $OSTCOUNT -gt 1 ]; then
+ mkdir -p $DIR/d65
+ $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
+ $(($OSTCOUNT - 1)) || error "setstripe"
+ touch $DIR/d65/f3
+ $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
+ fi
+}
+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
+ $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 =============="
+
+test_65e() {
+ mkdir -p $DIR/d65
+
+ $SETSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
+ $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || error "no stripe info failed"
+ touch $DIR/d65/f6
+ $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
+}
+run_test 65e "directory setstripe 0 -1 0 ======================="
+
+test_65f() {
+ mkdir -p $DIR/d65f
+ $RUNAS $SETSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
+}
+run_test 65f "dir setstripe permission (should return error) ==="
+
+test_65g() {
+ mkdir -p $DIR/d65
+ $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
+ $SETSTRIPE -d $DIR/d65 || error "setstripe"
+ $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
+ error "delete default stripe failed"
+}
+run_test 65g "directory setstripe -d ==========================="
+
+test_65h() {
+ mkdir -p $DIR/d65
+ $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
+ mkdir -p $DIR/d65/dd1
+ [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
+ "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
+}
+run_test 65h "directory stripe info inherit ===================="
+
+test_65i() { # bug6367
+ $SETSTRIPE $MOUNT 65536 -1 -1
+}
+run_test 65i "set non-default striping on root directory (bug 6367)="
+
+test_65j() { # bug6367
+ # if we aren't already remounting for each test, do so for this test
+ if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
+ cleanup -f || error "failed to unmount"
+ setup
+ fi
+ $SETSTRIPE -d $MOUNT
+}
+run_test 65j "set default striping on root directory (bug 6367)="
+
+test_65k() { # bug11679
+ [ "$OSTCOUNT" -lt 2 ] && skip "too few OSTs" && return
+
+ echo "Check OST status: "
+ MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
+ for OSC in $MDS_OSCS; do
+ echo $OSC "is activate"
+ do_facet mds lctl --device %$OSC activate
+ done
+ mkdir -p $DIR/$tdir
+ for INACTIVE_OSC in $MDS_OSCS; do
+ echo $INACTIVE_OSC "is Deactivate:"
+ do_facet mds lctl --device %$INACTIVE_OSC deactivate
+ for STRIPE_OSC in $MDS_OSCS; do
+ STRIPE_OST=`osc_to_ost $STRIPE_OSC`
+ STRIPE_INDEX=`do_facet mds cat $LPROC/lov/*md*/target_obd |
+ grep $STRIPE_OST | awk -F: '{print $1}'`
+ echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1"
+ do_facet mds $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1
+ RC=$?
+ [ $RC -ne 0 ] && error "setstripe should have succeeded"
+ done
+ rm -f $DIR/$tdir/*
+ echo $INACTIVE_OSC "is Activate."
+ do_facet mds lctl --device %$INACTIVE_OSC activate
+ done
+}
+run_test 65k "validate manual striping works properly with deactivated OSCs"
+
+# bug 2543 - update blocks count on client
+test_66() {
+ COUNT=${COUNT:-8}
+ dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
+ sync; sleep 1; sync
+ BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
+ [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
+}
+run_test 66 "update inode blocks count on client ==============="
+
+test_67() {
+ [ ! -f sanity-sec.sh ] && skip "missing subtest sanity-sec.sh" && return
+ sh sanity-sec.sh
+}
+run_test 67 "security test ====================================="
+
+cleanup_68() {
+ trap 0
+ if [ "$LOOPDEV" ]; then
+ swapoff $LOOPDEV || error "swapoff failed"
+ losetup -d $LOOPDEV || error "losetup -d failed"
+ unset LOOPDEV LOOPNUM
+ fi
+ rm -f $DIR/f68
+}
+
+meminfo() {
+ awk '($1 == "'$1':") { print $2 }' /proc/meminfo
+}
+
+swap_used() {
+ 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() {
+ [ "$UID" != 0 ] && skip "must run as root" && return
+ grep -q obdfilter $LPROC/devices && \
+ skip "local OST" && return
+
+ find_loop_dev
+ dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
+
+ trap cleanup_68 EXIT
+
+ losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
+ mkswap $LOOPDEV
+ swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV 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`
+
+ cleanup_68
+
+ [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
+}
+run_test 68 "support swapping to Lustre ========================"
+
+# bug5265, obdfilter oa2dentry return -ENOENT
+# #define OBD_FAIL_OST_ENOENT 0x217
+test_69() {
+ [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+ skip "skipping test for remote OST" && return
+ [ ! -z "$USING_KRB5" ] && \
+ skip "gss with bulk security will triger oops. re-enable this after b10091 get fixed" && return
+
+ f="$DIR/$tfile"
+ touch $f
+
+ if ! $DIRECTIO write ${f}.2 0 1; then
+ skip "O_DIRECT not implemented"
+ return 0
+ fi
+
+ sysctl -w lustre.fail_loc=0x217
+ truncate $f 1 # vmtruncate() will ignore truncate() error.
+ $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
+
+ sysctl -w lustre.fail_loc=0
+ $DIRECTIO write $f 0 2 || error "write error"
+
+ cancel_lru_locks osc
+ $DIRECTIO read $f 0 1 || error "read error"
+
+ sysctl -w lustre.fail_loc=0x217
+ $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
+
+ sysctl -w lustre.fail_loc=0
+ rm -f $f
+}
+run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
+
+test_71() {
+ which dbench > /dev/null 2>&1 || skip "dbench not installed, skip this test" && return 0
+ DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
+ PATH=${DBENCH_LIB}:${PATH}
+ cp `which dbench` $DIR
+
+ TGT=$DIR/client.txt
+ SRC=${SRC:-$DBENCH_LIB/client.txt}
+ [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
+ SRC=$DBENCH_LIB/client_plain.txt
+ [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
+
+ echo "copying necessary lib to $DIR"
+ [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
+ mkdir -p $DIR$LIB71 || error "can't create $DIR$LIB71"
+ cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
+ cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
+
+ echo "chroot $DIR /dbench -c client.txt 2"
+ chroot $DIR /dbench -c client.txt 2
+ RC=$?
+
+ rm -rf $DIR/dbench $TGT $DIR$LIB71
+
+ return $RC
+}
+run_test 71 "Running dbench on lustre (don't segment fault) ===="
+
+test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
+ check_kernel_version 43 || return 0
+ [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
+ # We had better clear the $DIR to get enough space for dd
+ rm -rf $DIR/*
+ touch $DIR/f72
+ chmod 777 $DIR/f72
+ chmod ug+s $DIR/f72
+ $RUNAS -u $(($RUNAS_ID + 1)) dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
+ # See if we are still setuid/sgid
+ test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
+ # Now test that MDS is updated too
+ cancel_lru_locks mdc
+ test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
+ true
+}
+run_test 72 "Test that remove suid works properly (bug5695) ===="
+
+# bug 3462 - multiple simultaneous MDC requests
+test_73() {
+ mkdir $DIR/d73-1
+ mkdir $DIR/d73-2
+ multiop $DIR/d73-1/f73-1 O_c &
+ pid1=$!
+ #give multiop a chance to open
+ usleep 500
+
+ echo 0x80000129 > /proc/sys/lustre/fail_loc
+ multiop $DIR/d73-1/f73-2 Oc &
+ sleep 1
+ echo 0 > /proc/sys/lustre/fail_loc
+
+ multiop $DIR/d73-2/f73-3 Oc &
+ pid3=$!
+
+ kill -USR1 $pid1
+ wait $pid1 || return 1
+
+ sleep 25
+
+ $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
+ $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
+ $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
+
+ rm -rf $DIR/d73-*
+}
+run_test 73 "multiple MDC requests (should not deadlock)"
+
+test_74() { # bug 6149, 6184
+ #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
+ #
+ # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
+ # will spin in a tight reconnection loop
+ sysctl -w lustre.fail_loc=0x8000030e
+ # get any lock
+ touch $DIR/f74
+ sysctl -w lustre.fail_loc=0
+ true
+}
+run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
+
+JOIN=${JOIN:-"lfs join"}
+F75=$DIR/f75
+F128k=${F75}_128k
+FHEAD=${F75}_head
+FTAIL=${F75}_tail
+export T75_PREP=no
+test75_prep() {
+ [ $T75_PREP = "yes" ] && return
+ echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
+
+ dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
+ log "finished dd"
+ chmod 777 ${F128k}
+ T75_PREP=yes
+}
+
+test_75a() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ cp -p ${F128k} ${FHEAD}
+ log "finished cp to $FHEAD"
+ cp -p ${F128k} ${FTAIL}
+ log "finished cp to $FTAIL"
+ cat ${F128k} ${F128k} > ${F75}_sim_sim
+
+ $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
+ log "finished join $FHEAD to ${F75}_sim_sim"
+ cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
+ log "finished cmp $FHEAD to ${F75}_sim_sim"
+ $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
+}
+run_test 75a "TEST join file ===================================="
+
+test_75b() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ cp -p ${F128k} ${FTAIL}
+ cat ${F75}_sim_sim >> ${F75}_join_sim
+ cat ${F128k} >> ${F75}_join_sim
+ $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
+ cmp ${FHEAD} ${F75}_join_sim || \
+ error "${FHEAD} ${F75}_join_sim are different"
+ $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
+}
+run_test 75b "TEST join file 2 =================================="
+
+test_75c() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ cp -p ${F128k} ${FTAIL}
+ cat ${F128k} >> ${F75}_sim_join
+ cat ${F75}_join_sim >> ${F75}_sim_join
+ $JOIN ${FTAIL} ${FHEAD} || error "join error"
+ cmp ${FTAIL} ${F75}_sim_join || \
+ error "${FTAIL} ${F75}_sim_join are different"
+ $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
+}
+run_test 75c "TEST join file 3 =================================="
+
+test_75d() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ cp -p ${F128k} ${FHEAD}
+ cp -p ${F128k} ${FHEAD}_tmp
+ cat ${F75}_sim_sim >> ${F75}_join_join
+ cat ${F75}_sim_join >> ${F75}_join_join
+ $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
+ $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
+ cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
+ $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
+}
+run_test 75d "TEST join file 4 =================================="
+
+test_75e() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ rm -rf ${FHEAD} || "delete join file error"
+}
+run_test 75e "TEST join file 5 (remove joined file) ============="
+
+test_75f() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ test75_prep
+
+ cp -p ${F128k} ${F75}_join_10_compare
+ cp -p ${F128k} ${F75}_join_10
+ for ((i = 0; i < 10; i++)); do
+ cat ${F128k} >> ${F75}_join_10_compare
+ cp -p ${F128k} ${FTAIL}
+ $JOIN ${F75}_join_10 ${FTAIL} || \
+ error "join ${F75}_join_10 ${FTAIL} error"
+ $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
+ done
+ cmp ${F75}_join_10 ${F75}_join_10_compare || \
+ error "files ${F75}_join_10 ${F75}_join_10_compare differ"
+}
+run_test 75f "TEST join file 6 (join 10 files) =================="
+
+test_75g() {
+# skipped temporarily: we do not have join file currently
+# please remove this when ready - huanghua
+ return
+ [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
+ $LFS getstripe ${F75}_join_10
+
+ $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
+
+ ls -l $F75*
+}
+run_test 75g "TEST join file 7 (open unlink) ===================="
+
+num_inodes() {
+ awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
+}
+
+test_76() { # bug 1443
+ DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
+ [ $DETH -eq 0 ] && skip "No _iget." && return 0
+ BEFORE_INODES=`num_inodes`
+ echo "before inodes: $BEFORE_INODES"
+ for i in `seq 1000`; do
+ touch $DIR/$tfile
+ rm -f $DIR/$tfile
+ done
+ AFTER_INODES=`num_inodes`
+ echo "after inodes: $AFTER_INODES"
+ [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
+ error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
+ true
+}
+run_test 76 "destroy duplicate inodes in client inode cache ===="
+
+export ORIG_CSUM=""
+set_checksums()
+{
+ [ "$ORIG_CSUM" ]||ORIG_CSUM=`cat $LPROC/llite/*/checksum_pages|head -n1`
+ for f in $LPROC/llite/*/checksum_pages; do
+ echo $1 >> $f
+ done
+
+ return 0
+}
+
+F77_TMP=$TMP/f77-temp
+F77SZ=8
+setup_f77() {
+ dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
+ error "error writing to $F77_TMP"
+}
+
+test_77a() { # bug 10889
+ [ ! -f $F77_TMP ] && setup_f77
+ set_checksums 1
+ dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
+ set_checksums 0
+}
+run_test 77a "normal checksum read/write operation ============="
+
+test_77b() { # bug 10889
+ [ ! -f $F77_TMP ] && setup_f77
+ #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
+ sysctl -w lustre.fail_loc=0x80000409
+ set_checksums 1
+ dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
+ error "dd error: $?"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77b "checksum error on client write ===================="
+
+test_77c() { # bug 10889
+ [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
+ cancel_lru_locks osc
+ #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
+ sysctl -w lustre.fail_loc=0x80000408
+ set_checksums 1
+ cmp $F77_TMP $DIR/f77b || error "file compare failed"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77c "checksum error on client read ==================="
+
+test_77d() { # bug 10889
+ #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
+ sysctl -w lustre.fail_loc=0x80000409
+ set_checksums 1
+ directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
+ error "direct write: rc=$?"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77d "checksum error on OST direct write ==============="
+
+test_77e() { # bug 10889
+ [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
+ #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
+ sysctl -w lustre.fail_loc=0x80000408
+ set_checksums 1
+ cancel_lru_locks osc
+ directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
+ error "direct read: rc=$?"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77e "checksum error on OST direct read ================"
+
+test_77f() { # bug 10889
+ #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
+ sysctl -w lustre.fail_loc=0x409
+ set_checksums 1
+ directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
+ error "direct write succeeded"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77f "repeat checksum error on write (expect error) ===="
+
+test_77g() { # bug 10889
+ [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+ skip "remote OST" && return
+ [ ! -f $F77_TMP ] && setup_f77
+ #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
+ sysctl -w lustre.fail_loc=0x8000021a
+ set_checksums 1
+ dd if=$F77_TMP of=$DIR/f77 bs=1M count=$F77SZ || \
+ error "write error: rc=$?"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77g "checksum error on OST write ======================"
+
+test_77h() { # bug 10889
+ [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+ skip "remote OST" && return
+ [ ! -f $DIR/f77 ] && skip "requires 77g - skipping" && return
+ cancel_lru_locks osc
+ #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
+ sysctl -w lustre.fail_loc=0x8000021b
+ set_checksums 1
+ cmp $F77_TMP $DIR/f77 || error "file compare failed"
+ sysctl -w lustre.fail_loc=0
+ set_checksums 0
+}
+run_test 77h "checksum error on OST read ======================="
+
+[ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
+rm -f $F77_TMP
+unset F77_TMP
+
+test_78() { # bug 10901
+ NSEQ=5
+ F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
+ [ $F78SIZE -gt 512 ] && F78SIZE=512
+ [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
+ SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
+ [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024)) ] && \
+ F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024))
+ $SETSTRIPE $DIR/$tfile 0 -1 -1 || error "setstripe failed"
+ for i in `seq 1 $NSEQ`
+ do
+ echo directIO rdwr round $i of $NSEQ
+ $DIRECTIO rdwr $DIR/$tfile 0 $F78SIZE 1048576 || error "rdwr failed"
+ done
+
+ rm -f $DIR/$tfile
+}
+run_test 78 "handle large O_DIRECT writes correctly ============"
+
+# on the LLNL clusters, runas will still pick up root's $TMP settings,
+# which will not be writable for the runas user, and then you get a CVS
+# error message with a corrupt path string (CVS bug) and panic.
+# We're not using much space, so just stick it in /tmp, which is safe.
+OLDTMPDIR=$TMPDIR
+OLDTMP=$TMP
+TMPDIR=/tmp
+TMP=/tmp
+OLDHOME=$HOME
+[ $RUNAS_ID -ne $UID ] && HOME=/tmp
+
+test_99a() {
+ mkdir -p $DIR/d99cvsroot
+ chown $RUNAS_ID $DIR/d99cvsroot
+ $RUNAS cvs -d $DIR/d99cvsroot init || error
+}
+run_test 99a "cvs init ========================================="
+
+test_99b() {
+ [ ! -d $DIR/d99cvsroot ] && test_99a
+ cd /etc/init.d
+ # some versions of cvs import exit(1) when asked to import links or
+ # files they can't read. ignore those files.
+ TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
+ ! -perm +4 -printf '-I %f\n')
+ $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
+ d99reposname vtag rtag
+}
+run_test 99b "cvs import ======================================="
+
+test_99c() {
+ [ ! -d $DIR/d99cvsroot ] && test_99b
+ cd $DIR
+ mkdir -p $DIR/d99reposname
+ chown $RUNAS_ID $DIR/d99reposname
+ $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
+}
+run_test 99c "cvs checkout ====================================="
+
+test_99d() {
+ [ ! -d $DIR/d99cvsroot ] && test_99c
+ cd $DIR/d99reposname
+ $RUNAS touch foo99
+ $RUNAS cvs add -m 'addmsg' foo99
+}
+run_test 99d "cvs add =========================================="
+
+test_99e() {
+ [ ! -d $DIR/d99cvsroot ] && test_99c
+ cd $DIR/d99reposname
+ $RUNAS cvs update
+}
+run_test 99e "cvs update ======================================="
+
+test_99f() {
+ [ ! -d $DIR/d99cvsroot ] && test_99d
+ cd $DIR/d99reposname
+ $RUNAS cvs commit -m 'nomsg' foo99
+}
+run_test 99f "cvs commit ======================================="
+
+test_100() {
+ 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 $STRIPE_SIZE $STRIPE_OFFSET $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 $stripe_size $offset $count
+ done
+ done
+ done
+
+ cd ..
+ 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 65536 1 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 trusted.lov xattr
+ echo "get/set/list trusted.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"
+
+ local testfile2=${testfile}2
+ local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
+ grep "trusted.lov" |sed -e 's/[^=]\+=//' `
+
+ $RUNAS $MCREATE $testfile2
+ $RUNAS setfattr -n trusted.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 trusted.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
+ 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/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
+ 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/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
+ 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/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()
+{
+ $SAVE_PWD/acl/run $SAVE_PWD/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
+ [ ! -z "$USING_KRB5" ] && skip "could not run under gss" && return
+
+ 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
+# XXX add back permission test when we support supplementary groups.
+# 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 $SAVE_PWD/acl/make-tree . || error
+ chmod +x make-tree || error
+ run_acl_subtest inheritance || error
+ rm -f make-tree
+
+ cd $SAVE_PWD
+ umask $SAVE_UMASK
+}
+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
+ mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+ $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 () {
+ 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
+ [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
+ skip "remote MDS, skipping test" && 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} 0 $MINI 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 0 -1 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=$($LFS 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=$($LFS 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 =========="
+
+test_118() #bug 11710
+{
+ sync; sleep 1; sync
+ multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c;
+ dirty=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+
+ return $dirty
+}
+run_test 118 "verify O_SYNC work"
+
+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
+
+ lfs setstripe $DIR/$tfile 0 -1 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"
+}
+run_test 119b "Sparse directIO read must return actual read amount"
+
+test_119a() {
+ mkdir $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`
+ 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."
+}
+run_test 119a "Early Lock Cancel: mkdir test"
+
+test_119b() {
+ mkdir $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`
+ 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."
+}
+run_test 119b "Early Lock Cancel: create test"
+
+test_119c() {
+ 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."
+}
+run_test 119c "Early Lock Cancel: link test"
+
+test_119d() {
+ 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."
+}
+run_test 119d "Early Lock Cancel: setattr test"
+
+test_119e() {
+ mkdir $DIR/$tdir
+ 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."
+}
+run_test 119e "Early Lock Cancel: unlink test"
+
+test_119f() {
+ 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."
+}
+run_test 119f "Early Lock Cancel: rename test"
+
+test_119g() {
+ count=10000
+ echo create $count files
+ mkdir $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
+}
+run_test 119g "Early Lock Cancel: performance test"
+
+TMPDIR=$OLDTMPDIR
+TMP=$OLDTMP
+HOME=$OLDHOME
+
+log "cleanup: ======================================================"
+if [ "`mount | grep $MOUNT`" ]; then
+ rm -rf $DIR/[Rdfs][1-9]*
+fi
+if [ "$I_MOUNTED" = "yes" ]; then
+ cleanupall -f || error "cleanup failed"
+fi