Whamcloud - gitweb
LU-4482 grant: don't use cache data in osd_statfs()
[fs/lustre-release.git] / lustre / tests / sanity.sh
index e2e2b96..b0220e2 100644 (file)
@@ -447,6 +447,10 @@ test_17g() {
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
                TESTS="4094 4095"
 
+       # skip long symlink name for rhel6.5.
+       # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
+       grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
+
        for i in $TESTS; do
                local SYMNAME=$(str_repeat 'x' $i)
                ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
@@ -571,7 +575,7 @@ test_17m() {
 
        echo "stop and checking mds${mds_index}: $cmd"
        # e2fsck should not return error
-       stop mds${mds_index} -f
+       stop mds${mds_index}
        do_facet mds${mds_index} $cmd || rc=$?
 
        start mds${mds_index} $devname $MDS_MOUNT_OPTS
@@ -588,7 +592,9 @@ check_fs_consistency_17n() {
        local cmd
        local rc=0
 
-       for mdt_index in $(seq 1 $MDSCOUNT); do
+       # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
+       # so it only check MDT1/MDT2 instead of all of MDTs.
+       for mdt_index in $(seq 1 2); do
                devname=$(mdsdevname $mdt_index)
                cmd="$E2FSCK -fnvd $devname"
 
@@ -3746,7 +3752,7 @@ run_test 51a "special situations: split htree with empty entry =="
 export NUMTEST=70000
 test_51b() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       local BASE=$DIR/$tdir
+       local BASE=$DIR/d${base}.${TESTSUITE}
 
        # cleanup the directory
        rm -fr $BASE
@@ -3773,7 +3779,7 @@ test_51b() {
 run_test 51b "exceed 64k subdirectory nlink limit"
 
 test_51ba() { # LU-993
-       local BASE=$DIR/$tdir
+       local BASE=$DIR/d${base}.${TESTSUITE}
        # unlink all but 100 subdirectories, then check it still works
        local LEFT=100
        [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
@@ -3903,37 +3909,53 @@ test_53() {
        local ost_last_id
        local ostnum
        local node
-       local found=0
+       local found=false
+       local support_last_seq=true
+
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
+               support_last_seq=false
 
        # only test MDT0000
-        local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
-        for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
-                param=$(echo ${value[0]} | cut -d "=" -f1)
-                ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
-                param_seq=$(echo ${param} |
-                           sed -e s/prealloc_last_id/prealloc_last_seq/g)
-               mds_last_seq=$(do_facet $SINGLEMDS lctl get_param -n $param_seq)
-               mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
+       local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
+       local value
+       for value in $(do_facet $SINGLEMDS \
+                      $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
+               param=$(echo ${value[0]} | cut -d "=" -f1)
+               ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
+
+               if $support_last_seq; then
+                       param_seq=$(echo $param |
+                               sed -e s/prealloc_last_id/prealloc_last_seq/g)
+                       mds_last_seq=$(do_facet $SINGLEMDS \
+                                      $LCTL get_param -n $param_seq)
+               fi
+               mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
 
                ostnum=$(index_from_ostuuid ${ostname}_UUID)
                node=$(facet_active_host ost$((ostnum+1)))
                param="obdfilter.$ostname.last_id"
-               for ost_last in $(do_node $node lctl get_param -n $param) ; do
-                       echo "$ostname.last_id=$ost_last ;MDS.last_id=$mds_last"
-                       ost_last_id=$(echo $ost_last | awk -F':' '{print $2}' |
-                                     sed -e "s/^0x//g")
-                       ost_last_seq=$(echo $ost_last | awk -F':' '{print $1}')
-                       if [ $ost_last_seq = $mds_last_seq ]; then
-                               if [ $ost_last_id != $mds_last ]; then
-                                       error "$ost_last != $mds_last_id"
-                               else
-                                       found=1
-                                       break
-                               fi
+               for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
+                       echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
+                       ost_last_id=$ost_last
+
+                       if $support_last_seq; then
+                               ost_last_id=$(echo $ost_last |
+                                             awk -F':' '{print $2}' |
+                                             sed -e "s/^0x//g")
+                               ost_last_seq=$(echo $ost_last |
+                                              awk -F':' '{print $1}')
+                               [[ $ost_last_seq = $mds_last_seq ]] || continue
+                       fi
+
+                       if [[ $ost_last_id != $mds_last ]]; then
+                               error "$ost_last_id != $mds_last"
+                       else
+                               found=true
+                               break
                        fi
                done
-        done
-       [ $found = 0 ] && error "can not match last_seq/last_id for $mdtosc"
+       done
+       $found || error "can not match last_seq/last_id for $mdtosc"
        return 0
 }
 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
@@ -4820,10 +4842,11 @@ test_62() {
 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
 
 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
-test_63a() {   # was test_63
+# Though this test is irrelevant anymore, it helped to reveal some
+# other grant bugs (LU-4482), let's keep it.
+test_63a() {   # was test_63
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
-       lctl set_param -n osc.*.max_dirty_mb 0
        for i in `seq 10` ; do
                dd if=/dev/zero of=$DIR/f63 bs=8k &
                sleep 5
@@ -4831,7 +4854,6 @@ test_63a() {      # was test_63
                sleep 1
        done
 
-       lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
        rm -f $DIR/f63 || true
 }
 run_test 63a "Verify oig_wait interruption does not crash ======="
@@ -5955,89 +5977,89 @@ test_101c() {
 run_test 101c "check stripe_size aligned read-ahead ================="
 
 set_read_ahead() {
-   $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
-   $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
+       $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
+       $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
 }
 
 test_101d() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        local file=$DIR/$tfile
-       local size=${FILESIZE_101c:-500}
+       local sz_MB=${FILESIZE_101d:-500}
        local ra_MB=${READAHEAD_MB:-40}
 
-       local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
-       [ $space -gt $((size * 1024)) ] ||
-               { skip "Need free space ${size}M, have ${space}K" && return; }
+       local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
+       [ $free_MB -lt $sz_MB ] &&
+               skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
 
-       echo "Creating test file $file of size ${size}M with ${space}K free space"
+       echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
        $SETSTRIPE -c -1 $file || error "setstripe failed"
-       dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
+
+       dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
        echo Cancel LRU locks on lustre client to flush the client cache
        cancel_lru_locks osc
 
-    echo Disable read-ahead
-    local old_READAHEAD=$(set_read_ahead 0)
+       echo Disable read-ahead
+       local old_READAHEAD=$(set_read_ahead 0)
 
-    echo Reading the test file $file with read-ahead disabled
-    time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
+       echo Reading the test file $file with read-ahead disabled
+       local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
 
-    echo Cancel LRU locks on lustre client to flush the client cache
-    cancel_lru_locks osc
-    echo Enable read-ahead with ${ra_MB}MB
-    set_read_ahead $ra_MB
+       echo Cancel LRU locks on lustre client to flush the client cache
+       cancel_lru_locks osc
+       echo Enable read-ahead with ${ra_MB}MB
+       set_read_ahead $ra_MB
 
-    echo Reading the test file $file with read-ahead enabled
-    time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
+       echo Reading the test file $file with read-ahead enabled
+       local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
 
-    echo read-ahead disabled time read $time_ra_OFF
-    echo read-ahead enabled  time read $time_ra_ON
+       echo "read-ahead disabled time read $raOFF"
+       echo "read-ahead enabled  time read $raON"
 
        set_read_ahead $old_READAHEAD
        rm -f $file
        wait_delete_completed
 
-    [ $time_ra_ON -lt $time_ra_OFF ] ||
-        error "read-ahead enabled  time read (${time_ra_ON}s) is more than
-               read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
+       [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
+               error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
 }
-run_test 101d "file read with and without read-ahead enabled  ================="
+run_test 101d "file read with and without read-ahead enabled"
 
 test_101e() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-    local file=$DIR/$tfile
-    local size=500  #KB
-    local count=100
-    local blksize=1024
-
-    local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
-    local need_space=$((count * size))
-    [ $space -gt $need_space ] ||
-        { skip_env "Need free space $need_space, have $space" && return; }
-
-    echo Creating $count ${size}K test files
-    for ((i = 0; i < $count; i++)); do
-        dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
-    done
+       local file=$DIR/$tfile
+       local size_KB=500  #KB
+       local count=100
+       local bsize=1024
+
+       local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
+       local need_KB=$((count * size_KB))
+       [ $free_KB -le $need_KB ] &&
+               skip_env "Need free space $need_KB, have $free_KB" && return
+
+       echo "Creating $count ${size_KB}K test files"
+       for ((i = 0; i < $count; i++)); do
+               dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
+       done
 
-    echo Cancel LRU locks on lustre client to flush the client cache
-    cancel_lru_locks osc
+       echo "Cancel LRU locks on lustre client to flush the client cache"
+       cancel_lru_locks osc
 
-    echo Reset readahead stats
-    $LCTL set_param -n llite.*.read_ahead_stats 0
+       echo "Reset readahead stats"
+       $LCTL set_param -n llite.*.read_ahead_stats 0
 
-    for ((i = 0; i < $count; i++)); do
-        dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
-    done
+       for ((i = 0; i < $count; i++)); do
+               dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
+       done
 
-    local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
-          get_named_value 'misses' | cut -d" " -f1 | calc_total)
+       local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
+                    get_named_value 'misses' | cut -d" " -f1 | calc_total)
 
-    for ((i = 0; i < $count; i++)); do
-        rm -rf ${file}_${i} 2>/dev/null
-    done
+       for ((i = 0; i < $count; i++)); do
+               rm -rf $file.$i 2>/dev/null
+       done
 
-    #10000 means 20% reads are missing in readahead
-    [ $miss -lt 10000 ] ||  error "misses too much for small reads"
+       #10000 means 20% reads are missing in readahead
+       [ $miss -lt 10000 ] ||  error "misses too much for small reads"
 }
 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
 
@@ -9189,6 +9211,39 @@ test_154c() {
 }
 run_test 154c "lfs path2fid and fid2path multiple arguments"
 
+test_154d() {
+       [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
+               skip "Need MDS version at least 2.5.53" && return
+
+       if remote_mds; then
+               nid=$($LCTL list_nids | sed  "s/\./\\\./g")
+       else
+               nid="0@lo"
+       fi
+       local proc_ofile="mdt.*.exports.'$nid'.open_files"
+       local fd
+       local cmd
+
+       rm -f $DIR/$tfile
+       touch $DIR/$tfile
+
+       fid=$($LFS path2fid $DIR/$tfile)
+       # Open the file
+       fd=$(free_fd)
+       cmd="exec $fd<$DIR/$tfile"
+       eval $cmd
+       fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
+       echo $fid_list | grep $fid
+       rc=$?
+
+       cmd="exec $fd>/dev/null"
+       eval $cmd
+       if [ $rc -ne 0 ]; then
+               error "FID $fid not found in open files list $fid_list"
+       fi
+}
+run_test 154d "Verify open file fid"
+
 test_155_small_load() {
     local temp=$TMP/$tfile
     local file=$DIR/$tfile
@@ -11717,44 +11772,6 @@ test_230a() {
 }
 run_test 230a "Create remote directory and files under the remote directory"
 
-test_230b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       local MDTIDX=1
-       local remote_dir=$DIR/$tdir/remote_dir
-       local rc=0
-
-       mkdir -p $DIR/$tdir
-       $LFS mkdir -i $MDTIDX $remote_dir ||
-               error "create remote directory failed"
-
-       $LFS mkdir -i 0 $remote_dir/new_dir &&
-               error "nested remote directory create succeed!"
-
-       do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
-       $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
-       do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
-
-       [ $rc -ne 0 ] &&
-          error "create remote directory failed after set enable_remote_dir"
-
-       rm -rf $remote_dir || error "first unlink remote directory failed"
-
-       $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
-                                                       error "chown worked"
-
-       do_facet mds$MDTIDX lctl set_param \
-                               mdt.*.enable_remote_dir_gid=$RUNAS_GID
-       $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
-       do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
-
-       [ $rc -ne 0 ] &&
-          error "create remote dir failed after set enable_remote_dir_gid"
-
-       rm -r $DIR/$tdir || error "second unlink remote directory failed"
-}
-run_test 230b "nested remote directory should be failed"
-
 test_231a()
 {
        # For simplicity this test assumes that max_pages_per_rpc
@@ -11912,6 +11929,17 @@ test_236() {
 }
 run_test 236 "Layout swap on open unlinked file"
 
+# test to verify file handle related system calls
+# (name_to_handle_at/open_by_handle_at)
+# The new system calls are supported in glibc >= 2.14.
+
+test_237() {
+       echo "Test file_handle syscalls" > $DIR/$tfile
+       check_fhandle_syscalls $DIR/$tfile ||
+               error "check_fhandle_syscalls failed"
+}
+run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
+
 #
 # tests that do cleanup/setup should be run at the end
 #