Whamcloud - gitweb
LU-11848 lov: FIEMAP support for PFL and FLR file
[fs/lustre-release.git] / lustre / tests / sanity.sh
index e01bdc8..a79e409 100755 (executable)
@@ -44,6 +44,11 @@ ALWAYS_EXCEPT+="               42a     42b     42c "
 # bug number:    LU-8411 LU-9054
 ALWAYS_EXCEPT+=" 407     312"
 
+if $SHARED_KEY; then
+       # bug number:    LU-14181 LU-14181
+       ALWAYS_EXCEPT+=" 64e      64f"
+fi
+
 selinux_status=$(getenforce)
 if [ "$selinux_status" != "Disabled" ]; then
        # bug number:
@@ -77,11 +82,16 @@ fi
 
 if [ "$mds1_FSTYPE" = "zfs" ]; then
        # bug number for skipped test:
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  "
+       ALWAYS_EXCEPT+="              "
        #                                               13    (min)"
        [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
 fi
 
+if [ "$ost1_FSTYPE" = "zfs" ]; then
+       # bug number for skipped test:  LU-1941  LU-1941  LU-1941  LU-1941
+       ALWAYS_EXCEPT+="                130a 130b 130c 130d 130e 130f 130g"
+fi
+
 # Get the SLES distro version
 #
 # Returns a version string that should only be used in comparing
@@ -3347,6 +3357,21 @@ test_31p() {
 }
 run_test 31p "remove of open striped directory"
 
+test_31q() {
+       [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
+
+       $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
+       index=$($LFS getdirstripe -i $DIR/$tdir)
+       [ $index -eq 3 ] || error "first stripe index $index != 3"
+       index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
+       [ $index -eq 1 ] || error "second stripe index $index != 1"
+
+       # when "-c <stripe_count>" is set, the number of MDTs specified after
+       # "-i" should equal to the stripe count
+       $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
+}
+run_test 31q "create striped directory on specific MDTs"
+
 cleanup_test32_mount() {
        local rc=0
        trap 0
@@ -12633,38 +12658,30 @@ test_130e() {
 
        local fm_file=$DIR/$tfile
        $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
-       [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
-               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
 
        NUM_BLKS=512
        EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
-       for ((i = 0; i < $NUM_BLKS; i++))
-       do
-               dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
+       for ((i = 0; i < $NUM_BLKS; i++)); do
+               dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
+                       conv=notrunc > /dev/null 2>&1
        done
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
        filefrag_op=$(filefrag -ve -k $fm_file |
                        sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
 
-       last_lun=$(echo $filefrag_op | cut -d: -f5 |
-               sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
+       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 |
-                       sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
+       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 [[ "$frag_lun" != "$last_lun" ]]; then
                        if (( tot_len != $EXPECTED_LEN )); then
                                cleanup_130
-                               error "FIEMAP on $fm_file failed; returned " \
-                               "len $tot_len for OST $last_lun instead " \
-                               "of $EXPECTED_LEN"
-                               return
+                               error "OST$last_lun $tot_len != $EXPECTED_LEN"
                        else
                                (( num_luns += 1 ))
                                tot_len=0
@@ -12675,13 +12692,9 @@ test_130e() {
        done
        if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
                cleanup_130
-               error "FIEMAP on $fm_file failed; returned wrong number " \
-                       "of luns or wrong len for OST $last_lun"
-               return
+               error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
        fi
 
-       cleanup_130
-
        echo "FIEMAP with continuation calls succeeded"
 }
 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
@@ -12698,14 +12711,38 @@ test_130f() {
        filefrag_extents=$(filefrag -vek $fm_file |
                           awk '/extents? found/ { print $2 }')
        if [[ "$filefrag_extents" != "0" ]]; then
-               error "FIEMAP on $fm_file failed; " \
-                     "returned $filefrag_extents expected 0"
+               error "$fm_file: filefrag_extents=$filefrag_extents != 0"
        fi
 
        rm -f $fm_file
 }
 run_test 130f "FIEMAP (unstriped file)"
 
+test_130g() {
+       local file=$DIR/$tfile
+       local nr=$((OSTCOUNT * 100))
+
+       $LFS setstripe -C $nr $file ||
+               error "failed to setstripe -C $nr $file"
+
+       dd if=/dev/zero of=$file count=$nr bs=1M
+       sync
+       nr=$($LFS getstripe -c $file)
+
+       local extents=$(filefrag -v $file |
+                       sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
+
+       echo "filefrag list $extents extents in file with stripecount $nr"
+       if (( extents < nr )); then
+               $LFS getstripe $file
+               filefrag -v $file
+               error "filefrag printed $extents < $nr extents"
+       fi
+
+       rm -f $file
+}
+run_test 130g "FIEMAP (overstripe file)"
+
 # Test for writev/readv
 test_131a() {
        rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
@@ -13413,17 +13450,33 @@ test_150c() {
        [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
                skip "Need OST version at least 2.13.53"
 
-       $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
-       fallocate -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
+       $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
+       fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
        sync; sync_all_data
        cancel_lru_locks $OSC
        sleep 5
-       bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
+       bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
        want=$((OSTCOUNT * 1048576))
 
        # Must allocate all requested space, not more than 5% extra
        (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
                error "bytes $bytes is not $want"
+
+       rm -f $DIR/$tfile
+       # verify fallocate on PFL file
+       $LFS setstripe -E1M -c1 -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
+               error "Create $DIR/$tfile failed"
+       fallocate -l $((1048576 * 1024)) $DIR/$tfile ||
+                       error "fallocate failed"
+       sync; sync_all_data
+       cancel_lru_locks $OSC
+       sleep 5
+       bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
+       want=$((1024 * 1048576))
+
+       # Must allocate all requested space, not more than 5% extra
+       (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
+               error "bytes $bytes is not $want"
 }
 run_test 150c "Verify fallocate Size and Blocks"
 
@@ -23925,7 +23978,10 @@ test_430b() {
        [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
        printf "Seeking data from 1000000 ... "
        lseek_test -d 1000000 $file && error "lseek should fail"
-       # full first component, non-inited second one
+       rm $file
+
+       # full component followed by non-inited one
+       $LFS setstripe -E 1M -c2 -E eof $file
        dd if=/dev/urandom of=$file bs=1M count=1
        printf "Seeking hole from 1000000 ... "
        offset=$(lseek_test -l 1000000 $file)
@@ -23936,7 +23992,6 @@ test_430b() {
        # init second component and truncate back
        echo "123" >> $file
        $TRUNCATE $file 1048576
-       ls -lia $file
        printf "Seeking hole from 1000000 ... "
        offset=$(lseek_test -l 1000000 $file)
        echo $offset
@@ -25105,8 +25160,18 @@ test_820() {
        # open intent should update default EA size
        # see mdc_update_max_ea_from_body()
        # notice this is the very first RPC to MDS2
-       cp /etc/services $DIR/$tdir/mds2 ||
-               error "Failed to copy files to mds$n"
+       out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
+       ret=$?
+       echo $out
+       # With SSK, this situation can lead to -EPERM being returned.
+       # In that case, simply retry.
+       if [ $ret -ne 0 ] && $SHARED_KEY; then
+               if echo "$out" | grep -q "not permitted"; then
+                       cp /etc/services $DIR/$tdir/mds2
+                       ret=$?
+               fi
+       fi
+       [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
 }
 run_test 820 "update max EA from open intent"