/tests/zfs-tests/tests/functional/refreserv/refreserv_raidz.ksh

https://github.com/adilger/zfs · Korn Shell · 135 lines · 68 code · 22 blank · 45 comment · 9 complexity · 9239d0967f44e242bec027fa625aa035 MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright 2019 Joyent, Inc.
  14. #
  15. . $STF_SUITE/include/libtest.shlib
  16. . $STF_SUITE/tests/functional/refreserv/refreserv.cfg
  17. #
  18. # DESCRIPTION:
  19. # raidz refreservation=auto accounts for extra parity and skip blocks
  20. #
  21. # STRATEGY:
  22. # 1. Create a pool with a single raidz vdev
  23. # 2. For each block size [512b, 1k, 128k] or [4k, 8k, 128k]
  24. # - create a volume
  25. # - fully overwrite it
  26. # - verify that referenced is less than or equal to reservation
  27. # - destroy the volume
  28. # 3. Destroy the pool
  29. # 4. Recreate the pool with one more disk in the vdev, then repeat steps
  30. # 2 and 3.
  31. # 5. Repeat all steps above for raidz2 and raidz3.
  32. #
  33. # NOTES:
  34. # 1. This test will use up to 14 disks but can cover the key concepts with
  35. # 5 disks.
  36. # 2. If the disks are a mixture of 4Kn and 512n/512e, failures are likely.
  37. #
  38. verify_runnable "global"
  39. typeset -a alldisks=($DISKS)
  40. # The larger the volsize, the better zvol_volsize_to_reservation() is at
  41. # guessing the right number. At 10M on ashift=12, the estimate may be over 26%
  42. # too high.
  43. volsize=100
  44. function cleanup
  45. {
  46. default_cleanup_noexit
  47. default_setup_noexit "${alldisks[0]}"
  48. }
  49. log_assert "raidz refreservation=auto accounts for extra parity and skip blocks"
  50. log_onexit cleanup
  51. poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
  52. # Testing tiny block sizes on ashift=12 pools causes so much size inflation
  53. # that small test disks may fill before creating small volumes. However,
  54. # testing 512b and 1K blocks on ashift=9 pools is an ok approximation for
  55. # testing the problems that arise from 4K and 8K blocks on ashift=12 pools.
  56. if is_freebsd; then
  57. bps=$(diskinfo -v ${alldisks[0]} | awk '/sectorsize/ { print $1 }')
  58. elif is_linux; then
  59. bps=$(lsblk -nrdo min-io /dev/${alldisks[0]})
  60. fi
  61. log_must test "$bps" -eq 512 -o "$bps" -eq 4096
  62. case "$bps" in
  63. 512)
  64. allshifts=(9 10 17)
  65. maxpct=151
  66. ;;
  67. 4096)
  68. allshifts=(12 13 17)
  69. maxpct=110
  70. ;;
  71. *)
  72. log_fail "bytes/sector: $bps != (512|4096)"
  73. ;;
  74. esac
  75. log_note "Testing in ashift=${allshifts[0]} mode"
  76. # This loop handles all iterations of steps 1 through 4 described in strategy
  77. # comment above,
  78. for parity in 1 2 3; do
  79. raid=raidz$parity
  80. # Ensure we hit scenarios with and without skip blocks
  81. for ndisks in $((parity * 2)) $((parity * 2 + 1)); do
  82. typeset -a disks=(${alldisks[0..$((ndisks - 1))]})
  83. if (( ${#disks[@]} < ndisks )); then
  84. log_note "Too few disks to test $raid-$ndisks"
  85. continue
  86. fi
  87. log_must zpool create "$TESTPOOL" "$raid" "${disks[@]}"
  88. for bits in "${allshifts[@]}"; do
  89. vbs=$((1 << bits))
  90. log_note "Testing $raid-$ndisks volblocksize=$vbs"
  91. vol=$TESTPOOL/$TESTVOL
  92. log_must zfs create -V ${volsize}m \
  93. -o volblocksize=$vbs "$vol"
  94. block_device_wait "/dev/zvol/$vol"
  95. log_must dd if=/dev/zero of=/dev/zvol/$vol \
  96. bs=1024k count=$volsize
  97. sync
  98. ref=$(zfs get -Hpo value referenced "$vol")
  99. refres=$(zfs get -Hpo value refreservation "$vol")
  100. log_must test -n "$ref"
  101. log_must test -n "$refres"
  102. typeset -F2 deltapct=$((refres * 100.0 / ref))
  103. log_note "$raid-$ndisks refreservation $refres" \
  104. "is $deltapct% of reservation $res"
  105. log_must test "$ref" -le "$refres"
  106. log_must test "$deltapct" -le $maxpct
  107. log_must_busy zfs destroy "$vol"
  108. block_device_wait
  109. done
  110. log_must_busy zpool destroy "$TESTPOOL"
  111. done
  112. done
  113. log_pass "raidz refreservation=auto accounts for extra parity and skip blocks"