Whamcloud - gitweb
LU-11518 ldlm: control lru_size for extent lock
[fs/lustre-release.git] / lustre / tests / sanity.sh
index c3ae827..b6363ae 100755 (executable)
@@ -7717,7 +7717,7 @@ test_60g() {
 
                do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
                        > /dev/null
-               usleep 100
+               sleep 0.01
        done
 
        kill -9 $pid
@@ -8630,36 +8630,45 @@ test_74c() {
 }
 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
 
-num_inodes() {
-       [ -f /sys/kernel/slab/lustre_inode_cache/shrink ] &&
-               echo 1 > /sys/kernel/slab/lustre_inode_cache/shrink
-       awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
+slab_lic=/sys/kernel/slab/lustre_inode_cache
+num_objects() {
+       [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
+       [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
+               awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
 }
 
-test_76() { # Now for bug 20433, added originally in bug 1443
+test_76() { # Now for b=20433, added originally in b=1443
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        cancel_lru_locks osc
+       # there may be some slab objects cached per core
        local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
-       local before=$(num_inodes)
+       local before=$(num_objects)
        local count=$((512 * cpus))
-       [ "$SLOW" = "no" ] && count=$((64 * cpus))
+       [ "$SLOW" = "no" ] && count=$((128 * cpus))
+       local margin=$((count / 10))
+       if [[ -f $slab_lic/aliases ]]; then
+               local aliases=$(cat $slab_lic/aliases)
+               (( aliases > 0 )) && margin=$((margin * aliases))
+       fi
 
-       echo "before inodes: $before"
+       echo "before slab objects: $before"
        for i in $(seq $count); do
                touch $DIR/$tfile
                rm -f $DIR/$tfile
        done
        cancel_lru_locks osc
-       local after=$(num_inodes)
-       echo "after inodes: $after"
-       while (( after > before + 8 * ${cpus:-1} )); do
+       local after=$(num_objects)
+       echo "created: $count, after slab objects: $after"
+       # shared slab counts are not very accurate, allow significant margin
+       # the main goal is that the cache growth is not permanently > $count
+       while (( after > before + margin )); do
                sleep 1
-               after=$(num_inodes)
+               after=$(num_objects)
                wait=$((wait + 1))
-               (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
-               if (( wait > 30 )); then
-                       error "inode slab grew from $before to $after"
+               (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
+               if (( wait > 60 )); then
+                       error "inode slab grew from $before+$margin to $after"
                fi
        done
 }
@@ -15778,7 +15787,8 @@ obdecho_test() {
 test_180a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
-       if ! module_loaded obdecho; then
+       if ! [ -d /sys/fs/lustre/echo_client ] &&
+          ! module_loaded obdecho; then
                load_module obdecho/obdecho &&
                        stack_trap "rmmod obdecho" EXIT ||
                        error "unable to load obdecho on client"
@@ -22038,6 +22048,11 @@ test_398d() { #  LU-13846
        aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
 
        diff $DIR/$tfile $aio_file || "file diff after aiocp"
+
+       # make sure we don't crash and fail properly
+       aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
+               error "aio not aligned with PAGE SIZE should fail"
+
        rm -rf $DIR/$tfile $aio_file
 }
 run_test 398d "run aiocp to verify block size > stripe size"
@@ -23356,6 +23371,41 @@ test_424() {
 }
 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
 
+test_425() {
+       test_mkdir -c -1 $DIR/$tdir
+       $LFS setstripe -c -1 $DIR/$tdir
+
+       lru_resize_disable "" 100
+       stack_trap "lru_resize_enable" EXIT
+
+       sleep 5
+
+       for i in $(seq $((MDSCOUNT * 125))); do
+               local t=$DIR/$tdir/$tfile_$i
+
+               dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
+                       error_noexit "Create file $t"
+       done
+       stack_trap "rm -rf $DIR/$tdir" EXIT
+
+       for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
+               local lru_size=$($LCTL get_param -n $oscparam.lru_size)
+               local lock_count=$($LCTL get_param -n $oscparam.lock_count)
+
+               [ $lock_count -le $lru_size ] ||
+                       error "osc lock count $lock_count > lru size $lru_size"
+       done
+
+       for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
+               local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
+               local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
+
+               [ $lock_count -le $lru_size ] ||
+                       error "mdc lock count $lock_count > lru size $lru_size"
+       done
+}
+run_test 425 "lock count should not exceed lru size"
+
 prep_801() {
        [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
        [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&