Whamcloud - gitweb
b=20101 a fix for lfs getstripe --pool
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 5ccee9b..c3e586f 100755 (executable)
@@ -477,7 +477,7 @@ test_17h() { #bug 17378
         mkdir -p $DIR/$tdir
         $SETSTRIPE $DIR/$tdir -c -1
 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
-        do_facet mds lctl set_param fail_loc=0x80000141
+        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
         touch $DIR/$tdir/$tfile || true
 }
 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
@@ -487,7 +487,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=0x80000143
+       do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
        ls -l $foo && error "error not detected"
        return 0
 }
@@ -805,6 +805,17 @@ test_24v() {
 }
 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
 
+test_24w() { # bug21506
+        SZ1=234852
+        dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
+        dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
+        dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
+        SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
+        [ "$SZ1" = "$SZ2" ] || \
+                error "Error reading at the end of the file $tfile"
+}
+run_test 24w "Reading a file larger than 4Gb"
+
 test_25a() {
        echo '== symlink sanity ============================================='
 
@@ -993,7 +1004,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 * 2}')
+        local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
         sleep $DELAY
 }
 
@@ -1262,7 +1273,7 @@ test_27y() {
         [ $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 }'`
+        MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
         OFFSET=$(($OSTCOUNT-1))
         OST=-1
         for OSC in $MDS_OSCS; do
@@ -1270,7 +1281,7 @@ test_27y() {
                         OST=`osc_to_ost $OSC`
                 } else {
                         echo $OSC "is Deactivate:"
-                        do_facet mds lctl --device  %$OSC deactivate
+                        do_facet $SINGLEMDS lctl --device  %$OSC deactivate
                 } fi
         done
 
@@ -1290,7 +1301,7 @@ test_27y() {
         for OSC in $MDS_OSCS; do
                 [ `osc_to_ost $OSC` != $OST  ] && {
                         echo $OSC "is activate"
-                        do_facet mds lctl --device %$OSC activate
+                        do_facet $SINGLEMDS lctl --device %$OSC activate
                 }
         done
 }
@@ -2095,11 +2106,11 @@ test_39() {
        $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
        if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
                echo "mtime"
-               ls -l  $DIR/$tfile $DIR/${tfile}2
+               ls -l --full-time $DIR/$tfile $DIR/${tfile}2
                echo "atime"
-               ls -lu  $DIR/$tfile $DIR/${tfile}2
+               ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
                echo "ctime"
-               ls -lc  $DIR/$tfile $DIR/${tfile}2
+               ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
                error "O_TRUNC didn't change timestamps"
        fi
 }
@@ -2349,6 +2360,56 @@ test_39k() {
 }
 run_test 39k "write, utime, close, stat ========================"
 
+# this should be set to future
+TEST_39_ATIME=`date -d "1 year" +%s`
+
+test_39l() {
+       local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
+
+       mkdir -p $DIR/$tdir
+
+       # test setting directory atime to future
+       touch -a -d @$TEST_39_ATIME $DIR/$tdir
+       local atime=$(stat -c %X $DIR/$tdir)
+       [ "$atime" = $TEST_39_ATIME ] || \
+               error "atime is not set to future: $atime, should be $TEST_39_ATIME"
+
+       # test setting directory atime from future to now
+       local d1=$(date +%s)
+       ls $DIR/$tdir
+       local d2=$(date +%s)
+
+       cancel_lru_locks mdc
+       atime=$(stat -c %X $DIR/$tdir)
+       [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
+               error "atime is not updated from future: $atime, should be $d1<atime<$d2"
+
+       do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
+       sleep 3
+
+       # test setting directory atime when now > dir atime + atime_diff
+       d1=$(date +%s)
+       ls $DIR/$tdir
+       d2=$(date +%s)
+       cancel_lru_locks mdc
+       atime=$(stat -c %X $DIR/$tdir)
+       [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
+               error "atime is not updated  : $atime, should be $d2"
+
+       do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
+       sleep 3
+
+       # test not setting directory atime when now < dir atime + atime_diff
+       ls $DIR/$tdir
+       cancel_lru_locks mdc
+       atime=$(stat -c %X $DIR/$tdir)
+       [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
+               error "atime is updated to $atime, should remain $d1<atime<$d2"
+
+       do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
+}
+run_test 39l "directory atime update ==========================="
+
 test_40() {
        dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
        $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
@@ -3231,8 +3292,8 @@ run_test 56h "check lfs find ! -name ============================="
 test_56i() {
        tdir=${tdir}i
        mkdir -p $DIR/$tdir
-       UUID=`$LFS osts | awk '/0: / { print $2 }'`
-       OUT="`$LFIND -ost $UUID $DIR/$tdir`"
+       UUID=$(ostuuid_from_index 0 $DIR/$tdir)
+       OUT=$($LFIND -obd $UUID $DIR/$tdir)
        [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
 }
 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
@@ -3350,6 +3411,39 @@ test_56q() {
 }
 run_test 56q "check lfs find -gid and ! -gid ==============================="
 
+test_56r() {
+       setup_56 $NUMFILES $NUMDIRS
+       TDIR=$DIR/${tdir}g
+       
+       EXPECTED=12
+       NUMS=`$LFIND -size 0 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR -size 0 wrong: found $NUMS, expected $EXPECTED"
+       EXPECTED=0
+       NUMS=`$LFIND ! -size 0 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR ! -size 0 wrong: found $NUMS, expected $EXPECTED"
+       echo "test" > $TDIR/56r && sync
+       EXPECTED=1
+       NUMS=`$LFIND -size 5 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR -size 5 wrong: found $NUMS, expected $EXPECTED"
+       EXPECTED=1
+       NUMS=`$LFIND -size +5 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR -size +5 wrong: found $NUMS, expected $EXPECTED"
+       EXPECTED=13
+       NUMS=`$LFIND -size +0 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR -size +0 wrong: found $NUMS, expected $EXPECTED"
+       EXPECTED=0
+       NUMS=`$LFIND ! -size -5 -t f $TDIR | wc -l`
+       [ $NUMS -eq $EXPECTED ] || \
+               error "lfs find $TDIR ! -size -5 wrong: found $NUMS, expected $EXPECTED"
+}
+
+run_test 56r "check lfs find -size works =========================="
+
 test_57a() {
        # note test will not do anything if MDS is not local
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
@@ -3686,7 +3780,7 @@ test_65k() { # bug11679
                         STRIPE_INDEX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
                                       grep $STRIPE_OST | awk -F: '{print $1}' | head -n 1`
 
-                       [ -f $DIR/$tdir/${STRIPE_INDEX} ] && continue
+                [ -f $DIR/$tdir/${STRIPE_INDEX} ] && continue
                         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=$?
@@ -6084,6 +6178,7 @@ set_dir_limits () {
                 devs=$(do_node $node "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
                for dev in $devs; do
                        mntdev=$(do_node $node "lctl get_param -n osd*.$dev.mntdev")
+                       do_node $node "test -e $LDPROC/\\\$(basename $mntdev)/max_dir_size" || LDPROC=/sys/fs/ldiskfs
                        do_node $node "echo $1 >$LDPROC/\\\$(basename $mntdev)/max_dir_size"
                done
        done
@@ -6438,11 +6533,11 @@ som_mode_switch() {
         if [ x$som = x"enabled" ]; then
                 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
                 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
-                do_facet mgs "$LCTL conf_param mdt.$FSNAME.som=disabled"
+                do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
         else
                 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
                 MOUNTOPT="$MOUNTOPT,som_preview"
-                do_facet mgs "$LCTL conf_param mdt.$FSNAME.som=enabled"
+                do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
         fi
 
         # do remount to make new mount-conf parameters actual
@@ -7007,42 +7102,47 @@ check_path() {
        err17935 "path looked up \"${path}\" instead of \"${expected}\""
        return 2
     fi
-    echo "fid $fid resolves to path $path"
+    echo "fid $fid resolves to path $path (expected $expected)"
 }
 
 test_162() {
-    # 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
+       # 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
        # regular file
-    FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
-    check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
+       FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
+       check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
 
        # softlink
-    ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
-    FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[')
-    check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
+       ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
+       FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
+       check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
+
+       # softlink to wrong file
+       ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
+       FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
+       check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
 
        # hardlink
-    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 | tr -d '[')
-    # fid2path dir/fsname should both work
-    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
-    check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
-
-    # hardlink count: check that there are 2 links
-    # Doesnt work with CMD yet: 17935
+       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 | tr -d '[]')
+       # fid2path dir/fsname should both work
+       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
+       check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
+
+       # hardlink count: check that there are 2 links
+       # Doesnt work with CMD yet: 17935
        ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
                err17935 "expected 2 links"
 
        # hardlink indexing: remove the first link
-    rm $DIR/$tdir/d2/p/q/r/hlink
-    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
+       rm $DIR/$tdir/d2/p/q/r/hlink
+       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
 
        return 0
 }
@@ -7055,7 +7155,7 @@ test_163() {
        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 ||\
+       do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
          error "kernel->userspace send failed"
        kill -INT $!
 }
@@ -7299,8 +7399,8 @@ run_test 200c "Set pool on a directory ================================="
 
 test_200d() {
        remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-       res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
-       [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
+       res=$($GETSTRIPE --pool $POOL_DIR)
+       [ $res = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
 }
 run_test 200d "Check pool on a directory ==============================="
 
@@ -7594,6 +7694,19 @@ test_216() { # bug 20317
 }
 run_test 216 "check lockless direct write works and updates file size and kms correctly"
 
+test_217() { # bug 22430
+       local node
+       for node in $(nodes_list); do
+               if [[ $node = *-* ]] ; then
+                       echo "lctl ping $node@$NETTYPE"
+                       lctl ping $node@$NETTYPE
+               else
+                       echo "skipping $node (no hiphen detected)"
+               fi
+       done
+}
+run_test 217 "check lctl ping for hostnames with hiphen ('-')"
+
 #
 # tests that do cleanup/setup should be run at the end
 #