test_stress_05.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
  4. ERR_CODE=0
  5. if ! _have_program fio; then
  6. exit "$UBLK_SKIP_CODE"
  7. fi
  8. run_io_and_remove()
  9. {
  10. local size=$1
  11. local dev_id
  12. local dev_pid
  13. shift 1
  14. dev_id=$(_add_ublk_dev "$@")
  15. _check_add_dev $TID $?
  16. [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)"
  17. fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \
  18. --rw=readwrite --iodepth=128 --size="${size}" --numjobs=4 \
  19. --runtime=40 --time_based > /dev/null 2>&1 &
  20. sleep 4
  21. dev_pid=$(_get_ublk_daemon_pid "$dev_id")
  22. kill -9 "$dev_pid"
  23. if ! __remove_ublk_dev_return "${dev_id}"; then
  24. echo "delete dev ${dev_id} failed"
  25. return 255
  26. fi
  27. }
  28. ublk_io_and_remove()
  29. {
  30. run_io_and_remove "$@"
  31. ERR_CODE=$?
  32. if [ ${ERR_CODE} -ne 0 ]; then
  33. echo "$TID failure: $*"
  34. _show_result $TID $ERR_CODE
  35. fi
  36. }
  37. _prep_test "stress" "run IO and remove device with recovery enabled"
  38. _create_backfile 0 256M
  39. _create_backfile 1 256M
  40. for reissue in $(seq 0 1); do
  41. ublk_io_and_remove 8G -t null -q 4 -g -r 1 -i "$reissue" &
  42. ublk_io_and_remove 256M -t loop -q 4 -g -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" &
  43. wait
  44. done
  45. if _have_feature "ZERO_COPY"; then
  46. for reissue in $(seq 0 1); do
  47. ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" &
  48. ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
  49. wait
  50. done
  51. fi
  52. if _have_feature "AUTO_BUF_REG"; then
  53. for reissue in $(seq 0 1); do
  54. ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" &
  55. ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
  56. ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &
  57. wait
  58. done
  59. fi
  60. if _have_feature "PER_IO_DAEMON"; then
  61. ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" &
  62. ublk_io_and_remove 256M -t loop -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" &
  63. ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" &
  64. fi
  65. wait
  66. _cleanup_test "stress"
  67. _show_result $TID $ERR_CODE