Whamcloud - gitweb
LU-14808 utils: fix YAML support for DOM files
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
index 106842b..36c72bd 100644 (file)
@@ -12,9 +12,19 @@ init_test_env $@
 init_logging
 
 # bug number for skipped test:
-ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT"
+ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT "
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
+# Skip tests for PPC that fail frequently
+if [[ $(uname -m) = ppc64 ]]; then
+       # bug number:    LU-13186 LU-13205 LU-13207 LU-13186
+       ALWAYS_EXCEPT+=" 14       16a      16b      17"
+fi
+
+if [[ "$ost1_FSTYPE" == "zfs" ]]; then
+       # bug #:        LU-1941
+       ALWAYS_EXCEPT+="24a"
+fi
 build_test_filter
 
 check_and_setup_lustre
@@ -66,21 +76,116 @@ test_0b() {
 
        test_mkdir $DIR/$tdir
 
+       $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
+               error "Create $comp_file failed"
+
+       local count=$($LFS getstripe -I1 -c $comp_file)
+       [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
+               error "stripe count of first component is shrinked to $count"
+
+       rm -f $comp_file || error "Delete $comp_file failed"
+
        # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
        $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
                -C $LOV_MAX_STRIPE_COUNT $comp_file ||
-       error "Create $comp_file failed"
+               error "Create $comp_file failed"
+
+       local count=$($LFS getstripe -I2 -c $comp_file)
+       [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
+               error "stripe count of second component is shrinked to $count"
 
        rm -f $comp_file || error "Delete $comp_file failed"
 
-       # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
-       $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
-               $comp_file && error "Create $comp_file succeeded"
+       # Create file with 3*LOV_MAX_STRIPE_COUNT stripes should fail
+       $LFS setstripe -E 200G -C $LOV_MAX_STRIPE_COUNT \
+               -E 500G -C $LOV_MAX_STRIPE_COUNT \
+               -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file &&
+               error "Create $comp_file succeeded"
 
        rm -f $comp_file || error "Delete $comp_file failed"
 }
 run_test 0b "Verify comp stripe count limits"
 
+test_0c() {
+       [[ $($LCTL get_param mdc.*.import |
+               grep "connect_flags:.*overstriping") ]] ||
+               skip "server does not support overstriping"
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
+               skip "skipped for lustre < $SEL_VER"
+
+       large_xattr_enabled || skip_env "no large xattr support"
+
+       local comp_file=$DIR/$tdir/$tfile
+
+       test_mkdir $DIR/$tdir
+
+       $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT -z 128M $comp_file ||
+               error "Create $comp_file failed"
+
+       local count=$($LFS getstripe -I1 -c $comp_file)
+       [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
+               error "stripe count is shrinked to $count"
+}
+run_test 0c "Verify SEL comp stripe count limits"
+
+test_0d() {
+       (( $MDS1_VERSION > $(version_code 2.14.50.115) )) ||
+               skip_env "Need MDS version at least 2.14.50.115"
+
+       local td=$DIR/$tdir
+       local tf=$td/$tfile
+       local comp_end
+       local stripe_size
+
+       # Create parent directory
+       test_mkdir $td
+
+       # Component end must be a multiple of stripe size
+       # and a multiple of 64KiB to align with the minimum
+       # stripe size value.
+       # Values below 4096 are assumed to be in KiB units.
+       $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
+               error "creating $tf-1 with '-E 127' should fail"
+
+       $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
+               error "creating $tf-1 with '-E 128 -S 512' should fail"
+
+       $LFS setstripe -E 128 $tf-1 ||
+               error "creating $tf-1 failed"
+
+       yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
+               error "writing to $tf-1 should fail"
+
+       yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
+               error "writing to $tf-1 failed"
+
+       comp_end=$($LFS getstripe -I1 -E $tf-1)
+       stripe_size=$($LFS getstripe -I1 -S $tf-1)
+
+       [[ $comp_end == $((128 * 1024)) ]] ||
+               error "incorrect component end '$comp_end' for $tf-1"
+
+       [[ $stripe_size == $((128 * 1024)) ]] ||
+               error "incorrect stripe size '$stripe_size' for $tf-1"
+
+       rm $tf-1 || error "removing $tf-1 failed"
+
+       # The stripe size must be a multiple of 64KiB.
+       # Values below 4096 are assumed to be in KiB units.
+       $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
+               error "creating $tf-2 with '-S 2047' should fail"
+
+       $LFS setstripe -E -1 -S 2048 $tf-2 ||
+               error "creating $tf-2 failed"
+
+       stripe_size=$($LFS getstripe -I1 -S $tf-2)
+       [[ $stripe_size == $((2048 * 1024)) ]] ||
+               error "incorrect stripe size '$stripe_size' for $tf-2"
+
+       rm $tf-2 || error "removing $tf-2 failed"
+}
+run_test 0d "Verify comp end and stripe size"
+
 test_1a() {
        local comp_file=$DIR/$tdir/$tfile
        local rw_len=$((3 * 1024 * 1024))       # 3M
@@ -174,15 +279,19 @@ test_1c() {
 }
 run_test 1c "Test overstriping w/max stripe count"
 
-test_2() {
+base_test_2() {
        local comp_file=$DIR/$tdir/$tfile
        local rw_len=$((5 * 1024 * 1024))       # 5M
+       local params=$1
 
        test_mkdir $DIR/$tdir
        rm -f $comp_file
 
-       $LFS setstripe -E 1m -S 1m $comp_file ||
-               error "Create $comp_file failed"
+       multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
+               error "create failed $comp_file"
+
+       $LFS setstripe --component-add $params $comp_file ||
+               error "Add component to $comp_file failed"
 
        check_component_count $comp_file 1
 
@@ -210,7 +319,16 @@ test_2() {
 
        rm -f $comp_file || error "Delete $comp_file failed"
 }
-run_test 2 "Add component to existing file"
+
+test_2a() {
+       base_test_2 "-E 1m -S 1m"
+}
+run_test 2a "Add components to existing file"
+
+test_2b () {
+       base_test_2 "-E 1m -L mdt"
+}
+run_test 2b "Add components w/DOM to existing file"
 
 del_comp_and_verify() {
        local comp_file=$1
@@ -235,14 +353,14 @@ del_comp_and_verify() {
        $CHECKSTAT -s $size $comp_file || error "size != $size"
 }
 
-test_3() {
+base_test_3() {
        local comp_file=$DIR/$tdir/$tfile
+       local params=$1
 
        test_mkdir $DIR/$tdir
        rm -f $comp_file
 
-       $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
-               error "Create $comp_file failed"
+       $LFS setstripe $params $comp_file || error "Create $comp_file failed"
 
        check_component_count $comp_file 3
 
@@ -263,9 +381,17 @@ test_3() {
        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"
+}
+
+test_3a() {
+       base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
+}
+run_test 3a "Delete components from existing file"
 
+test_3b() {
+       base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
 }
-run_test 3 "Delete component from existing file"
+run_test 3b "Delete components w/DOM from existing file"
 
 test_4() {
        skip "Not supported in PFL"
@@ -509,7 +635,7 @@ test_10() {
 }
 run_test 10 "Inherit composite template from root"
 
-test_11() {
+test_11a() {
        local comp_file=$DIR/$tdir/$tfile
        test_mkdir $DIR/$tdir
        rm -f $comp_file
@@ -560,7 +686,22 @@ test_11() {
 
        return 0
 }
-run_test 11 "Verify component instantiation with write/truncate"
+run_test 11a "Verify component instantiation with write/truncate"
+
+test_11b() {
+       [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
+
+       local file=$DIR/$tdir/$tfile
+
+       test_mkdir $DIR/$tdir
+       rm -f $file
+
+       $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
+               error "setstripe dir $DIR/$tdir failed"
+       expand_truncate_test $file ||
+               error "expand_truncate_test failed on $file"
+}
+run_test 11b "truncate file set file size correctly"
 
 test_12() {
        [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
@@ -845,6 +986,68 @@ test_16b() {
 }
 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
 
+test_16c() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
+       local file=$DIR/$tdir/$tfile
+       local dir=$DIR/$tdir/dir
+       local temp=$DIR/$tdir/template
+       rm -rf $DIR/$tdir
+       test_mkdir $DIR/$tdir
+
+       #####################################################################
+       #                           1. SEL file
+       # set stripe for source file
+       $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
+               $file || error "Create $file failed"
+
+       echo "1. SEL file"
+       verify_yaml_layout $file $file.copy $temp "1. PFL file"
+
+       #####################################################################
+       #                           2. SEL dir
+       # set stripe for source dir
+       test_mkdir $dir
+       $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
+               $dir || error "setstripe $dir failed"
+
+       test_mkdir $dir.copy
+       echo "2. SEL template on dir"
+       verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
+}
+run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
+
+test_16d() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
+       local file=$DIR/$tdir/$tfile
+       local dir=$DIR/$tdir/dir
+       local temp=$DIR/$tdir/template
+       rm -rf $DIR/$tdir
+       test_mkdir $DIR/$tdir
+
+       #####################################################################
+       #                           1. DOM file
+       # set stripe for source file
+       $LFS setstripe -E1m -L mdt -E-1 -o1,0 $file ||
+               error "Create $file failed"
+
+       echo "1. DOM file"
+       verify_yaml_layout $file $file.copy $temp "1. DOM file"
+
+       #####################################################################
+       #                           2. DOM dir
+       # set stripe for source dir
+       test_mkdir $dir
+       $LFS setstripe -E1m -L mdt -E-1 -o1,0 $dir || error "Create $dir failed"
+
+       test_mkdir $dir.copy
+       echo "2. DOM dir"
+       verify_yaml_layout $dir $dir.copy $temp.dir "2. DOM dir"
+}
+run_test 16d "Verify setstripe/getstripe for DOM layout with YAML config file"
+
+
 test_17() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
        local file=$DIR/$tdir/$tfile
@@ -1368,7 +1571,7 @@ test_20a() {
        wait_mds_ost_sync
 
        # First component is on OST0
-       $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 1G $comp_file ||
+       $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
                error "Create $comp_file failed"
 
        # write past end of first component, so it is extended
@@ -1392,12 +1595,12 @@ test_20a() {
        $LFS getstripe $comp_file
 
        flg_opts="--comp-flags init"
-       found=$($LFS find --comp-start 128M -E 1152M $flg_opts $comp_file | \
+       found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
                wc -l)
        [ $found -eq 1 ] || error "Write: third component not found"
 
        flg_opts="--comp-flags extension"
-       found=$($LFS find --comp-start 1152M -E EOF $flg_opts $comp_file |wc -l)
+       found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
        [ $found -eq 1 ] || error "Write: fourth extension component not found"
 
        sel_layout_sanity $comp_file 3
@@ -1421,7 +1624,7 @@ test_20b() {
 
        # normal component to 10M, extendable component to 1G
        # further extendable to EOF
-       $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 512M \
+       $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
                $comp_file || error "Create $comp_file failed"
 
        replay_barrier $SINGLEMDS
@@ -1446,11 +1649,11 @@ test_20b() {
        [ $found -eq 0 ] || error "Write: zero length component still present"
 
        flg_opts="--comp-flags init"
-       found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
+       found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
        [ $found -eq 1 ] || error "Write: second component not found"
 
        flg_opts="--comp-flags extension"
-       found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
+       found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
        [ $found -eq 1 ] || error "Write: third component not found"
 
        fail $SINGLEMDS
@@ -1459,11 +1662,11 @@ test_20b() {
        [ $found -eq 0 ] || error "Failover: 0-length component still present"
 
        flg_opts="--comp-flags init"
-       found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
+       found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
        [ $found -eq 1 ] || error "Failover: second component not found"
 
        flg_opts="--comp-flags extension"
-       found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
+       found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
        [ $found -eq 1 ] || error "Failover: third component not found"
 
        sel_layout_sanity $comp_file 3
@@ -1650,7 +1853,7 @@ test_21b() {
        test_mkdir -p $DIR/$tdir
 
        # DoM, extendable component, further extendable component
-       $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 1G \
+       $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
                $comp_file || error "Create $comp_file failed"
 
        found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
@@ -1674,11 +1877,11 @@ test_21b() {
        [ $found -eq 0 ] || error "Write: Zero length component still present"
 
        flg_opts="--comp-flags init"
-       found=$($LFS find --comp-start 1M -E 1025M $flg_opts $comp_file | wc -l)
+       found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
        [ $found -eq 1 ] || error "Write: extended component not found"
 
        flg_opts="--comp-flags extension"
-       found=$($LFS find --comp-start 1025M -E EOF $flg_opts $comp_file |wc -l)
+       found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
        [ $found -eq 1 ] || error "Write: extension component not found"
 
        sel_layout_sanity $comp_file 3
@@ -2169,6 +2372,113 @@ test_23f() {
 }
 run_test 23f "Append with low on space: repeat and remove EXT comp"
 
+OLDIFS="$IFS"
+cleanup_24() {
+       trap 0
+       IFS="$OLDIFS"
+}
+
+test_24a() {
+       [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
+
+       trap cleanup_24 EXIT RETURN
+
+       local file=$DIR/$tfile
+
+       $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
+               error "setstripe on $file"
+
+       dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
+       sync
+
+       filefrag -ves $file || error "filefrag $file failed"
+       filefrag_op=$(filefrag -ve -k $file |
+                     sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
+
+#Filesystem type is: bd00bd0
+#File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
+# ext:     device_logical:        physical_offset: length:  dev: flags:
+#   0:        0..    1023:    1572864..   1573887:   1024: 0000: net
+#   1:        0..    1023:    1572864..   1573887:   1024: 0002: net
+#   2:     1024..    2047:    1573888..   1574911:   1024: 0001: last,net
+#/mnt/lustre/f24a.sanity-pfl: 3 extents found
+
+       last_lun=$(echo $filefrag_op | cut -d: -f5)
+
+       IFS=$'\n'
+       tot_len=0
+       num_luns=1
+       for line in $filefrag_op; do
+               frag_lun=$(echo $line | cut -d: -f5)
+               ext_len=$(echo $line | cut -d: -f4)
+               if [[ "$frag_lun" != "$last_lun" ]]; then
+                       if (( tot_len != 1024 )); then
+                               cleanup_24
+                               error "$file: OST$last_lun $tot_len != 1024"
+                       else
+                               (( num_luns += 1 ))
+                               tot_len=0
+                       fi
+               fi
+               (( tot_len += ext_len ))
+               last_lun=$frag_lun
+       done
+       if (( num_luns != 3 || tot_len != 1024 )); then
+               cleanup_24
+               error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
+       fi
+
+       echo "FIEMAP on $file succeeded"
+}
+run_test 24a "FIEMAP upon PFL file"
+
+test_25() {
+       local pfl_f=$DIR/$tdir/"$tfile"_pfl
+       local dom_f=$DIR/$tdir/"$tfile"_dom
+       local common_f=$DIR/$tdir/"$tfile"_common
+       local stripe_count
+       local stripe_size
+
+       mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+       $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
+               $pfl_f || error "setstripe $pfl_f failed"
+       $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
+               error "setstripe $dom_f failed"
+       $LFS setstripe -S 512K -c -1 $common_f ||
+               error "setstripe $common_f failed"
+
+       #verify lov_getstripe_old with PFL file
+       stripe_count=$(lov_getstripe_old $pfl_f |
+                       awk '/stripe_count/ { print $2 }')
+       stripe_size=$(lov_getstripe_old $pfl_f |
+                       awk '/stripe_size/ { print $2 }')
+       [ $stripe_count -eq 1 ] ||
+               error "stripe_count $stripe_count !=1 for $pfl_f"
+       [ $stripe_size -eq 2097152 ] ||
+               error "stripe_size $stripe_size != 2097152 for $pfl_f"
+
+       #verify lov_getstripe_old with DoM file
+       stripe_count=$(lov_getstripe_old $dom_f |
+                       awk '/stripe_count/ { print $2 }')
+       stripe_size=$(lov_getstripe_old $dom_f |
+                       awk '/stripe_size/ { print $2 }')
+       [ $stripe_count -eq 1 ] ||
+               error "stripe_count $stripe_count !=1 for $dom_f"
+       [ $stripe_size -eq 1048576 ] ||
+               error "stripe_size $stripe_size != 1048576 for $dom_f"
+
+       #verify lov_getstripe_old with common file
+       stripe_count=$(lov_getstripe_old $common_f |
+                       awk '/stripe_count/ { print $2 }')
+       stripe_size=$(lov_getstripe_old $common_f |
+                       awk '/stripe_size/ { print $2 }')
+       [ $stripe_count -eq $OSTCOUNT ] ||
+               error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
+       [ $stripe_size -eq 524288 ] ||
+               error "stripe_size $stripe_size != 524288 for $common_f"
+}
+run_test 25 "Verify old lov stripe API with PFL files"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status