/tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_006_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 98 lines · 40 code · 23 blank · 35 comment · 1 complexity · 8582296da4cf21e8da5dadc306e13b11 MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # This file and its contents are supplied under the terms of the
  6. # Common Development and Distribution License ("CDDL"), version 1.0.
  7. # You may only use this file in accordance with the terms of version
  8. # 1.0 of the CDDL.
  9. #
  10. # A full copy of the text of the CDDL should have accompanied this
  11. # source. A copy of the CDDL is also available via the Internet at
  12. # http://www.illumos.org/license/CDDL.
  13. #
  14. # CDDL HEADER END
  15. #
  16. #
  17. # Copyright (c) 2020, George Amanakis. All rights reserved.
  18. #
  19. . $STF_SUITE/include/libtest.shlib
  20. . $STF_SUITE/tests/functional/persist_l2arc/persist_l2arc.cfg
  21. #
  22. # DESCRIPTION:
  23. # Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not
  24. # present.
  25. #
  26. # STRATEGY:
  27. # 1. Create pool with a cache device.
  28. # 2. Create a random file in that pool and random read for 30 sec.
  29. # 3. Read the amount of log blocks written from the header of the
  30. # L2ARC device.
  31. # 4. Offline the L2ARC device and export pool.
  32. # 5. Import pool and online the L2ARC device.
  33. # 6. Read the amount of log blocks rebuilt in arcstats and compare to
  34. # (3).
  35. # 7. Check if the labels of the L2ARC device are intact.
  36. #
  37. verify_runnable "global"
  38. log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present."
  39. function cleanup
  40. {
  41. if poolexists $TESTPOOL ; then
  42. destroy_pool $TESTPOOL
  43. fi
  44. log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch
  45. log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE \
  46. $rebuild_blocks_min_l2size
  47. }
  48. log_onexit cleanup
  49. # L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches
  50. typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH)
  51. typeset rebuild_blocks_min_l2size=$(get_tunable L2ARC_REBUILD_BLOCKS_MIN_L2SIZE)
  52. log_must set_tunable32 L2ARC_NOPREFETCH 0
  53. log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE 0
  54. typeset fill_mb=800
  55. typeset cache_sz=$(( floor($fill_mb / 2) ))
  56. export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
  57. log_must truncate -s ${cache_sz}M $VDEV_CACHE
  58. log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE
  59. log_must fio $FIO_SCRIPTS/mkfiles.fio
  60. log_must fio $FIO_SCRIPTS/random_reads.fio
  61. log_must zpool offline $TESTPOOL $VDEV_CACHE
  62. log_must zpool export $TESTPOOL
  63. sleep 5
  64. typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
  65. typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \
  66. awk '{print $2}')
  67. log_must zpool import -d $VDIR $TESTPOOL
  68. log_must zpool online $TESTPOOL $VDEV_CACHE
  69. sleep 5
  70. typeset l2_rebuild_log_blk_end=$(get_arcstat l2_rebuild_log_blks)
  71. log_must test $l2_dh_log_blk -eq $(( $l2_rebuild_log_blk_end - $l2_rebuild_log_blk_start ))
  72. log_must test $l2_dh_log_blk -gt 0
  73. log_must zdb -lq $VDEV_CACHE
  74. log_must zpool destroy -f $TESTPOOL
  75. log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present."