Whamcloud - gitweb
b=22187 Handle the NULL pointer as legal value.
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 2d93a0e..0752702 100644 (file)
@@ -490,7 +490,7 @@ test_17i() { #bug 20018
        local foo=$DIR/$tdir/$tfile
        ln -s $foo $foo || error "create symlink failed"
 #define OBD_FAIL_MDS_READLINK_EPROTO     0x143
-       do_facet mds lctl set_param fail_loc=0x80000144
+       do_facet mds lctl set_param fail_loc=0x80000143
        ls -l $foo && error "error not detected"
        return 0
 }
@@ -1203,6 +1203,8 @@ test_27w() { # bug 10997
         $LSTRIPE $DIR/$tdir/f0 -s 65536 || error "lstripe failed"
         size=`$GETSTRIPE $DIR/$tdir/f0 -s`
         [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
+        gsdir=$($LFS getstripe -d $DIR/$tdir)
+        [ $(echo $gsdir | grep -c stripe_count) -ne 1 ] && error "$LFS getstripe -d $DIR/$tdir failed"
 
         [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
         for i in `seq 1 $OSTCOUNT`; do
@@ -2101,6 +2103,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
@@ -2226,10 +2295,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
@@ -2499,7 +2564,7 @@ test_52a() {
        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 "^-+[ae]-+ $DIR/d52a/foo" || error "lsattr"
+       lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
        chattr -a $DIR/d52a/foo || error "chattr -a failed"
         cp -r $DIR/d52a /tmp/
        rm -fr $DIR/d52a || error "cleanup rm failed"
@@ -2519,7 +2584,7 @@ test_52b() {
        mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
        [ -f $DIR/d52b/foo ] || error
        [ -f $DIR/d52b/foo_ren ] && error
-       lsattr $DIR/d52b/foo | egrep -q "^-+[ie]-+ $DIR/d52b/foo" || error "lsattr"
+       lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
        chattr -i $DIR/d52b/foo || error "chattr failed"
 
        rm -fr $DIR/d52b || error
@@ -4314,6 +4379,28 @@ test_102j() {
 }
 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
 
+test_102k() {
+        touch $DIR/$tfile
+        # b22187 just check that does not crash for regular file.
+        setfattr -n trusted.lov $DIR/$tfile
+        # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
+        local test_kdir=$DIR/d102k
+        mkdir $test_kdir
+        local default_size=`$GETSTRIPE -s $test_kdir`
+        local default_count=`$GETSTRIPE -c $test_kdir`
+        local default_offset=`$GETSTRIPE -o $test_kdir`
+        $SETSTRIPE -s 65536 -i 1 -c 2 $test_kdir || error 'dir setstripe failed'
+        setfattr -n trusted.lov $test_kdir
+        local stripe_size=`$GETSTRIPE -s $test_kdir`
+        local stripe_count=`$GETSTRIPE -c $test_kdir`
+        local stripe_offset=`$GETSTRIPE -o $test_kdir`
+        [ $stripe_size -eq $default_size ] || error "stripe size $stripe_size != $default_size"
+        [ $stripe_count -eq $default_count ] || error "stripe count $stripe_count != $default_count"
+        [ $stripe_offset -eq $default_offset ] || error "stripe offset $stripe_offset != $default_offset"
+        rm -rf $DIR/$tfile $test_kdir
+}
+run_test 102k "setfattr without parameter of value shouldn't cause a crash"
+
 cleanup_test102
 
 run_acl_subtest()
@@ -6559,15 +6646,16 @@ run_test 162 "path lookup sanity"
 
 test_163() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       copytool --test || { skip "copytool not runnable: $?" && return; }
-       copytool &
+       copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
+       copytool $FSNAME &
        sleep 1
        local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
        # this proc file is temporary and linux-only
-       do_facet mds lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid || error "lnl send failed"
-       kill $!
+       do_facet mds lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
+         error "kernel->userspace send failed"
+       kill -INT $!
 }
-run_test 163 "LustreNetLink kernelcomms"
+run_test 163 "kernel <-> userspace comms"
 
 test_169() {
        # do directio so as not to populate the page cache