Whamcloud - gitweb
b=22074 block if grant is available or maybe available soon
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 40e15f9..4e08db8 100644 (file)
@@ -10,7 +10,7 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 12653 12653 5188 16260 19742 
-ALWAYS_EXCEPT="                27u   42a  42b  42c  42d  45   51d   65a   65e   68b  119d  130 $SANITY_EXCEPT"
+ALWAYS_EXCEPT="                27u   42a  42b  42c  42d  45   51d   65a   65e   68b  $SANITY_EXCEPT"
 # bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
 #ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
@@ -72,8 +72,9 @@ LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
+init_logging
 
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
 
 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
 FAIL_ON_ERROR=false
@@ -984,7 +985,7 @@ test_27m() {
 run_test 27m "create file while OST0 was full =================="
 
 sleep_maxage() {
-        local DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 + 5}')
+        local DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
         sleep $DELAY
 }
 
@@ -1020,7 +1021,7 @@ exhaust_precreations() {
 
        do_facet mds${MDSIDX} lctl get_param osc.*OST*-osc-${MDT_INDEX}.prealloc*
 
-       mkdir -p $DIR/d27/${OST}
+       mkdir -p $DIR/$tdir/${OST}
        $SETSTRIPE $DIR/$tdir/${OST} -i $OSTIDX -c 1
 #define OBD_FAIL_OST_ENOSPC              0x215
        do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
@@ -1238,6 +1239,12 @@ test_27y() {
         [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
         remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
+        local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.*0000-osc-MDT0000.prealloc_last_id)
+        local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.*0000-osc-MDT0000.prealloc_next_id)
+        local fcount=$((last_id - next_id))
+        [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
+        [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
+
         MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
         OFFSET=$(($OSTCOUNT-1))
         OST=-1
@@ -1256,7 +1263,7 @@ test_27y() {
 
         do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
         sleep_maxage
-        createmany -o $DIR/$tdir/$tfile $OSTCOUNT
+        createmany -o $DIR/$tdir/$tfile $fcount
         do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
 
         for i in `seq 0 $OFFSET`; do
@@ -1778,6 +1785,23 @@ test_34f() { # bug 6242, 6243
 }
 run_test 34f "read from a file with no objects until EOF ======="
 
+test_34g() {
+       dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
+       $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
+       cancel_lru_locks osc
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
+               error "wrong size after lock cancel"
+
+       $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+               error "expanding truncate failed"
+       cancel_lru_locks osc
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+               error "wrong expanded size after lock cancel"
+}
+run_test 34g "truncate long file ==============================="
+
 test_35a() {
        cp /bin/sh $DIR/f35a
        chmod 444 $DIR/f35a
@@ -1823,15 +1847,15 @@ test_36e() {
 }
 run_test 36e "utime on non-owned file (should return error) ===="
 
-test_36f() {
+subr_36fh() {
+       local fl="$1"
        local LANG_SAVE=$LANG
        local LC_LANG_SAVE=$LC_LANG
        export LANG=C LC_LANG=C # for date language
 
        DATESTR="Dec 20  2000"
        mkdir -p $DIR/$tdir
-       #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
-       lctl set_param fail_loc=0x80000214
+       lctl set_param fail_loc=$fl
        date; date +%s
        cp /etc/hosts $DIR/$tdir/$tfile
        sync & # write RPC generated with "current" inode timestamp, but delayed
@@ -1849,6 +1873,11 @@ test_36f() {
 
        export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
 }
+
+test_36f() {
+       #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
+       subr_36fh "0x80000214"
+}
 run_test 36f "utime on file racing with OST BRW write =========="
 
 test_36g() {
@@ -1866,6 +1895,12 @@ test_36g() {
 }
 run_test 36g "filter mod data cache expiry ====================="
 
+test_36h() {
+       #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
+       subr_36fh "0x80000227"
+}
+run_test 36h "utime on file racing with OST BRW write =========="
+
 test_37() {
        mkdir -p $DIR/$tdir
        echo f > $DIR/$tdir/fbugfile
@@ -2066,6 +2101,73 @@ test_42d() {
 }
 run_test 42d "test complete truncate of file with cached dirty data"
 
+page_size() {
+       getconf PAGE_SIZE
+}
+
+test_42e() { # bug22074
+       local TDIR=$DIR/${tdir}e
+       local pagesz=$(page_size)
+       local pages=16
+       local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
+       local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
+       local max_dirty_mb
+       local warmup_files
+
+       mkdir -p $TDIR
+       $LFS setstripe -c 1 $TDIR
+       createmany -o $TDIR/f $files
+
+       max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
+
+       # we assume that with $OSTCOUNT files, at least one of them will
+       # be allocated on OST0.
+       warmup_files=$((OSTCOUNT * max_dirty_mb))
+       createmany -o $TDIR/w $warmup_files
+
+       # write a large amount of data into one file and sync, to get good
+       # avail_grant number from OST.
+       for ((i=0; i<$warmup_files; i++)); do
+               idx=$($LFS getstripe -i $TDIR/w$i)
+               [ $idx -ne 0 ] && continue
+               dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
+               break
+       done
+       [ $i -gt $warmup_files ] && error "OST0 is still cold"
+       sync
+       $LCTL get_param $proc_osc0/cur_dirty_bytes
+       $LCTL get_param $proc_osc0/cur_grant_bytes
+
+       # create as much dirty pages as we can while not to trigger the actual
+       # RPCs directly. but depends on the env, VFS may trigger flush during this
+       # period, hopefully we are good.
+       for ((i=0; i<$warmup_files; i++)); do
+               idx=$($LFS getstripe -i $TDIR/w$i)
+               [ $idx -ne 0 ] && continue
+               dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
+       done
+       $LCTL get_param $proc_osc0/cur_dirty_bytes
+       $LCTL get_param $proc_osc0/cur_grant_bytes
+
+       # perform the real test
+       $LCTL set_param $proc_osc0/rpc_stats 0
+       for ((;i<$files; i++)); do
+               [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
+               dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
+       done
+       sync
+       $LCTL get_param $proc_osc0/rpc_stats
+
+       $LCTL get_param $proc_osc0/rpc_stats |
+               while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
+                       [ "$PPR" != "16:" ] && continue
+                       [ $WPCT -lt 85 ] && error "$pages-page write RPCs only $WPCT% < 85%"
+                       break # we only want the "pages per rpc" stat
+               done
+       rm -rf $TDIR
+}
+run_test 42e "verify sub-RPC writes are not done synchronously"
+
 test_43() {
        mkdir -p $DIR/$tdir
        cp -p /bin/ls $DIR/$tdir/$tfile
@@ -2191,10 +2293,6 @@ test_45() {
 }
 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
@@ -3640,7 +3738,9 @@ rm -f $F77_TMP
 unset F77_TMP
 
 test_78() { # bug 10901
-       NSEQ=5
+       remote_ost || { skip_env "local OST" && return; }
+
+       NSEQ=5
        F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
        echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
        MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
@@ -4330,7 +4430,7 @@ test_103 () {
 }
 run_test 103 "acl test ========================================="
 
-test_104() {
+test_104a() {
        touch $DIR/$tfile
        lfs df || error "lfs df failed"
        lfs df -ih || error "lfs df -ih failed"
@@ -4346,7 +4446,18 @@ test_104() {
        lfs df || error "lfs df with reactivated OSC failed"
        rm -f $DIR/$tfile
 }
-run_test 104 "lfs df [-ih] [path] test ========================="
+run_test 104a "lfs df [-ih] [path] test ========================="
+
+test_104b() {
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+       chmod 666 /dev/obd
+       denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
+       if [ $denied_cnt -ne 0 ];
+       then
+                   error "lfs check servers test failed"
+       fi
+}
+run_test 104b "$RUNAS lfs check servers test ===================="
 
 test_105a() {
        # doesn't work on 2.4 kernels
@@ -5928,9 +6039,12 @@ test_132() { #1028, SOM
         stat $DIR/$tfile >/dev/null
         gl2=$(get_ost_param "ldlm_glimpse_enqueue")
         echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
-        cancel_lru_locks osc
+        rm $DIR/$tfile
         som_mode_switch $som1 $gl1 $gl2
 
+        dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
+        cancel_lru_locks osc
+
         som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" |  awk -F= ' {print $2}' | head -n 1)
         if [ $som1 == $som2 ]; then
             error "som is still "$som2