Whamcloud - gitweb
b=11694
[fs/lustre-release.git] / lustre / tests / sanity.sh
index f94a301..bae0863 100644 (file)
@@ -13,7 +13,7 @@ ALWAYS_EXCEPT="                 27o 27q  42a  42b  42c  42d  45   74b   75 $SANI
 #ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 24o 27m 36f 36g 51b 51c 63 64b 68 71 73 101 115"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 78 101 103 115 120g"
 
 # Tests that fail on uml
 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
@@ -143,6 +143,8 @@ MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
 rm -rf $DIR/[Rdfs][1-9]*
 
+check_runas_id $RUNAS_ID $RUNAS
+
 build_test_filter
 
 if [ "${ONLY}" = "MOUNT" ] ; then 
@@ -528,7 +530,6 @@ run_test 21 "write to dangling link ============================"
 
 test_22() {
        WDIR=$DIR/$tdir
-       mkdir $WDIR
        chown $RUNAS_ID $WDIR
        (cd $WDIR || error "cd $WDIR failed";
        $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
@@ -796,15 +797,15 @@ run_test 26e "unlink multiple component recursive symlink ======"
 
 # recursive symlinks (bug 7022)
 test_26f() {
-       mkdir $DIR/$tfile        || error "mkdir $DIR/$tfile failed"
-       cd $DIR/$tfile           || error "cd $DIR/$tfile failed"
-       mkdir -p $tdir/bar1      || error "mkdir $tdir/bar1 failed"
+       mkdir $DIR/$tdir/$tfile        || error "mkdir $DIR/$tdir/$tfile failed"
+       cd $DIR/$tdir/$tfile           || error "cd $DIR/$tdir/$tfile failed"
+       mkdir -p lndir/bar1      || error "mkdir lndir/bar1 failed"
        mkdir $tfile             || error "mkdir $tfile failed"
        cd $tfile                || error "cd $tfile failed"
        ln -s .. dotdot          || error "ln dotdot failed"
-       ln -s dotdot/$tdir $tdir || error "ln $tdir failed"
-       cd ../..                 || error "cd ../.. failed"
-       output=`ls $tfile/$tfile/$tdir/bar1`
+       ln -s dotdot/lndir lndir || error "ln lndir failed"
+       cd $DIR/$tdir                 || error "cd $DIR/$tdir failed"
+       output=`ls $tfile/$tfile/lndir/bar1`
        [ "$output" = bar1 ] && error "unexpected output"
        rm -r $tfile             || error "rm $tfile failed"
        $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
@@ -814,7 +815,7 @@ run_test 26f "rm -r of a directory which has recursive symlink ="
 test_27a() {
        echo '== stripe sanity =============================================='
        mkdir -p $DIR/d27 || error "mkdir failed"
-       $SETSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
+       $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
        $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
        pass
        log "== test_27a: write to one stripe file ========================="
@@ -825,7 +826,7 @@ run_test 27a "one stripe file =================================="
 test_27c() {
        [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        mkdir -p $DIR/d27
-       $SETSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
+       $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
        [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
                error "two-stripe file doesn't have two stripes"
        pass
@@ -844,15 +845,15 @@ run_test 27d "create file with default settings ================"
 
 test_27e() {
        mkdir -p $DIR/d27
-       $SETSTRIPE $DIR/d27/f12 65536 0 2 || error "lstripe failed"
-       $SETSTRIPE $DIR/d27/f12 65536 0 2 && error "lstripe succeeded twice"
+       $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
+       $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
        $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
 }
 run_test 27e "lstripe existing file (should return error) ======"
 
 test_27f() {
        mkdir -p $DIR/d27
-       $SETSTRIPE $DIR/d27/fbad 100 0 1 && error "lstripe failed"
+       $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
        dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
        $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
 }
@@ -873,7 +874,7 @@ run_test 27g "test lfs getstripe ==========================================="
 
 test_27j() {
        mkdir -p $DIR/d27
-       $SETSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error "lstripe failed"||true
+       $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
 }
 run_test 27j "lstripe with bad stripe offset (should return error)"
 
@@ -882,7 +883,7 @@ test_27k() { # bug 2844
        FILE=$DIR/d27/f27k
        LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
        [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
-       $SETSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
+       $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
        BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
        [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
        dd if=/dev/zero of=$FILE bs=4k count=1
@@ -894,7 +895,7 @@ run_test 27k "limit i_blksize for broken user apps ============="
 test_27l() {
        mkdir -p $DIR/d27
        mcreate $DIR/f27l || error "creating file"
-       $RUNAS $SETSTRIPE $DIR/f27l 65536 -1 1 && \
+       $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
                error "lstripe should have failed" || true
 }
 run_test 27l "check setstripe permissions (should return error)"
@@ -906,11 +907,11 @@ test_27m() {
                return
        fi
        mkdir -p $DIR/d27
-       $SETSTRIPE $DIR/d27/f27m_1 0 0 1
+       $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
        dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
                error "dd should fill OST0"
        i=2
-       while $SETSTRIPE $DIR/d27/f27m_$i 0 0 1 ; do
+       while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
                i=`expr $i + 1`
                [ $i -gt 256 ] && break
        done
@@ -945,7 +946,7 @@ exhaust_precreations() {
        next_id=$(cat $LPROC/osc/${OSC}/prealloc_next_id)
 
         mkdir -p $DIR/d27/${OST}
-       $SETSTRIPE $DIR/d27/${OST} 0 $OSTIDX 1
+       $SETSTRIPE $DIR/d27/${OST} -i $OSTIDX -c 1
 #define OBD_FAIL_OST_ENOSPC              0x215
        sysctl -w lustre.fail_loc=0x215
        echo "Creating to objid $last_id on ost $OST..."
@@ -1039,7 +1040,7 @@ test_27r() {
        rm -f $DIR/d27/f27r
        exhaust_precreations 0 0x80000215
 
-       $SETSTRIPE $DIR/d27/f27r 0 0 2 # && error
+       $SETSTRIPE $DIR/d27/f27r -i 0 -c 2 # && error
 
        reset_enospc
 }
@@ -1073,11 +1074,12 @@ test_27u() { # bug 4900
         createmany -o $DIR/d27u/t- 1000
         sysctl -w lustre.fail_loc=0
 
-        $LFS getstripe $DIR/d27u > $TMP/files
-        OBJS=`cat $TMP/files | awk -vobjs=0 '($1 == 0) { objs += 1 } END { print objs;}'`
+        TLOG=$DIR/$tfile.getstripe
+        $GETSTRIPE $DIR/d27u > $TLOG 
+        OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
         unlinkmany $DIR/d27u/t- 1000
         [ $OBJS -gt 0 ] && \
-                error "Found $OBJS objects were created on OST-0" || pass
+                error "$OBJS objects created on OST-0.  See $TLOG" || pass
 }
 run_test 27u "skip object creation on OSC w/o objects =========="
 
@@ -1088,7 +1090,7 @@ test_27v() { # bug 4900
         exhaust_all_precreations
 
         mkdir -p $DIR/$tdir
-        lfs setstripe $DIR/$tdir 0 -1 1         # 1 stripe / file
+        $SETSTRIPE $DIR/$tdir -c 1         # 1 stripe / file
 
         touch $DIR/$tdir/$tfile
         #define OBD_FAIL_TGT_DELAY_PRECREATE     0x705
@@ -1211,10 +1213,10 @@ run_test 31e "remove of open non-empty directory ==============="
 test_31f() { # bug 4554
        set -vx
        mkdir $DIR/d31f
-       lfs setstripe $DIR/d31f 1048576 -1 1
+       $SETSTRIPE $DIR/d31f -s 1048576 -c 1
        cp /etc/hosts $DIR/d31f
        ls -l $DIR/d31f
-       lfs getstripe $DIR/d31f/hosts
+       $GETSTRIPE $DIR/d31f/hosts
        multiop $DIR/d31f D_c &
        MULTIPID=$!
 
@@ -1222,10 +1224,10 @@ test_31f() { # bug 4554
 
        rm -rv $DIR/d31f || error "first of $DIR/d31f"
        mkdir $DIR/d31f
-       lfs setstripe $DIR/d31f 1048576 -1 1
+       $SETSTRIPE $DIR/d31f -s 1048576 -c 1
        cp /etc/hosts $DIR/d31f
        ls -l $DIR/d31f
-       lfs getstripe $DIR/d31f/hosts
+        $DIR/d31f/hosts
        multiop $DIR/d31f D_c &
        MULTIPID2=$!
 
@@ -1887,11 +1889,14 @@ test_42d() {
 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
+       multiop $DIR/$tdir/$tfile Ow_c &
+       pid=$!
+       # give multiop a chance to open
+       sleep 1
+
        $DIR/$tdir/$tfile && error || true
-       exec 9<&-
+       kill -USR1 $pid
 }
 run_test 43 "execution of file opened for write should return -ETXTBSY"
 
@@ -2343,7 +2348,7 @@ test_54e() {
        check_kernel_version 46 || return 0
        f="$DIR/f54e"
        string="aaaaaa"
-       mknod $f c 5 0
+       cp -aL /dev/console $f
        echo $string > $f || error
 }
 run_test 54e "console/tty device works in lustre ======================"
@@ -2444,6 +2449,25 @@ setup_56() {
         fi
 }
 
+setup_56_special() {
+       LOCAL_NUMFILES=$1
+       LOCAL_NUMDIRS=$2
+       TDIR=$DIR/${tdir}g
+       setup_56 $1 $2
+       if [ ! -e "$TDIR/loop1b" ] ; then
+               for i in `seq 1 $LOCAL_NUMFILES` ; do
+                       mknod $TDIR/loop${i}b b 7 $i
+                       mknod $TDIR/null${i}c c 1 3
+                       ln -s $TDIR/file1 $TDIR/link${i}l
+               done
+               for i in `seq 1 $LOCAL_NUMDIRS` ; do
+                       mknod $TDIR/dir$i/loop${i}b b 7 $i
+                       mknod $TDIR/dir$i/null${i}c c 1 3
+                       ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
+               done
+       fi
+}
+
 test_56g() {
         $LSTRIPE -d $DIR
 
@@ -2485,6 +2509,73 @@ test_56i() {
 }
 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
 
+test_56j() {
+       setup_56_special $NUMFILES $NUMDIRS
+
+       EXPECTED=$((NUMDIRS+1))
+       NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56j "check lfs find -type d ============================="
+
+test_56k() {
+       setup_56_special $NUMFILES $NUMDIRS
+
+       EXPECTED=$(((NUMDIRS+1) * NUMFILES))
+       NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56k "check lfs find -type f ============================="
+
+test_56l() {
+       setup_56_special $NUMFILES $NUMDIRS
+
+       EXPECTED=$((NUMDIRS + NUMFILES))
+       NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56l "check lfs find -type b ============================="
+
+test_56m() {
+       setup_56_special $NUMFILES $NUMDIRS
+
+       EXPECTED=$((NUMDIRS + NUMFILES))
+       NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56m "check lfs find -type c ============================="
+
+test_56n() {
+       setup_56_special $NUMFILES $NUMDIRS
+
+       EXPECTED=$((NUMDIRS + NUMFILES))
+       NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56n "check lfs find -type l ============================="
+
+test_56o() {
+       setup_56 $NUMFILES $NUMDIRS
+       TDIR=$DIR/${tdir}g
+
+       utime $TDIR/file1 > /dev/null || error
+       utime $TDIR/file2 > /dev/null || error
+       utime $TDIR/dir1 > /dev/null || error
+       utime $TDIR/dir2 > /dev/null || error
+       utime $TDIR/dir1/file1 > /dev/null || error
+
+       EXPECTED=5
+       NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
+}
+run_test 56o "check lfs find -mtime for old files =========================="
+
 test_57a() {
        # note test will not do anything if MDS is not local
        remote_mds && skip "remote MDS" && return
@@ -2580,6 +2671,26 @@ test_60c() {
 }
 run_test 60c "unlink file when mds full"
 
+test_60d() {
+       SAVEPRINTK=$(sysctl -n lnet.printk)
+
+       # verify "lctl mark" is even working"
+       MESSAGE="test message ID $RANDOM $$"
+       $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
+       dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
+
+       sysctl -w lnet.printk=0 || error "set lnet.printk failed"
+       sysctl -n lnet.printk | grep emerg || error "lnet.printk dropped emerg"
+
+       MESSAGE="new test message ID $RANDOM $$"
+       # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
+       $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
+       dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
+
+       sysctl -w lnet.printk="$SAVEPRINTK"
+}
+run_test 60d "test printk console message masking"
+
 test_61() {
        f="$DIR/f61"
        dd if=/dev/zero of=$f bs=`page_size` count=1
@@ -2663,7 +2774,7 @@ run_test 65a "directory with no stripe info ===================="
 
 test_65b() {
        mkdir -p $DIR/d65
-       $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
+       $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
        touch $DIR/d65/f2
        $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
 }
@@ -2672,8 +2783,8 @@ 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"
+               $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
+                       -c $(($OSTCOUNT - 1)) || error "setstripe"
                touch $DIR/d65/f3
                $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
        fi
@@ -2690,7 +2801,7 @@ test_65d() {
        else
                sc=$(($STRIPECOUNT - 1))
        fi
-       $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
+       $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
        touch $DIR/d65/f4 $DIR/d65/f5
        $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
 }
@@ -2699,8 +2810,8 @@ run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
 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"
+       $SETSTRIPE $DIR/d65 || error "setstripe"
+        $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
        touch $DIR/d65/f6
        $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
 }
@@ -2708,22 +2819,22 @@ 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
+       $RUNAS $SETSTRIPE $DIR/d65f && 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 $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
         $SETSTRIPE -d $DIR/d65 || error "setstripe"
-        $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
+        $GETSTRIPE -v $DIR/d65 | grep "Default" || \
                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"
+        $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 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"
@@ -2731,7 +2842,7 @@ test_65h() {
 run_test 65h "directory stripe info inherit ===================="
  
 test_65i() { # bug6367
-        $SETSTRIPE $MOUNT 65536 -1 -1
+        $SETSTRIPE $MOUNT -s 65536 -c -1 
 }
 run_test 65i "set non-default striping on root directory (bug 6367)="
 
@@ -2762,8 +2873,8 @@ test_65k() { # bug11679
                         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 client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1
+                        echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
+                        do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
                         RC=$?
                         [ $RC -ne 0 ] && error "setstripe should have succeeded"
                 done
@@ -2776,7 +2887,7 @@ run_test 65k "validate manual striping works properly with deactivated OSCs"
 
 test_65l() { # bug 12836
        mkdir -p $DIR/$tdir/test_dir
-       $LFS setstripe $DIR/$tdir/test_dir 65536 -1 -1
+       $SETSTRIPE $DIR/$tdir/test_dir -c -1
        $LFS find -mtime -1 $DIR/$tdir >/dev/null
 }
 run_test 65l "lfs find on -1 stripe dir ========================"
@@ -2828,6 +2939,9 @@ test_68() {
        grep -q llite_lloop /proc/modules
        [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
 
+       [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
+               skip "can't reliably test swap with TCP" && return
+
        MEMTOTAL=`meminfo MemTotal`
        NR_BLOCKS=$((MEMTOTAL>>8))
        [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
@@ -3141,8 +3255,8 @@ 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
+       [ "$ORIG_CSUM" ] || ORIG_CSUM=`cat $LPROC/osc/*/checksums | head -n1`
+       for f in $LPROC/osc/*/checksums; do
                echo $1 >> $f
        done
 
@@ -3263,7 +3377,7 @@ test_78() { # bug 10901
        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"
+       $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
        for i in `seq 1 $NSEQ`
        do
                echo directIO rdwr round $i of $NSEQ
@@ -3461,7 +3575,7 @@ setup_test102() {
 
        trap cleanup_test102 EXIT
        cd $DIR
-       $SETSTRIPE $tdir $STRIPE_SIZE  $STRIPE_OFFSET $STRIPE_COUNT
+       $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
        cd $DIR/$tdir 
        for num in 1 2 3 4
        do
@@ -3471,12 +3585,12 @@ setup_test102() {
                        do
                                local stripe_size=`expr $STRIPE_SIZE \* $num`
                                local file=file"$num-$offset-$count"
-                               $SETSTRIPE $file $stripe_size  $offset $count
+                               $SETSTRIPE $file -s $stripe_size -i $offset -c $count
                        done
                done
        done
 
-       cd ..
+       cd $DIR
        star -c  f=$TMP/f102.tar $tdir 
        SETUP_TEST102=yes
 }
@@ -3543,7 +3657,7 @@ test_102b() {
        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
+       $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"
 
@@ -3569,7 +3683,7 @@ test_102c() {
        mkdir -p $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
        local testfile=$DIR/$tdir/$tfile
-       $RUNAS $SETSTRIPE $testfile 65536 1 2
+       $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"
 
@@ -3819,7 +3933,6 @@ test_105c() {
 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"
 }
@@ -3891,8 +4004,9 @@ test_115() {
 run_test 115 "verify dynamic thread creation===================="
 
 free_min_max () {
-        AVAIL=($(cat $LPROC/osc/*[oO][sS][cC]-[^M]*/kbytesavail))
-        echo OST kbytes available: ${AVAIL[@]}
+       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
@@ -3925,7 +4039,7 @@ test_116() {
        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
+       $SETSTRIPE $DIR/$tdir/OST${MINI} -i $MINI -c 1
        i=0
        while [ $FILL -gt 0 ]; do
            i=$(($i + 1))
@@ -3954,7 +4068,7 @@ test_116() {
 
        # now fill using QOS
        echo writing a bunch of files to QOS-assigned OSTs
-       $SETSTRIPE $DIR/$tdir 0 -1 1
+       $SETSTRIPE $DIR/$tdir -c 1
        i=0
        while [ $FILL -gt 0 ]; do
            i=$(($i + 1))
@@ -3980,11 +4094,11 @@ test_116() {
        # 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)
+        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=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
+        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"
@@ -4312,7 +4426,8 @@ test_118k()
        mkdir -p $DIR/$tdir
 
         for ((i=0;i<10;i++)); do
-                dd if=/dev/zero of=$DIR/$tdir/$tdir-$i bs=1M count=10 &
+                (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
@@ -4343,7 +4458,7 @@ test_119b() # bug 11737
 {
         [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
 
-        lfs setstripe $DIR/$tfile 0 -1 2
+        $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)) || \
@@ -4424,7 +4539,6 @@ test_120a() {
         [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
                skip "no early lock cancel on server" && return 0
         lru_resize_disable
-        mkdir $DIR/$tdir
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
         can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
@@ -4442,7 +4556,6 @@ test_120b() {
         [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
                skip "no early lock cancel on server" && return 0
         lru_resize_disable
-        mkdir $DIR/$tdir
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
         can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
@@ -4497,7 +4610,6 @@ test_120e() {
         [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
                skip "no early lock cancel on server" && return 0
         lru_resize_disable
-        mkdir $DIR/$tdir
         dd if=/dev/zero of=$DIR/$tdir/f1 count=1
         cancel_lru_locks mdc
         cancel_lru_locks osc
@@ -4582,12 +4694,21 @@ test_121() { #bug #10589
 }
 run_test 121 "read cancel race ========="
 
+cmd_cancel_lru_locks() {
+        NS=$1
+        test "x$NS" = "x" && NS="mdc"
+        for d in `find $LPROC/ldlm/namespaces | grep $NS`; do
+                if test -f $d/lru_size; then
+                        cancel_lru_locks $d
+                fi
+        done
+}
+
 test_124a() {
        [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
                skip "no lru resize on server" && return 0
-        cancel_lru_locks mdc
+        cmd_cancel_lru_locks "mdc"
         lru_resize_enable
-        NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
 
         # we want to test main pool functionality, that is cancel based on SLV
         # this is why shrinkers are disabled
@@ -4597,20 +4718,33 @@ test_124a() {
         NR=2000
         mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
 
-        LRU_SIZE=`cat $NSDIR/lru_size`
-
         # use touch to produce $NR new locks
         log "create $NR files at $DIR/$tdir"
         for ((i=0;i<$NR;i++)); do touch $DIR/$tdir/f$i; done
+        
+        NSDIR=""
+        LRU_SIZE=0
+        for d in `find $LPROC/ldlm/namespaces | grep mdc-`; do
+                if test -f $d/lru_size; then
+                        LRU_SIZE=`cat $d/lru_size`
+                        if test $LRU_SIZE -gt 0; then
+                                log "using $d namespace"
+                                NSDIR=$d
+                                break
+                        fi
+                fi
+        done
 
-        LRU_SIZE_B=`cat $NSDIR/lru_size`
-        if test $LRU_SIZE -ge $LRU_SIZE_B; then
+        if test -z $NSDIR; then
                 skip "No cached locks created!"
-                cat $NSDIR/pool/state
                 return 0
         fi
-        LRU_SIZE_B=$((LRU_SIZE_B-LRU_SIZE))
-        log "created $LRU_SIZE_B lock(s)"
+
+        if test $LRU_SIZE -lt 100; then
+                skip "Not enough cached locks created!"
+                return 0
+        fi
+        log "created $LRU_SIZE lock(s)"
 
         # we want to sleep 30s to not make test too long
         SLEEP=30
@@ -4628,6 +4762,7 @@ test_124a() {
         # Use $LRU_SIZE_B here to take into account real number of locks created
         # in the case of CMD, LRU_SIZE_B != $NR in most of cases
         LVF=$(($MAX_HRS * 60 * 60 * $LIMIT / $SLEEP))
+        LRU_SIZE_B=$LRU_SIZE
         log "make client drop locks $LVF times faster so that ${SLEEP}s is enough to cancel $LRU_SIZE_B lock(s)"
         OLD_LVF=`cat $NSDIR/pool/lock_volume_factor`
         echo "$LVF" > $NSDIR/pool/lock_volume_factor
@@ -4650,39 +4785,82 @@ test_124a() {
 }
 run_test 124a "lru resize ======================================="
 
+set_lru_size() {
+        NS=$1
+        SIZE=$2
+        test "x$NS" = "x" && NS="mdc"
+        test "x$SIZE" = "x" && SIZE="0"
+        test $SIZE -lt 0 && SIZE="0"
+        test $SIZE -gt 0 && ACTION="disabled" || ACTION="enabled"
+        for d in `find $LPROC/ldlm/namespaces | grep $NS`; do
+                if test -f $d/lru_size; then
+                        log "$(basename $d):"
+                        log "  lru resize $ACTION"
+                        log "  lru_size=$SIZE"
+                        echo $SIZE > $d/lru_size
+                fi
+        done
+}
+
+get_lru_size() {
+        NS=$1
+        test "x$NS" = "x" && NS="mdc"
+        for d in `find $LPROC/ldlm/namespaces | grep $NS`; do
+                if test -f $d/lru_size; then
+                        log "$(basename $d):"
+                        log "  lru_size=$(cat $d/lru_size)"
+                fi
+        done
+}
+
 test_124b() {
        [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
                skip "no lru resize on server" && return 0
-        cleanup -f || error "failed to unmount"
-        MOUNTOPT="$MOUNTOPT,nolruresize"
-        setup
 
-        NR=3000
-        mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+        NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
+        LIMIT=`cat $NSDIR/pool/limit`
 
-        createmany -o $DIR/$tdir/f $NR
-        log "doing ls -la $DIR/$tdir 3 times (lru resize disabled)"
+        NR_CPU=$(awk '/processor/' /proc/cpuinfo | wc -l)
+       # 100 locks here is default value for non-shrinkable lru as well
+        # as the order to switch to static lru managing policy
+       # define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
+        LDLM_DEFAULT_LRU_SIZE=$((100 * NR_CPU))
+
+        NR=$((LIMIT-(LIMIT/3)))
+        log "starting lru resize disable cycle"
+        set_lru_size "mdc-" $LDLM_DEFAULT_LRU_SIZE
+
+        mkdir -p $DIR/$tdir/disable_lru_resize || 
+                error "failed to create $DIR/$tdir/disable_lru_resize"
+
+        createmany -o $DIR/$tdir/disable_lru_resize/f $NR
+        log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
         stime=`date +%s`
-        ls -la $DIR/$tdir > /dev/null
-        ls -la $DIR/$tdir > /dev/null
-        ls -la $DIR/$tdir > /dev/null
+        ls -la $DIR/$tdir/disable_lru_resize > /dev/null
+        ls -la $DIR/$tdir/disable_lru_resize > /dev/null
+        ls -la $DIR/$tdir/disable_lru_resize > /dev/null
         etime=`date +%s`
         nolruresize_delta=$((etime-stime))
         log "ls -la time: $nolruresize_delta seconds"
+        get_lru_size "mdc-"
+    
+        log "starting lru resize enable cycle"
+        mkdir -p $DIR/$tdir/enable_lru_resize || 
+                error "failed to create $DIR/$tdir/enable_lru_resize"
 
-        cleanup -f || error "failed to unmount"
-        MOUNTOPT=`echo $MOUNTOPT | sed "s/nolruresize/lruresize/"`
-        setup
+       # 0 locks means here flush lru and switch to lru resize policy 
+        set_lru_size "mdc-" 0
 
-        createmany -o $DIR/$tdir/f $NR
-        log "doing ls -la $DIR/$tdir 3 times (lru resize enabled)"
+        createmany -o $DIR/$tdir/enable_lru_resize/f $NR
+        log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
         stime=`date +%s`
-        ls -la $DIR/$tdir > /dev/null
-        ls -la $DIR/$tdir > /dev/null
-        ls -la $DIR/$tdir > /dev/null
+        ls -la $DIR/$tdir/enable_lru_resize > /dev/null
+        ls -la $DIR/$tdir/enable_lru_resize > /dev/null
+        ls -la $DIR/$tdir/enable_lru_resize > /dev/null
         etime=`date +%s`
         lruresize_delta=$((etime-stime))
         log "ls -la time: $lruresize_delta seconds"
+        get_lru_size "mdc-"
 
         if test $lruresize_delta -gt $nolruresize_delta; then
                 log "ls -la is $((lruresize_delta - $nolruresize_delta))s slower with lru resize enabled"
@@ -4691,20 +4869,27 @@ test_124b() {
         else
                 log "lru resize performs the same with no lru resize"
         fi
-
-        unlinkmany $DIR/$tdir/f $NR
 }
 run_test 124b "lru resize (performance test) ======================="
 
 test_125() { # 13358
        [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && skip "must have acl enabled" && return
        mkdir -p $DIR/d125 || error "mkdir failed"
-       $SETSTRIPE $DIR/d125 65536 -1 -1 || error "setstripe failed"
+       $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
        setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
        ls -ld $DIR/d125 || error "cannot access $DIR/d125"
 }
 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
 
+test_126() { # bug 12829/13455
+       [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
+       $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
+       gid=`ls -n $DIR/$tfile | awk '{print $4}'`
+       rm -f $DIR/$tfile
+       [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
+}
+run_test 126 "check that the fsgid provided by the client is taken into account"
+
 TMPDIR=$OLDTMPDIR
 TMP=$OLDTMP
 HOME=$OLDHOME