/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh

https://github.com/adilger/zfs · Korn Shell · 103 lines · 48 code · 22 blank · 33 comment · 1 complexity · c2fc2836bf782127e5608211e6129da3 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 The FreeBSD Foundation [1]
  18. #
  19. # [1] Portions of this software were developed by Allan Jude
  20. # under sponsorship from the FreeBSD Foundation.
  21. . $STF_SUITE/include/libtest.shlib
  22. export SIZE=1G
  23. export VDIR=$TESTDIR/disk.persist_l2arc
  24. export VDEV="$VDIR/a"
  25. export VDEV_CACHE="$VDIR/b"
  26. export PASSPHRASE="password"
  27. # fio options
  28. export DIRECTORY=/$TESTPOOL-l2arc/encrypted
  29. export NUMJOBS=4
  30. export RUNTIME=30
  31. export PERF_RANDSEED=1234
  32. export PERF_COMPPERCENT=66
  33. export PERF_COMPCHUNK=0
  34. export BLOCKSIZE=128K
  35. export SYNC_TYPE=0
  36. export DIRECT=1
  37. #
  38. # DESCRIPTION:
  39. # System with compressed_arc disabled succeeds at reading from L2ARC
  40. #
  41. # STRATEGY:
  42. # 1. Enable compressed_arc.
  43. # 2. Create pool with a cache device, encryption, and compression enabled.
  44. # 3. Read the number of L2ARC checksum failures.
  45. # 4. Create a random file in that pool and random read for 30 sec.
  46. # 5. Read the number of L2ARC checksum failures.
  47. #
  48. verify_runnable "global"
  49. log_assert "L2ARC with encryption enabled succeeds."
  50. origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED)
  51. function cleanup
  52. {
  53. if poolexists $TESTPOOL-l2arc ; then
  54. destroy_pool $TESTPOOL-l2arc
  55. fi
  56. log_must set_tunable64 COMPRESSED_ARC_ENABLED $origin_carc_setting
  57. }
  58. log_onexit cleanup
  59. # Enable Compressed ARC so that in-ARC and on-disk will match
  60. log_must set_tunable64 COMPRESSED_ARC_ENABLED 1
  61. log_must rm -rf $VDIR
  62. log_must mkdir -p $VDIR
  63. log_must mkfile $SIZE $VDEV
  64. typeset fill_mb=800
  65. typeset cache_sz=$(( floor($fill_mb / 2) ))
  66. export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
  67. log_must truncate -s ${cache_sz}M $VDEV_CACHE
  68. log_must zpool create -O compression=zstd -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE
  69. log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
  70. "-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
  71. "$TESTPOOL-l2arc/encrypted"
  72. l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
  73. log_must fio $FIO_SCRIPTS/mkfiles.fio
  74. log_must fio $FIO_SCRIPTS/random_reads.fio
  75. l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
  76. log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
  77. "$l2_cksum_bad_end"
  78. log_must test $(( $l2_cksum_bad_end - $l2_cksum_bad_start )) -eq 0
  79. log_must zpool destroy -f $TESTPOOL-l2arc
  80. log_pass "L2ARC with encryption and compressed_arc enabled does not result in"\
  81. "checksum errors."