Whamcloud - gitweb
LU-5473 tests: sanity/51b Account for ZFS inode size
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 37ce91c..5a26c77 100755 (executable)
@@ -81,8 +81,8 @@ init_logging
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
        # bug number for skipped test: LU-4536 LU-1957
        ALWAYS_EXCEPT="$ALWAYS_EXCEPT  65ic    180"
-       #                                               4   13    (min)"
-       [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
+       #                                               13    (min)"
+       [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
 fi
 
 FAIL_ON_ERROR=false
@@ -4097,6 +4097,12 @@ test_51a() {     # was test_51
 }
 run_test 51a "special situations: split htree with empty entry =="
 
+cleanup_print_lfs_df () {
+       trap 0
+       $LFS df
+       $LFS df -i
+}
+
 test_51b() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        local dir=$DIR/$tdir
@@ -4118,10 +4124,12 @@ test_51b() {
 
        # need to check free space for the directories as well
        local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
-       numfree=$((blkfree / 4))
+       numfree=$(( blkfree / $(fs_inode_ksize) ))
        [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
                return
 
+       trap cleanup_print_lfsdf EXIT
+
        # create files
        createmany -d $dir/d $nrdirs ||
                error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
@@ -4133,6 +4141,9 @@ test_51b() {
        local left=100
        local delete=$((nrdirs - left))
 
+       $LFS df
+       $LFS df -i
+
        # for ldiskfs the nlink count should be 1, but this is OSD specific
        # and so this is listed for informational purposes only
        echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
@@ -4151,6 +4162,8 @@ test_51b() {
        local after=$(stat -c %h $dir)
        [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
                echo "nlink after: $after"
+
+       cleanup_print_lfs_df
 }
 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
 
@@ -12662,10 +12675,11 @@ test_224c() { # LU-6441
                error "conf_param timeout=5 failed"
 
        #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3   0x520
-       $LCTL set_param fail_loc=0x520
+       do_facet ost1 $LCTL set_param fail_loc=0x520
+       $LFS setstripe -c 1 -i 0 $DIR/$tfile
        dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
        sync
-       $LCTL set_param fail_loc=0
+       do_facet ost1 $LCTL set_param fail_loc=0
 
        set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
                error "conf_param at_max=$at_max failed"
@@ -13868,18 +13882,9 @@ test_247e() {
 run_test 247e "mount .. as fileset"
 
 test_248() {
-       local my_error=error
-
        local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
        [ -z "$fast_read_sav" ] && skip "no fast read support" && return
 
-       # This test case is time sensitive and Maloo uses KVM to run autotest.
-       # Therefore the complete time of I/O task is unreliable and depends on
-       # the workload on the host machine when the task is running.
-       local virt=$(running_in_vm)
-       [ -n "$virt" ] && echo "running in VM '$virt', ignore error" &&
-                 my_error="error_ignore env=$virt"
-
        # create a large file for fast read verification
        dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
 
@@ -13901,7 +13906,8 @@ test_248() {
 
        # verify that fast read is 4 times faster for cache read
        [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
-               $my_error "fast read was not 4 times faster: $t_fast vs $t_slow"
+               error_not_in_vm "fast read was not 4 times faster: " \
+                          "$t_fast vs $t_slow"
 
        echo "Test 2: verify the performance between big and small read"
        $LCTL set_param -n llite.*.fast_read=1
@@ -13918,7 +13924,7 @@ test_248() {
 
        # verify that big IO is not 4 times faster than small IO
        [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
-               $my_error "bigger IO is way too fast: $t_1k vs $t_1m"
+               error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
 
        $LCTL set_param -n llite.*.fast_read=$fast_read_sav
        rm -f $DIR/$tfile
@@ -14098,6 +14104,7 @@ ladvise_willread_performance()
        local repeat=10
        local average_cache=0
        local average_ladvise=0
+
        for ((i = 1; i <= $repeat; i++)); do
                echo "Iter $i/$repeat: reading without willread hint"
                cancel_lru_locks osc
@@ -14147,8 +14154,8 @@ ladvise_willread_performance()
 
        local lowest_speedup=$((average_cache / 2))
        [ $average_ladvise -gt $lowest_speedup ] ||
-               error "Speedup with willread is less than $lowest_speedup%,"\
-                       "got $average_ladvise%"
+               error_not_in_vm "Speedup with willread is less than " \
+                          "$lowest_speedup%, got $average_ladvise%"
        echo "Speedup with willread ladvise: $average_ladvise%"
        echo "Speedup with cache: $average_cache%"
 }
@@ -14232,6 +14239,71 @@ test_255a() {
 }
 run_test 255a "check 'lfs ladvise -a willread'"
 
+facet_meminfo() {
+       local facet=$1
+       local info=$2
+
+       do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
+}
+
+test_255b() {
+       lfs setstripe -c -1 -i 0 $DIR/$tfile
+
+       ladvise_no_type dontneed $DIR/$tfile &&
+               skip "dontneed ladvise is not supported" && return
+
+       ladvise_no_ioctl $DIR/$tfile &&
+               skip "ladvise ioctl is not supported" && return
+
+       [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
+               skip "lustre < 2.8.54 does not support ladvise" && return
+
+       [ "$(facet_fstype ost1)" = "zfs" ] &&
+               skip "zfs-osd does not support dontneed advice" && return
+
+       local size_mb=100
+       local size=$((size_mb * 1048576))
+       # In order to prevent disturbance of other processes, only check 3/4
+       # of the memory usage
+       local kibibytes=$((size_mb * 1024 * 3 / 4))
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
+               error "dd to $DIR/$tfile failed"
+
+       local total=$(facet_meminfo ost1 MemTotal)
+       echo "Total memory: $total KiB"
+
+       do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
+       local before_read=$(facet_meminfo ost1 Cached)
+       echo "Cache used before read: $before_read KiB"
+
+       lfs ladvise -a willread $DIR/$tfile ||
+               error "Ladvise willread failed"
+       local after_read=$(facet_meminfo ost1 Cached)
+       echo "Cache used after read: $after_read KiB"
+
+       lfs ladvise -a dontneed $DIR/$tfile ||
+               error "Ladvise dontneed again failed"
+       local no_read=$(facet_meminfo ost1 Cached)
+       echo "Cache used after dontneed ladvise: $no_read KiB"
+
+       if [ $total -lt $((before_read + kibibytes)) ]; then
+               echo "Memory is too small, abort checking"
+               return 0
+       fi
+
+       if [ $((before_read + kibibytes)) -gt $after_read ]; then
+               error "Ladvise willread should use more memory" \
+                       "than $kibibytes KiB"
+       fi
+
+       if [ $((no_read + kibibytes)) -gt $after_read ]; then
+               error "Ladvise dontneed should release more memory" \
+                       "than $kibibytes KiB"
+       fi
+}
+run_test 255b "check 'lfs ladvise -a dontneed'"
+
 test_256() {
        local cl_user
        local cat_sl
@@ -14296,6 +14368,29 @@ test_256() {
 }
 run_test 256 "Check llog delete for empty and not full state"
 
+test_257() {
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
+               skip "Need MDS version at least 2.8.55" && return
+
+       test_mkdir -p $DIR/$tdir
+
+       setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
+               error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
+       stat $DIR/$tdir
+
+#define OBD_FAIL_MDS_XATTR_REP                 0x161
+       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local facet=mds$((mdtidx + 1))
+       set_nodes_failloc $(facet_active_host $facet) 0x80000161
+       getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
+
+       stop $facet || error "stop MDS failed"
+       start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
+               error "start MDS fail"
+}
+run_test 257 "xattr locks are not lost"
+
 test_260() {
 #define OBD_FAIL_MDC_CLOSE               0x806
        $LCTL set_param fail_loc=0x80000806
@@ -15169,6 +15264,48 @@ test_312() { # LU-4856
 }
 run_test 312 "make sure ZFS adjusts its block size by write pattern"
 
+test_399() { # LU-7655 for OST fake write
+       # turn off debug for performance testing
+       local saved_debug=$($LCTL get_param -n debug)
+       $LCTL set_param debug=0
+
+       $SETSTRIPE -c 1 -i 0 $DIR/$tfile
+
+       # get ost1 size - lustre-OST0000
+       local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
+       local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
+       [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
+
+       local start_time=$(date +%s.%N)
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=$blocks oflag=sync ||
+               error "real dd writing error"
+       local duration=$(bc <<< "$(date +%s.%N) - $start_time")
+       rm -f $DIR/$tfile
+
+       # define OBD_FAIL_OST_FAKE_WRITE        0x238
+       do_facet ost1 $LCTL set_param fail_loc=0x238
+
+       local start_time=$(date +%s.%N)
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=$blocks oflag=sync ||
+               error "fake dd writing error"
+       local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
+
+       # verify file size
+       cancel_lru_locks osc
+       $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
+               error "$tfile size not $blocks MB"
+
+       do_facet ost1 $LCTL set_param fail_loc=0
+
+       echo "fake write $duration_fake vs. normal write $duration in seconds"
+       [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
+               error_not_in_vm "fake write is slower"
+
+       $LCTL set_param -n debug="$saved_debug"
+       rm -f $DIR/$tfile
+}
+run_test 399 "fake write should not be slower than normal write"
+
 test_400a() { # LU-1606, was conf-sanity test_74
        local extra_flags=''
        local out=$TMP/$tfile