Whamcloud - gitweb
LU-4185 llite: Revise create with no open optimization
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 5a26c77..320c39a 100755 (executable)
@@ -2850,6 +2850,15 @@ test_33f() {
 }
 run_test 33f "nonroot user can create, access, and remove a striped directory"
 
+test_33g() {
+       mkdir -p $DIR/$tdir/dir2
+
+       local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
+       echo $err
+       [[ $err =~ "exists" ]] || error "Not exists error"
+}
+run_test 33g "nonroot user create already existing root created file"
+
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
        rm -f $DIR/f34
@@ -4436,30 +4445,47 @@ test_56a() {    # was test_56
                error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
        echo "$GETSTRIPE --recursive passed."
 
-        # test lfs getstripe with file instead of dir
+       # test lfs getstripe with file instead of dir
        FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
        [[ $FILENUM -eq 1 ]] ||
                error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
        echo "$GETSTRIPE file1 passed."
 
-        #test lfs getstripe with --verbose
+       #test lfs getstripe with --verbose
        [[ $($GETSTRIPE --verbose $DIR/$tdir |
                grep -c lmm_magic) -eq $NUMFILES ]] ||
                error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
        [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
-               rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
+               error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
+
+       #test lfs getstripe with -v prints lmm_fid
+       [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
+               error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
+       [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
+               error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
        echo "$GETSTRIPE --verbose passed."
 
-        #test lfs getstripe with --obd
-        $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
+       #check for FID information
+       local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
+       local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
+                      awk '/lmm_fid: / { print $2 }')
+       local fid3=$($LFS path2fid $DIR/$tdir/file1)
+       [ "$fid1" != "$fid2" ] &&
+               error "getstripe --fid $fid1 != getstripe --verbose $fid2"
+       [ "$fid1" != "$fid3" ] &&
+               error "getstripe --fid $fid1 != lfs path2fid $fid3"
+       echo "$GETSTRIPE --fid passed."
+
+       #test lfs getstripe with --obd
+       $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
                grep -q "unknown obduuid" ||
                error "$GETSTRIPE --obd wrong_uuid should return error message"
 
        [[ $OSTCOUNT -lt 2 ]] &&
-                skip_env "skipping other $GETSTRIPE --obd test" && return
+               skip_env "skipping other $GETSTRIPE --obd test" && return
 
-        OSTIDX=1
-        OBDUUID=$(ostuuid_from_index $OSTIDX)
+       OSTIDX=1
+       OBDUUID=$(ostuuid_from_index $OSTIDX)
        FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
        FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
        [[ $FOUND -eq $FILENUM ]] ||
@@ -4805,7 +4831,7 @@ run_test 56s "check lfs find -stripe-count works"
 
 test_56t() { # LU-611
        TDIR=$DIR/${tdir}t
-       setup_56 $NUMFILES $NUMDIRS "-s 512k"
+       setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
 
        $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
 
@@ -6698,6 +6724,9 @@ run_test 101e "check read-ahead for small read(1k) for small files(500k)"
 test_101f() {
        which iozone || { skip "no iozone installed" && return; }
 
+       local old_debug=$($LCTL get_param debug)
+       $LCTL set_param debug="reada mmap"
+
        # create a test file
        iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
 
@@ -6711,10 +6740,12 @@ test_101f() {
        iozone -i 1 -+n -r 32k -s 128m -B -f $DIR/$tfile > /dev/null 2>&1
 
        echo checking missing pages
+       $LCTL get_param llite.*.read_ahead_stats
        local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
                        get_named_value 'misses' | cut -d" " -f1 | calc_total)
 
-       [ $miss -lt 3 ] || error "misses too much pages!"
+       $LCTL set_param debug=$old_debug
+       [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
        rm -f $DIR/$tfile
 }
 run_test 101f "check mmap read performance"
@@ -10157,17 +10188,17 @@ test_154A() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
                skip "Need MDS version at least 2.4.1" && return
 
-       touch $DIR/$tfile
-       local FID=$($LFS path2fid $DIR/$tfile)
-       [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
+       local tf=$DIR/$tfile
+       touch $tf
 
-       # check that we get the same pathname back
-       local FOUND=$($LFS fid2path $MOUNT "$FID")
-       [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
-       [ "$FOUND" != "$DIR/$tfile" ] &&
-               error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
+       local fid=$($LFS path2fid $tf)
+       [ -z "$fid" ] && error "path2fid unable to get $tf FID"
 
-       rm -rf $DIR/$tfile
+       # check that we get the same pathname back
+       local found=$($LFS fid2path $MOUNT "$fid")
+       [ -z "$found" ] && error "fid2path unable to get '$fid' path"
+       [ "$found" == "$tf" ] ||
+               error "fid2path($fid=path2fid($tf)) = $found != $tf"
 }
 run_test 154A "lfs path2fid and fid2path basic checks"
 
@@ -14028,6 +14059,129 @@ test_252() {
 }
 run_test 252 "check lr_reader tool"
 
+test_253_fill_ost() {
+       local size_mb #how many MB should we write to pass watermark
+       local lwm=$3  #low watermark
+       local free_10mb #10% of free space
+
+       free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
+       size_mb=$((free_kb / 1024 - lwm))
+       free_10mb=$((free_kb / 10240))
+       #If 10% of free space cross low watermark use it
+       if (( free_10mb > size_mb )); then
+               size_mb=$free_10mb
+       else
+               #At least we need to store 1.1 of difference between
+               #free space and low watermark
+               size_mb=$((size_mb + size_mb / 10))
+       fi
+       if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
+               dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
+                        oflag=append conv=notrunc
+       fi
+
+       sleep_maxage
+
+       free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
+       echo "OST still has $((free_kb / 1024)) mbytes free"
+}
+
+test_253() {
+       local ostidx=0
+       local rc=0
+
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+
+       local ost_name=$($LFS osts | grep ${ostidx}": " | \
+               awk '{print $2}' | sed -e 's/_UUID$//')
+       # on the mdt's osc
+       local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
+       do_facet $SINGLEMDS $LCTL get_param -n \
+               osp.$mdtosc_proc1.reserved_mb_high ||
+               { skip  "remote MDS does not support reserved_mb_high" &&
+                 return; }
+
+       rm -rf $DIR/$tdir
+       wait_mds_ost_sync
+       wait_delete_completed
+       mkdir $DIR/$tdir
+
+       local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
+                       osp.$mdtosc_proc1.reserved_mb_high)
+       local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
+                       osp.$mdtosc_proc1.reserved_mb_low)
+       echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
+
+       do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
+               error "Pool creation failed"
+       do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
+               error "Adding $ost_name to pool failed"
+
+       # Wait for client to see a OST at pool
+       wait_update $HOSTNAME "$LCTL get_param -n
+               lov.$FSNAME-*.pools.$TESTNAME | sort -u |
+               grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
+               error "Client can not see the pool"
+       $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
+               error "Setstripe failed"
+
+       dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
+       local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
+       echo "OST still has $((blocks/1024)) mbytes free"
+
+       local new_lwm=$((blocks/1024-10))
+       do_facet $SINGLEMDS $LCTL set_param \
+                       osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
+       do_facet $SINGLEMDS $LCTL set_param \
+                       osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
+
+       test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
+
+       #First enospc could execute orphan deletion so repeat.
+       test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
+
+       local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
+                       osp.$mdtosc_proc1.prealloc_status)
+       echo "prealloc_status $oa_status"
+
+       dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
+               error "File creation should fail"
+       #object allocation was stopped, but we still able to append files
+       dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
+               error "Append failed"
+       rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
+
+       wait_delete_completed
+
+       sleep_maxage
+
+       for i in $(seq 10 12); do
+               dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
+                       error "File creation failed after rm";
+       done
+
+       oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
+                       osp.$mdtosc_proc1.prealloc_status)
+       echo "prealloc_status $oa_status"
+
+       if (( oa_status != 0 )); then
+               error "Object allocation still disable after rm"
+       fi
+       do_facet $SINGLEMDS $LCTL set_param \
+                       osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
+       do_facet $SINGLEMDS $LCTL set_param \
+                       osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
+
+
+       do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
+               error "Remove $ost_name from pool failed"
+       do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
+               error "Pool destroy fialed"
+}
+run_test 253 "Check object allocation limit"
+
 test_254() {
        local cl_user