Whamcloud - gitweb
LU-9357 pfl: should inherit pool from previous layout comp
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
index 2720a1a..cbd34dd 100644 (file)
@@ -39,14 +39,18 @@ check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
 test_0() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
        local rw_len=$((3 * 1024 * 1024))       # 3M
 
+       test_mkdir $DIR/$tdir
        rm -f $comp_file
 
        $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)
 
@@ -59,14 +63,18 @@ test_0() {
 run_test 0 "Create full components file, no reused OSTs"
 
 test_1() {
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
        local rw_len=$((3 * 1024 * 1024))       # 3M
 
+       test_mkdir $DIR/$tdir
        rm -f $comp_file
 
        $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)
 
@@ -79,9 +87,10 @@ test_1() {
 run_test 1 "Create full components file, reused OSTs"
 
 test_2() {
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
        local rw_len=$((5 * 1024 * 1024))       # 5M
 
+       test_mkdir $DIR/$tdir
        rm -f $comp_file
 
        $LFS setstripe -E 1m -S 1m $comp_file ||
@@ -97,8 +106,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"
@@ -142,8 +151,9 @@ del_comp_and_verify() {
 }
 
 test_3() {
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
 
+       test_mkdir $DIR/$tdir
        rm -f $comp_file
 
        $LFS setstripe -E 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
@@ -166,6 +176,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"
 }
@@ -184,7 +197,7 @@ test_5() {
        local subdir=$parent/subdir
 
        rm -fr $parent
-       mkdir -p $parent || error "Create dir $parent failed"
+       test_mkdir $parent || error "Create dir $parent failed"
 
        # set default layout to parent directory
        $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
@@ -195,6 +208,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"
@@ -230,8 +246,9 @@ test_5() {
 run_test 5 "Inherit composite layout from parent directory"
 
 test_6() {
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
 
+       test_mkdir $DIR/$tdir
        rm -f $DIR/$tfile
 
        $LFS setstripe -c 1 -S 128K $comp_file ||
@@ -284,7 +301,7 @@ test_6() {
 run_test 6 "Migrate composite file"
 
 test_7() {
-       mkdir -p $DIR/$tdir || error "mkdir failed"
+       test_mkdir -p $DIR/$tdir || error "mkdir failed"
        chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
 
        local comp_file=$DIR/$tdir/$tfile
@@ -308,7 +325,7 @@ test_8() {
        local parent=$DIR/$tdir
 
        rm -fr $parent
-       mkdir -p $parent || error "Create dir $parent failed"
+       test_mkdir -p $parent || error "Create dir $parent failed"
 
        $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
                -E -1 -c 4 -S 4M $parent ||
@@ -321,31 +338,33 @@ test_8() {
 run_test 8 "Run debench over composite files"
 
 test_9() {
-       local comp_file=$DIR/$tfile
+       local comp_file=$DIR/$tdir/$tfile
 
+       test_mkdir $DIR/$tdir
        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 +375,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"
@@ -365,7 +385,7 @@ test_10() {
                -E -1 -c 4 -S 4M $MOUNT ||
                error "Set root layout failed"
 
-       mkdir -p $parent || error "Create dir $parent failed"
+       test_mkdir -p $parent || error "Create dir $parent failed"
        # set a different layout for parent
        $LFS setstripe -E -1 -c 1 -S 1M $parent ||
                error "set $parent layout failed"
@@ -393,10 +413,160 @@ 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/$tdir/$tfile
+       test_mkdir $DIR/$tdir
+       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/$tdir/$tfile
+       test_mkdir $DIR/$tdir
+       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"
+
+test_14() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+       local file=$DIR/$tdir/$tfile
+       test_mkdir -p $DIR/$tdir
+       rm -f $file
+
+       $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
+                       -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
+               error "Create $file failed"
+
+       # check --pool inheritance
+       local pool
+       pool="$($LFS getstripe -I2 --pool $file)"
+       [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
+               error "$file: component 2 doesn't have poolname pool1"
+       pool="$($LFS getstripe -I4 --pool $file)"
+       [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
+               error "$file: component 4 doesn't have poolname pool2"
+
+       #check --stripe-count inheritance
+       local count
+       count="$($LFS getstripe -I2 -c $file)"
+       [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
+               error "$file: component 2 doesn't have 1 stripe_count"
+       count="$($LFS getstripe -I4 -c $file)"
+       [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
+               error "$file: component 4 doesn't have 2 stripe_count"
+
+       #check --stripe-size inheritance
+       local size
+       size="$($LFS getstripe -I2 -S $file)"
+       [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
+               error "$file: component 2 doesn't have 1M stripe_size"
+       size="$($LFS getstripe -I4 -S $file)"
+       [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
+               error "$file: component 4 doesn't have 2M stripe_size"
+
+       return 0
+}
+run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status