Whamcloud - gitweb
LU-7813 lov: rename LOV_MAGIC_V*_DEF to *_DEFINED
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
index cbd34dd..372f9ba 100644 (file)
@@ -51,8 +51,8 @@ test_0() {
        #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)
+       local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
+       local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
 
        [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
 
@@ -75,8 +75,8 @@ test_1() {
        #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)
+       local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
+       local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
 
        [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
 
@@ -133,12 +133,12 @@ del_comp_and_verify() {
        local left=$3
        local size=$4
 
-       local opt="-I"
-       if [ $id == "init" ]; then
-               opt="--component-flags"
+       local opt="-I "
+       if [ $id == "init" -o $id == "^init" ]; then
+               opt="--component-flags="
        fi
 
-       $LFS setstripe --component-del $opt $id $comp_file ||
+       $LFS setstripe --component-del $opt$id $comp_file ||
                error "Delete component $id from $comp_file failed"
 
        local comp_cnt=$($LFS getstripe --component-count $comp_file)
@@ -176,11 +176,10 @@ 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" 1 0
        del_comp_and_verify $comp_file "init" 0 0
        rm -f $comp_file || error "Delete second $comp_file failed"
+
 }
 run_test 3 "Delete component from existing file"
 
@@ -197,7 +196,7 @@ test_5() {
        local subdir=$parent/subdir
 
        rm -fr $parent
-       test_mkdir $parent || error "Create dir $parent failed"
+       test_mkdir $parent
 
        # set default layout to parent directory
        $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
@@ -211,11 +210,11 @@ test_5() {
        #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)
+       local ost_idx=$($LFS getstripe -I1 -i $comp_file)
        [ $ost_idx -ne 0 ] &&
                error "component 1 ost_idx $ost_idx != 0"
 
-       ost_idx=$($LFS getstripe -I 2 -i $comp_file)
+       ost_idx=$($LFS getstripe -I2 -i $comp_file)
        [ $ost_idx -ne 0 ] &&
                error "component 2 ost_idx $ost_idx != 0"
 
@@ -236,7 +235,7 @@ test_5() {
                error "Delete default layout from $parent failed"
 
        comp_cnt=$($LFS getstripe -d --component-count $parent)
-       [ ! -z "$comp_cnt" ] && error "$comp_cnt isn't empty"
+       [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
 
        rm -f $comp_file || error "Delete $comp_file failed"
        rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
@@ -255,7 +254,7 @@ test_6() {
                error "Create v1 $comp_file failed"
 
        local comp_cnt=$($LFS getstripe --component-count $comp_file)
-       [ ! -z "$comp_cnt" ] && error "Wrong component count $comp_cnt"
+       [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt"
 
        dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
                error "Write to v1 $comp_file failed"
@@ -290,7 +289,7 @@ test_6() {
                error "Migrate(composite -> v1) $comp_file failed"
 
        comp_cnt=$($LFS getstripe --component-count $comp_file)
-       [ ! -z "$comp_cnt" ] && error "$comp_cnt isn't empty"
+       [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
 
        chksum=$(md5sum $comp_file)
        [ "$old_chksum" != "$chksum" ] &&
@@ -301,7 +300,7 @@ test_6() {
 run_test 6 "Migrate composite file"
 
 test_7() {
-       test_mkdir -p $DIR/$tdir || error "mkdir failed"
+       test_mkdir $DIR/$tdir
        chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
 
        local comp_file=$DIR/$tdir/$tfile
@@ -325,17 +324,17 @@ test_8() {
        local parent=$DIR/$tdir
 
        rm -fr $parent
-       test_mkdir -p $parent || error "Create dir $parent failed"
+       test_mkdir $parent
 
        $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
                -E -1 -c 4 -S 4M $parent ||
                error "Set default layout to $parent failed"
 
-       sh rundbench -C -D $parent 2 || error "debench failed"
+       sh rundbench -C -D $parent 2 || error "dbench failed"
 
        rm -fr $parent || error "Delete dir $parent failed"
 }
-run_test 8 "Run debench over composite files"
+run_test 8 "Run dbench over composite files"
 
 test_9() {
        local comp_file=$DIR/$tdir/$tfile
@@ -354,15 +353,15 @@ test_9() {
        # 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 |
+       local f1=$($LFS getstripe -I2 $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 |
+       local f2=$($LFS getstripe -I2 $comp_file |
                        awk '/l_fid:/ {print $7}')
        echo "after MDS recovery, the ost fid of 2nd component is $f2"
-       [ $f1 == $f2 ] || error "$f1 != $f2"
+       [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
 }
 run_test 9 "Replay layout extend object instantiation"
 
@@ -385,7 +384,7 @@ test_10() {
                -E -1 -c 4 -S 4M $MOUNT ||
                error "Set root layout failed"
 
-       test_mkdir -p $parent || error "Create dir $parent failed"
+       test_mkdir $parent
        # set a different layout for parent
        $LFS setstripe -E -1 -c 1 -S 1M $parent ||
                error "set $parent layout failed"
@@ -428,34 +427,34 @@ test_11() {
        $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")
+       local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
        [[ -z $f1 ]] && error "1: 1st component uninstantiated"
-       local f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+       local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
        [[ -n $f2 ]] && error "1: 2nd component instantiated"
-       local f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
        [[ -n $f3 ]] && error "1: 3rd component instantiated"
-       local f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       local f4=$($LFS getstripe -I4 $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")
+       f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
        [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
-       f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
        [[ -n $f3 ]] && error "2: 3rd component instantiated"
-       f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       f4=$($LFS getstripe -I4 $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")
+       f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
        [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
-       f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+       f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
        [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
-       f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+       f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
        [[ -n $f4 ]] && error "3: 4th component instantiated"
 
        # all 4 components instantiated, using append write
@@ -464,7 +463,7 @@ test_11() {
        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")
+       f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
        [[ -z $f4 ]] && error "4: 4th component uninstantiated"
 
        return 0
@@ -480,8 +479,14 @@ test_12() {
 
        # 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 ||
+               -E4m -c1 -i2 -E-1 $file ||
                error "Create $file failed"
+
+       # clear lod component cache
+       stop $SINGLEMDS || error "stop MDS"
+       local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
+       start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
+
        # instantiate all components
        $TRUNCATE $file $((1024*1024*4+1))
 
@@ -500,7 +505,7 @@ test_12() {
 
        local o4=$($LFS getstripe -I4 $file |
                        awk '/l_ost_idx:/ {printf("%d",$5)}')
-       [[ $o4 != "20" ]] && error "$o4 is not 20"
+       [[ $o4 != "2" ]] && error "$o4 is not 2"
 
        return 0
 }
@@ -567,6 +572,106 @@ test_14() {
 }
 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
 
+test_15() {
+       local parent=$DIR/$tdir
+
+       rm -fr $parent
+       test_mkdir $parent
+
+       $LFS setstripe -d $parent || error "delete default layout"
+
+       $LFS setstripe -E 1M -E 10M -E eof $parent/f1 || error "create f1"
+       $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
+       test_mkdir $parent/subdir
+       $LFS setstripe -E 6M -E 30M -E eof $parent/subdir ||
+               error "setstripe to subdir"
+       $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
+       $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
+
+       # none
+       local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
+       [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
+
+       # f2, f3
+       found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
+       [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
+
+       # subdir
+       found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
+       [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
+
+       local flg_opts="--component-flags init"
+       # none
+       found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
+       [ $found -eq 0 ] ||
+               error "before write: start=1M, end=10M, flag=init, $found != 0"
+
+       dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
+               error "dd $parent/f1 failed"
+
+       # f1
+       found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
+       [ $found -eq 1 ] ||
+               error "after write: start=1M, end=10M, flag=init, $found != 1"
+
+       local ext_opts="--component-start -1M -E +5M"
+       # parent, subdir, f3, f4
+       found=$($LFS find $ext_opts $parent | wc -l)
+       [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
+
+       local cnt_opts="--component-count +2"
+       # subdir
+       found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
+       [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
+
+       # none
+       found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
+       [ $found -eq 0 ] ||
+               error "start-1M, end+5M, count+2, flag=init, $found != 0"
+
+       # f3, f4
+       found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
+       [ $found -eq 2 ] ||
+               error "start-1M, end+5M, !count+2, flag=init, $found != 2"
+}
+run_test 15 "Verify component options for lfs find"
+
+test_17() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+       local file=$DIR/$tdir/$tfile
+       test_mkdir -p $DIR/$tdir
+       rm -f $file
+
+       $LFS setstripe -E1m -E2m -c2 -E-1 -c-1 $file ||
+               error "Create $file failed"
+
+       local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
+       local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
+       local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
+       echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
+
+       # init 2nd component
+       $TRUNCATE $file $((1024*1024+1))
+       local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
+       local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
+       echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
+
+       [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
+       [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
+
+       # init 3rd component
+       $TRUNCATE $file $((1024*1024*2+1))
+       s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
+       s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
+       local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
+       echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
+
+       [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
+       [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
+       [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
+}
+run_test 17 "Verify LOVEA grows with more component inited"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status