Whamcloud - gitweb
LU-14143 lov: fix SEEK_HOLE calcs at component end
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 01229b1..66c2903 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:
@@ -60,11 +65,6 @@ if [[ $(uname -m) = aarch64 ]]; then
        ALWAYS_EXCEPT+=" 400a     400b"
 fi
 
-# skip splice tests on kernels >= 4.15.0 until they are fixed
-if [ $LINUX_VERSION_CODE -ge $(version_code 4.15.0) ]; then
-       # bug number:   LU-14045
-       ALWAYS_EXCEPT+=" 426"
-fi
 # skip nfs tests on kernels >= 4.12.0 until they are fixed
 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
        # bug number:   LU-12661
@@ -3352,6 +3352,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
@@ -8394,7 +8409,11 @@ test_65n() {
 
        local file2_stripe_size=$($LFS getstripe -S $file2)
        [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
+       {
+               echo "file2_stripe_size: '$file2_stripe_size'"
+               echo "new_def_stripe_size: '$new_def_stripe_size'"
                error "$file2 didn't inherit stripe size $new_def_stripe_size"
+       }
 
        local dir3=$MOUNT/$tdir-3
        mkdir $dir3 || error "mkdir $dir3 failed"
@@ -8404,7 +8423,11 @@ test_65n() {
        local dir3_layout=$(get_layout_param $dir3)
        local root_dir_layout=$(get_layout_param $MOUNT)
        [[ "$dir3_layout" = "$root_dir_layout" ]] ||
+       {
+               echo "dir3_layout: '$dir3_layout'"
+               echo "root_dir_layout: '$root_dir_layout'"
                error "$dir3 should show the default layout from $MOUNT"
+       }
 
        # set OST pool on root directory
        local pool=$TESTNAME
@@ -8422,7 +8445,7 @@ test_65n() {
 
        local file3_pool=$($LFS getstripe -p $file3)
        [[ "$file3_pool" = "$pool" ]] ||
-               error "$file3 didn't inherit OST pool $pool"
+               error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
 
        local dir4=$MOUNT/$tdir-4
        mkdir $dir4 || error "mkdir $dir4 failed"
@@ -8433,7 +8456,11 @@ test_65n() {
        echo "$LFS getstripe -d $MOUNT"
        $LFS getstripe -d $MOUNT
        [[ "$dir4_layout" = "$root_dir_layout" ]] ||
+       {
+               echo "dir4_layout: '$dir4_layout'"
+               echo "root_dir_layout: '$root_dir_layout'"
                error "$dir4 should show the default layout from $MOUNT"
+       }
 
        # new file created in $dir4 should inherit the pool from
        # the filesystem default
@@ -8442,7 +8469,7 @@ test_65n() {
 
        local file4_pool=$($LFS getstripe -p $file4)
        [[ "$file4_pool" = "$pool" ]] ||
-               error "$file4 didn't inherit OST pool $pool"
+               error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
 
        # new subdirectory under non-root directory should inherit
        # the default layout from its parent directory
@@ -8455,7 +8482,11 @@ test_65n() {
        dir4_layout=$(get_layout_param $dir4)
        local dir5_layout=$(get_layout_param $dir5)
        [[ "$dir4_layout" = "$dir5_layout" ]] ||
+       {
+               echo "dir4_layout: '$dir4_layout'"
+               echo "dir5_layout: '$dir5_layout'"
                error "$dir5 should inherit the default layout from $dir4"
+       }
 
        # though subdir under ROOT doesn't inherit default layout, but
        # its sub dir/file should be created with default layout.
@@ -15179,8 +15210,7 @@ test_160l() {
        compare_mtime_changelog $DIR/$tdir/$tfile
 
        # Test CL_MTIME during close
-       dd if=/dev/urandom of=$DIR/$tdir/${tfile}_2 bs=1M count=64 ||
-               error "cannot create file $DIR/$tdir/${tfile}_2"
+       $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
        compare_mtime_changelog $DIR/$tdir/${tfile}_2
 }
 run_test 160l "Verify that MTIME changelog records contain the parent FID"
@@ -15559,8 +15589,8 @@ test_165a() {
        (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
                skip "OFD access log unsupported"
 
-       do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
        setup_165
+       do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
        sleep 5
 
        do_facet ost1 ofd_access_log_reader --list
@@ -15596,13 +15626,15 @@ test_165b() {
                skip "OFD access log unsupported"
 
        setup_165
+       do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
+       sleep 5
+
+       do_facet ost1 ofd_access_log_reader --list
 
        lfs setstripe -c 1 -i 0 "${file}"
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
                error "cannot create '${file}'"
-       do_facet ost1 ofd_access_log_reader --list
 
-       do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
        sleep 5
        do_facet ost1 killall -TERM ofd_access_log_reader
        wait
@@ -15638,9 +15670,12 @@ test_165b() {
        fi
 
        do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
+       sleep 5
+
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
                error "cannot read '${file}'"
        sleep 5
+
        do_facet ost1 killall -TERM ofd_access_log_reader
        wait
        rc=$?
@@ -15672,6 +15707,7 @@ test_165b() {
 run_test 165b "ofd access log entries are produced and consumed"
 
 test_165c() {
+       local trace="/tmp/${tfile}.trace"
        local file="${DIR}/${tdir}/${tfile}"
 
        (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
@@ -15680,6 +15716,8 @@ test_165c() {
        test_mkdir "${DIR}/${tdir}"
 
        setup_165
+       do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
+       sleep 5
 
        lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
 
@@ -15690,34 +15728,53 @@ test_165c() {
        done
 
        sync
-       do_facet ost1 ofd_access_log_reader --list
+
+       do_facet ost1 killall -TERM ofd_access_log_reader
+       wait
+       rc=$?
+       if ((rc != 0)); then
+               error "ofd_access_log_reader exited with rc = '${rc}'"
+       fi
+
        unlinkmany  "${file}-%d" 128
 }
 run_test 165c "full ofd access logs do not block IOs"
 
-oal_peek_entry_count() {
-       do_facet ost1 ofd_access_log_reader --list |
-               awk '$1 == "_entry_count:" { print $2; }'
+oal_get_read_count() {
+       local stats="$1"
+
+       # STATS lustre-OST0001 alr_read_count 1
+
+       do_facet ost1 cat "${stats}" |
+       awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
+            END { print count; }'
 }
 
-oal_expect_entry_count() {
-       local entry_count=$(oal_peek_entry_count)
-       local expect="$1"
+oal_expect_read_count() {
+       local stats="$1"
+       local count
+       local expect="$2"
+
+       # Ask ofd_access_log_reader to write stats.
+       do_facet ost1 killall -USR1 ofd_access_log_reader
 
-       if ((entry_count == expect)); then
+       # Allow some time for things to happen.
+       sleep 1
+
+       count=$(oal_get_read_count "${stats}")
+       if ((count == expect)); then
                return 0
        fi
 
-       error_noexit "bad entry count, got ${entry_count}, expected ${expect}"
-       do_facet ost1 ofd_access_log_reader --list >&2
+       error_noexit "bad read count, got ${count}, expected ${expect}"
+       do_facet ost1 cat "${stats}" >&2
        exit 1
 }
 
 test_165d() {
-       local trace="/tmp/${tfile}.trace"
+       local stats="/tmp/${tfile}.stats"
        local file="${DIR}/${tdir}/${tfile}"
        local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
-       local entry_count
 
        (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
                skip "OFD access log unsupported"
@@ -15725,46 +15782,117 @@ test_165d() {
        test_mkdir "${DIR}/${tdir}"
 
        setup_165
+       do_facet ost1 ofd_access_log_reader --stats="${stats}" &
+       sleep 5
+
        lfs setstripe -c 1 -i 0 "${file}"
 
        do_facet ost1 lctl set_param "${param}=rw"
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
                error "cannot create '${file}'"
-       oal_expect_entry_count 1
+       oal_expect_read_count "${stats}" 1
 
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
                error "cannot read '${file}'"
-       oal_expect_entry_count 2
+       oal_expect_read_count "${stats}" 2
 
        do_facet ost1 lctl set_param "${param}=r"
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
                error "cannot create '${file}'"
-       oal_expect_entry_count 2
+       oal_expect_read_count "${stats}" 2
 
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
                error "cannot read '${file}'"
-       oal_expect_entry_count 3
+       oal_expect_read_count "${stats}" 3
 
        do_facet ost1 lctl set_param "${param}=w"
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
                error "cannot create '${file}'"
-       oal_expect_entry_count 4
+       oal_expect_read_count "${stats}" 4
 
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
                error "cannot read '${file}'"
-       oal_expect_entry_count 4
+       oal_expect_read_count "${stats}" 4
 
        do_facet ost1 lctl set_param "${param}=0"
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
                error "cannot create '${file}'"
-       oal_expect_entry_count 4
+       oal_expect_read_count "${stats}" 4
 
        $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
                error "cannot read '${file}'"
-       oal_expect_entry_count 4
+       oal_expect_read_count "${stats}" 4
+
+       do_facet ost1 killall -TERM ofd_access_log_reader
+       wait
+       rc=$?
+       if ((rc != 0)); then
+               error "ofd_access_log_reader exited with rc = '${rc}'"
+       fi
 }
 run_test 165d "ofd_access_log mask works"
 
+test_165e() {
+       local stats="/tmp/${tfile}.stats"
+       local file0="${DIR}/${tdir}-0/${tfile}"
+       local file1="${DIR}/${tdir}-1/${tfile}"
+
+       (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
+               skip "OFD access log unsupported"
+
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+
+       test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
+       test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
+
+       lfs setstripe -c 1 -i 0 "${file0}"
+       lfs setstripe -c 1 -i 0 "${file1}"
+
+       setup_165
+       do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
+       sleep 5
+
+       $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
+               error "cannot create '${file0}'"
+       sync
+       oal_expect_read_count "${stats}" 0
+
+       $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
+               error "cannot create '${file1}'"
+       sync
+       oal_expect_read_count "${stats}" 1
+
+       do_facet ost1 killall -TERM ofd_access_log_reader
+       wait
+       rc=$?
+       if ((rc != 0)); then
+               error "ofd_access_log_reader exited with rc = '${rc}'"
+       fi
+}
+run_test 165e "ofd_access_log MDT index filter works"
+
+test_165f() {
+       local trace="/tmp/${tfile}.trace"
+       local rc
+       local count
+
+       setup_165
+       do_facet ost1 timeout 60 ofd_access_log_reader \
+               --exit-on-close --debug=- --trace=- > "${trace}" &
+       sleep 5
+       stop ost1
+
+       wait
+       rc=$?
+
+       if ((rc != 0)); then
+               error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
+               cat "${trace}"
+               exit 1
+       fi
+}
+run_test 165f "ofd_access_log_reader --exit-on-close works"
+
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
@@ -21654,6 +21782,56 @@ test_300r() {
 }
 run_test 300r "test -1 striped directory"
 
+test_300s_helper() {
+       local count=$1
+
+       local stripe_dir=$DIR/$tdir/striped_dir.$count
+
+       $LFS mkdir -c $count $stripe_dir ||
+               error "lfs mkdir -c error"
+
+       $LFS getdirstripe $stripe_dir ||
+               error "lfs getdirstripe fails"
+
+       local stripe_count
+       stripe_count=$($LFS getdirstripe $stripe_dir |
+                     awk '/lmv_stripe_count:/ { print $2 }')
+
+       [ $count -ne $stripe_count ] &&
+               error_noexit "bad stripe count $stripe_count expected $count"
+
+       local dupe_stripes
+       dupe_stripes=$($LFS getdirstripe $stripe_dir |
+               awk '/0x/ {count[$1] += 1}; END {
+                       for (idx in count) {
+                               if (count[idx]>1) {
+                                       print "index " idx " count " count[idx]
+                               }
+                       }
+               }')
+
+       if [[ -n "$dupe_stripes" ]] ; then
+               lfs getdirstripe $stripe_dir
+               error_noexit "Dupe MDT above: $dupe_stripes "
+       fi
+
+       rm -rf $stripe_dir ||
+               error_noexit "unlink $stripe_dir fails"
+}
+
+test_300s() {
+       [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
+               skip "Need MDS version at least 2.7.55" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       for count in $(seq 2 $MDSCOUNT); do
+               test_300s_helper $count
+       done
+}
+run_test 300s "test lfs mkdir -c without -i"
+
+
 prepare_remote_file() {
        mkdir $DIR/$tdir/src_dir ||
                error "create remote source failed"
@@ -22212,6 +22390,13 @@ test_398d() { #  LU-13846
 }
 run_test 398d "run aiocp to verify block size > stripe size"
 
+test_398e() {
+       dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
+       touch $DIR/$tfile.new
+       dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
+}
+run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
+
 test_fake_rw() {
        local read_write=$1
        if [ "$read_write" = "write" ]; then
@@ -23760,7 +23945,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)
@@ -23771,7 +23959,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
@@ -24940,8 +25127,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"