Whamcloud - gitweb
LU-8943 lnd: Enable Multiple OPA Endpoints between Nodes
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
index 2720a1a..a846956 100644 (file)
@@ -47,6 +47,9 @@ test_0() {
        $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
                error "Create $comp_file failed"
 
+       #instantiate all components, so that objs are allocted
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
+
        local ost_idx1=$($LFS getstripe -I 1 -i $comp_file)
        local ost_idx2=$($LFS getstripe -I 2 -i $comp_file)
 
@@ -67,6 +70,9 @@ test_1() {
        $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
                error "Create $comp_file failed"
 
+       #instantiate all components, so that objs are allocted
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
+
        local ost_idx1=$($LFS getstripe -I 1 -i $comp_file)
        local ost_idx2=$($LFS getstripe -I 2 -i $comp_file)
 
@@ -97,8 +103,8 @@ test_2() {
 
        dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
                error "Write beyond component should fail"
-       dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 &&
-               error "Read beyond component should fail"
+       dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
+               error "Read beyond component should short read, not fail"
 
        $LFS setstripe --component-add -E 2M -c 1 $comp_file ||
                error "Add component to $comp_file failed"
@@ -166,6 +172,9 @@ test_3() {
        $LFS setstripe -E 1M -E 16M -E -1 $comp_file ||
                error "Create second $comp_file failed"
 
+       #instantiate all components, so that objs are allocted
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=17k
+
        del_comp_and_verify $comp_file "init" 0 0
        rm -f $comp_file || error "Delete second $comp_file failed"
 }
@@ -195,6 +204,9 @@ test_5() {
        local comp_cnt=$($LFS getstripe --component-count $comp_file)
        [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 2"
 
+       #instantiate all components, so that objs are allocted
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
+
        local ost_idx=$($LFS getstripe -I 1 -i $comp_file)
        [ $ost_idx -ne 0 ] &&
                error "component 1 ost_idx $ost_idx != 0"
@@ -325,27 +337,28 @@ test_9() {
 
        rm -f $comp_file
 
-       $LFS setstripe -E 1m -S 1m $comp_file ||
+       $LFS setstripe -E 1m -S 1m -E 2M -c 1 $comp_file ||
                error "Create $comp_file failed"
 
        local comp_cnt=$($LFS getstripe --component-count $comp_file)
-       [ $comp_cnt -ne 1 ] && error "component count $comp_cnt != 1"
+       [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
 
        replay_barrier $SINGLEMDS
 
-       $LFS setstripe --component-add -E 2M -c 1 $comp_file ||
-               error "Add component to $comp_file failed"
+       # instantiate the 2nd component
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
 
        local f1=$($LFS getstripe -I 2 $comp_file |
                        awk '/l_fid:/ {print $7}')
-
+       echo "before MDS recovery, the ost fid of 2nd component is $f1"
        fail $SINGLEMDS
 
        local f2=$($LFS getstripe -I 2 $comp_file |
                        awk '/l_fid:/ {print $7}')
+       echo "after MDS recovery, the ost fid of 2nd component is $f2"
        [ $f1 == $f2 ] || error "$f1 != $f2"
 }
-run_test 9 "Replay component add"
+run_test 9 "Replay layout extend object instantiation"
 
 component_dump() {
        echo $($LFS getstripe $1 |
@@ -356,6 +369,7 @@ component_dump() {
 
 test_10() {
        local parent=$DIR/$tdir
+       local root_layout=$(get_layout_param $MOUNT)
 
        rm -rf $parent
        $LFS setstripe -d $MOUNT || error "clear root layout"
@@ -393,10 +407,117 @@ test_10() {
                error "$parent/file1 does not inherite parent layout"
        [  x$f2_expect != x$f2_entry ] &&
                error "$parent/file2 does not inherite root layout"
+
+       $LFS setstripe $root_layout $MOUNT
        return 0
 }
 run_test 10 "Inherit composite template from root"
 
+test_11() {
+       local comp_file=$DIR/$tfile
+       rm -f $comp_file
+
+       # only 1st component instantiated
+       $LFS setstripe -E 1m -E 2m -E 3m -E -1 $comp_file ||
+               error "Create $comp_file failed"
+
+       local f1=$($LFS getstripe -I 1 $comp_file | grep "l_fid")
+       [[ -z $f1 ]] && error "1: 1st component uninstantiated"
+       local f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+       [[ -n $f2 ]] && error "1: 2nd component instantiated"
+       local f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       [[ -n $f3 ]] && error "1: 3rd component instantiated"
+       local f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       [[ -n $f4 ]] && error "1: 4th component instantiated"
+
+       # the first 2 components instantiated
+       $TRUNCATE $comp_file $((1024*1024*1+1))
+
+       f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+       [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
+       f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       [[ -n $f3 ]] && error "2: 3rd component instantiated"
+       f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       [[ -n $f4 ]] && error "2: 4th component instantiated"
+
+       # the first 3 components instantiated
+       $TRUNCATE $comp_file $((1024*1024*3))
+       $TRUNCATE $comp_file $((1024*1024*1+1))
+
+       f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+       [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
+       f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
+       f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       [[ -n $f4 ]] && error "3: 4th component instantiated"
+
+       # all 4 components instantiated, using append write
+       dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
+       ls -l $comp_file
+       rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
+       ls -l $comp_file
+
+       f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       [[ -z $f4 ]] && error "4: 4th component uninstantiated"
+
+       return 0
+}
+run_test 11 "Verify component instantiation with write/truncate"
+
+test_12() {
+       [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
+
+       local file=$DIR/$tfile
+       rm -f $file
+
+       # specify ost list for component
+       $LFS setstripe -E1m -c2 -o0,1 -E2m -c2 -o1,2 -E3m -c2 -o2,1 \
+               -E4m -c2 -o2,0 -E-1 $file ||
+               error "Create $file failed"
+       # instantiate all components
+       $TRUNCATE $file $((1024*1024*4+1))
+
+       #verify object alloc order
+       local o1=$($LFS getstripe -I1 $file |
+                       awk '/l_ost_idx:/ {printf("%d",$5)}')
+       [[ $o1 != "01" ]] && error "$o1 is not 01"
+
+       local o2=$($LFS getstripe -I2 $file |
+                       awk '/l_ost_idx:/ {printf("%d",$5)}')
+       [[ $o2 != "12" ]] && error "$o2 is not 12"
+
+       local o3=$($LFS getstripe -I3 $file |
+                       awk '/l_ost_idx:/ {printf("%d",$5)}')
+       [[ $o3 != "21" ]] && error "$o3 is not 21"
+
+       local o4=$($LFS getstripe -I4 $file |
+                       awk '/l_ost_idx:/ {printf("%d",$5)}')
+       [[ $o4 != "20" ]] && error "$o4 is not 20"
+
+       return 0
+}
+run_test 12 "Verify ost list specification"
+
+test_13() { # LU-9311
+       [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs" && return
+
+       local file=$DIR/$tfile
+       local dd_count=4
+       local dd_size=$(($dd_count * 1024 * 1024))
+       local real_size
+
+       rm -f $file
+       $LFS setstripe -E 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
+               error "Create $file failed"
+       dd if=/dev/zero of=$file bs=1M count=$dd_count
+       real_size=$(stat -c %s $file)
+       [ $real_size -eq $dd_size ] ||
+               error "dd actually wrote $real_size != $dd_size bytes"
+
+       rm -f $file
+}
+run_test 13 "shouldn't reprocess granted resent request"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status