Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 3cfcc5b..77157c2 100644 (file)
@@ -126,7 +126,7 @@ rm -rf $DIR/[Rdfs][0-9]*
 # $RUNAS_ID may get set incorrectly somewhere else
 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
 
-check_runas_id $RUNAS_ID $RUNAS
+check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
 
 build_test_filter
 
@@ -3162,7 +3162,7 @@ test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
        [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
 
         # Check that testing environment is properly set up. Skip if not
-        FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS || {
+        FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
                 skip "User $RUNAS_ID does not exist - skipping"
                 return 0
         }
@@ -3628,21 +3628,16 @@ test_80() { # bug 10718
 }
 run_test 80 "Page eviction is equally fast at high offsets too  ===="
 
-# 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() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && \
+           return
        mkdir -p $DIR/d99cvsroot
        chown $RUNAS_ID $DIR/d99cvsroot
+       local oldPWD=$PWD       # bug 13584, use $TMP as working dir
+       cd $TMP
+       
        $RUNAS cvs -d $DIR/d99cvsroot init || error
+       cd $oldPWD
 }
 run_test 99a "cvs init ========================================="
 
@@ -3990,17 +3985,6 @@ test_102c() {
 }
 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
 
-get_stripe_info() {
-       stripe_size=0
-       stripe_count=0
-       stripe_offset=0
-       local lines=`sed -n '/obdidx/=' $1`
-       stripe_size=`awk '{if($1~/size/) print $2}' $1`
-       stripe_count=`awk '{if($1~/count/) print $2}' $1`
-       lines=`expr $lines + 1`
-       stripe_offset=`sed -n ${lines}p $1 |awk '{print $1}'`
-}
-
 compare_stripe_info1() {
        for num in 1 2 3 4
        do
@@ -4010,22 +3994,16 @@ compare_stripe_info1() {
                        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
+                               get_stripe_info client $PWD/$file
+                               if [ $stripe_size -ne $size ]; then
                                        error "$file: different stripe size" && return
                                fi
-                               if test $stripe_count -ne $count
-                               then
+                               if [ $stripe_count -ne $count ]; then
                                        error "$file: different stripe count" && return
                                fi
-                               if test $stripe_offset -ne 0
-                               then
+                               if [ $stripe_index -ne 0 ]; then
                                        error "$file: different stripe offset" && return
                                fi
-                               rm -f $tmp_file
                        done
                done
        done
@@ -4040,22 +4018,16 @@ compare_stripe_info2() {
                        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
+                               get_stripe_info client $PWD/$file
+                               if [ $stripe_size -ne $size ]; then
                                        error "$file: different stripe size" && return  
                                fi
-                               if test $stripe_count -ne $count
-                               then
+                               if [ $stripe_count -ne $count ]; then
                                        error "$file: different stripe count" && return
                                fi
-                               if test $stripe_offset -ne $offset
-                               then
+                               if [ $stripe_index -ne $offset ]; then
                                        error "$file: different stripe offset" && return
                                fi
-                               rm -f $tmp_file
                        done
                done
        done
@@ -5116,6 +5088,7 @@ test_123a() { # was test 123, statahead(bug 11401)
         for ((i=1, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
                 createmany -o $DIR/$tdir/$tfile $j $((i - j))
 
+                swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
                 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
                 cancel_lru_locks mdc
                 cancel_lru_locks osc
@@ -5125,6 +5098,7 @@ test_123a() { # was test 123, statahead(bug 11401)
                 delta_sa=$((etime - stime))
                 log "ls $i files with statahead:    $delta_sa sec"
                lctl get_param -n llite.*.statahead_stats
+                ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
 
                 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
                 lctl set_param -n llite.*.statahead_max 0
@@ -5138,6 +5112,9 @@ test_123a() { # was test 123, statahead(bug 11401)
                 log "ls $i files without statahead: $delta sec"
 
                 lctl set_param llite.*.statahead_max=$max
+                if [ $swrong -lt $ewrong ]; then
+                        log "statahead was stopped, maybe too many locks held!"
+                fi
                 if [ $delta_sa -gt $(($delta + 2)) ]; then
                         log "ls $i files is slower with statahead!"
                         error=1
@@ -5227,7 +5204,7 @@ test_124a() {
         # them (10-100 locks). This depends on how fast ther were created.
         # Many of them were touched in almost the same moment and thus will
         # be killed in groups.
-        local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP))
+        local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
 
         # 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
@@ -5751,24 +5728,11 @@ test_140() { #bug-17379
                 }
         done
         i=`expr $i - 1`
-        [ $i -eq 5 -o $i -eq 8 ] || error "Invalid symlink depth"
         echo "The symlink depth = $i"
+        [ $i -eq 5 -o $i -eq 8 ] || error "Invalid symlink depth"
 }
 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
 
-test_141() {
-        local ls
-        #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG   0x903
-        $LCTL set_param fail_loc=0x903
-        # cancel_lru_locks mgc - does not work due to lctl set_param syntax
-        for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
-                echo "clear" > $ls
-        done
-        cleanup || error "failed to cleanup"
-        setup || error "failed to setup"
-}
-run_test 141 "umount should not race with any mgc requeue thread"
-
 test_150() {
        local TF="$TMP/$tfile"
 
@@ -5882,6 +5846,143 @@ test_152() {
 }
 run_test 152 "test read/write with enomem ============================"
 
+test_153() {
+        multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
+}
+run_test 153 "test if fdatasync does not crash ======================="
+
+#Changelogs
+test_160() {
+    remote_mds && skip "remote MDS" && return
+    lctl set_param -n mdd.*.changelog on
+    $LFS changelog_clear $FSNAME 0
+
+    # change something
+    mkdir -p $DIR/$tdir/pics/2008/zachy
+    touch $DIR/$tdir/pics/2008/zachy/timestamp
+    cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
+    mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
+    ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
+    ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
+    rm $DIR/$tdir/pics/desktop.jpg
+
+    # verify contents
+    $LFS changelog $FSNAME
+    # check target fid
+    fidc=$($LFS changelog $FSNAME | grep timestamp | grep "CREAT" | tail -1 | \
+       awk '{print $5}')
+    fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
+    [ "$fidc" == "t=$fidf" ] || \
+       error "fid in changelog $fidc != file fid $fidf"
+    # check parent fid
+    fidc=$($LFS changelog $FSNAME | grep timestamp | grep "CREAT" | tail -1 | \
+       awk '{print $6}')
+    fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
+    [ "$fidc" == "p=$fidf" ] || \
+       error "pfid in changelog $fidc != dir fid $fidf" 
+
+    # verify purge
+    FIRST_REC=$($LFS changelog $FSNAME | head -1 | awk '{print $1}')
+    $LFS changelog_clear $FSNAME $(($FIRST_REC + 5)) 
+    PURGE_REC=$($LFS changelog $FSNAME | head -1 | awk '{print $1}')
+    [ $PURGE_REC == $(($FIRST_REC + 6)) ] || \
+     error "first rec after purge should be $(($FIRST_REC + 6)); is $PURGE_REC"
+    # purge all
+    $LFS changelog_clear $FSNAME 0
+    lctl set_param -n mdd.*.changelog off
+}
+run_test 160 "changelog sanity"
+
+test_161() {
+    # need local MDT for fid2path
+    remote_mds && skip "remote MDS" && return
+
+    mkdir -p $DIR/$tdir
+    cp /etc/hosts $DIR/$tdir/$tfile
+    mkdir $DIR/$tdir/foo1
+    mkdir $DIR/$tdir/foo2
+    ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
+    ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
+    ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
+    ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
+    local FID=$($LFS path2fid $DIR/$tdir/$tfile)
+    if [ "$($LFS fid2path ${mds1_svc} $FID | wc -l)" != "5" ]; then
+       $LFS fid2path ${mds1_svc} $FID
+       error "bad link ea"
+    fi
+    # middle
+    rm $DIR/$tdir/foo2/zachary
+    # last
+    rm $DIR/$tdir/foo2/thor
+    # first
+    rm $DIR/$tdir/$tfile
+    # rename
+    mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
+    if [ "$($LFS fid2path ${mds1_svc} --link 1 $FID)" != "/$tdir/foo2/maggie" ]
+       then
+       $LFS fid2path ${mds1_svc} $FID
+       error "bad link rename"
+    fi
+    rm $DIR/$tdir/foo2/maggie
+
+    # overflow the EA
+    local longname=filename_avg_len_is_thirty_two_
+    createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
+       error "failed to hardlink many files"
+    links=$($LFS fid2path ${mds1_svc} $FID | wc -l)
+    echo -n "${links}/1000 links in link EA"
+    [ ${links} -gt 60 ] || error "expected at least 60 links in link EA"
+    unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
+       error "failed to unlink many hardlinks" 
+}
+run_test 161 "link ea sanity"
+
+check_path() {
+    local expected=$1
+    shift
+    local fid=$2
+
+    local path=$(${LFS} fid2path $*)
+    RC=$?
+
+    if [ $RC -ne 0 ]; then
+       error "path looked up of $expected failed. Error $RC"
+       return $RC
+    elif [ "${path}" != "${expected}" ]; then
+       error "path looked up \"${path}\" instead of \"${expected}\""
+       return 2
+    fi
+    echo "fid $fid resolves to path $path"
+}
+
+test_162() {
+    # need local MDT for fid2path
+    remote_mds && skip "remote MDS" && return
+
+    # Make changes to filesystem
+    mkdir -p $DIR/$tdir/d2
+    touch $DIR/$tdir/d2/$tfile
+    touch $DIR/$tdir/d2/x1
+    touch $DIR/$tdir/d2/x2
+    mkdir -p $DIR/$tdir/d2/a/b/c
+    mkdir -p $DIR/$tdir/d2/p/q/r
+    fid=$($LFS path2fid $DIR/$tdir/d2/$tfile)
+    check_path "/$tdir/d2/$tfile" ${mds1_svc} $fid --link 0
+    ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
+    mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
+    fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file)
+    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $fid --link 1
+    check_path "/$tdir/d2/p/q/r/hlink" ${mds1_svc} $fid --link 0
+    # check that there are 2 links, and that --rec doesnt break anything
+    ${LFS} fid2path ${mds1_svc} $fid --rec 20 | wc -l | grep -q 2 || \
+       error "expected 2 links" 
+
+    rm $DIR/$tdir/d2/p/q/r/hlink
+    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $fid --link 0
+}
+run_test 162 "path lookup sanity"
+
+# OST pools tests
 POOL=${POOL:-cea1}
 TGT_COUNT=$OSTCOUNT
 TGTPOOL_FIRST=1
@@ -6017,9 +6118,22 @@ test_212() {
 }
 run_test 212 "Sendfile test ============================================"
 
-TMPDIR=$OLDTMPDIR
-TMP=$OLDTMP
-HOME=$OLDHOME
+#
+# tests that do cleanup/setup should be run at the end
+#
+
+test_900() {
+        local ls
+        #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG   0x903
+        $LCTL set_param fail_loc=0x903
+        # cancel_lru_locks mgc - does not work due to lctl set_param syntax
+        for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
+                echo "clear" > $ls
+        done
+        FAIL_ON_ERROR=true cleanup
+        FAIL_ON_ERROR=true setup
+}
+run_test 900 "umount should not race with any mgc requeue thread"
 
 log "cleanup: ======================================================"
 check_and_cleanup_lustre