Whamcloud - gitweb
b=23049 canonicalize disk names
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 248491e..a40f77d 100755 (executable)
@@ -44,7 +44,6 @@ MCREATE=${MCREATE:-mcreate}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
 READS=${READS:-"reads"}
-TRUNCATE=${TRUNCATE:-truncate}
 MUNLINK=${MUNLINK:-munlink}
 SOCKETSERVER=${SOCKETSERVER:-socketserver}
 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
@@ -2664,7 +2663,7 @@ test_43b() {
        cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
         MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
         MULTIOP_PID=$!
-        truncate $DIR/d43/multiop 0 && error "expected error, got success"
+        $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
         kill -USR1 $MULTIOP_PID || return 2
         wait $MULTIOP_PID || return 3
         rm $TMP/test43.junk
@@ -3292,8 +3291,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 ======="
@@ -3913,7 +3912,7 @@ test_69() {
        $DIRECTIO write ${f}.2 0 1 || error "directio write error"
 
        do_facet ost1 lctl set_param fail_loc=0x217
-       truncate $f 1 # vmtruncate() will ignore truncate() error.
+       $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
        $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
 
        do_facet ost1 lctl set_param fail_loc=0
@@ -6169,50 +6168,48 @@ test_128() { # bug 15212
 run_test 128 "interactive lfs for 2 consecutive find's"
 
 set_dir_limits () {
-        local mntdev
-        local node
+       local mntdev
+       local canondev
+       local node
 
        local LDPROC=/proc/fs/ldiskfs
 
-        for node in $(mdts_nodes); do
-                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
+       for facet in $(get_facets MDS); do
+               canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
+               do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
+               do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
        done
 }
 test_129() {
-        [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
-        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
-        EFBIG=27
-        MAX=16384
+       EFBIG=27
+       MAX=16384
 
-        set_dir_limits $MAX
+       set_dir_limits $MAX
 
-        mkdir -p $DIR/$tdir
+       mkdir -p $DIR/$tdir
 
-        I=0
-        J=0
-        while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
-                multiop $DIR/$tdir/$J Oc
-                rc=$?
-                if [ $rc -eq $EFBIG ]; then
-                        set_dir_limits 0
-                        echo "return code $rc received as expected"
-                        return 0
-                elif [ $rc -ne 0 ]; then
-                        set_dir_limits 0
-                        error_exit "return code $rc received instead of expected $EFBIG"
-                fi
-                J=$((J+1))
-                I=$(stat -c%s "$DIR/$tdir")
-        done
+       I=0
+       J=0
+       while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
+               multiop $DIR/$tdir/$J Oc
+               rc=$?
+               if [ $rc -eq $EFBIG ]; then
+                       set_dir_limits 0
+                       echo "return code $rc received as expected"
+                       return 0
+               elif [ $rc -ne 0 ]; then
+                       set_dir_limits 0
+                       error_exit "return code $rc received instead of expected $EFBIG"
+               fi
+               J=$((J+1))
+               I=$(stat -c%s "$DIR/$tdir")
+       done
 
-        error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
-        do_facet $SINGLEMDS "echo 0 >$LDPROC"
+       set_dir_limits 0
+       error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
 }
 run_test 129 "test directory size limit ========================"
 
@@ -7102,42 +7099,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
 }
@@ -7394,8 +7396,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 ==============================="
 
@@ -7702,6 +7704,23 @@ test_217() { # bug 22430
 }
 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
 
+test_218() {
+       # do directio so as not to populate the page cache
+       log "creating a 10 Mb file"
+       multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
+       log "starting reads"
+       dd if=$DIR/$tfile of=/dev/null bs=4096 &
+       log "truncating the file"
+       multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
+       log "killing dd"
+       kill %+ || true # reads might have finished
+       echo "wait until dd is finished"
+       wait
+       log "removing the temporary file"
+       rm -rf $DIR/$tfile || error "tmp file removal failed"
+}
+run_test 218 "parallel read and truncate should not deadlock ======================="
+
 #
 # tests that do cleanup/setup should be run at the end
 #