PageRenderTime 25ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 82 lines | 31 code | 13 blank | 38 comment | 7 complexity | 2faa01f0f31de85edccc34876ee903f1 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright (c) 2016 by Lawrence Livermore National Security, LLC.
  24. # Use is subject to license terms.
  25. #
  26. . $STF_SUITE/include/libtest.shlib
  27. #
  28. # DESCRIPTION:
  29. # Verify that the dnode sizes of newly created files are consistent
  30. # with the dnodesize dataset property.
  31. #
  32. # STRATEGY:
  33. # 1. Create a file system
  34. # 2. Set dnodesize to a legal literal value
  35. # 3. Create a file
  36. # 4. Repeat 2-3 for all legal literal values of dnodesize values
  37. # 5. Unmount the file system
  38. # 6. Use zdb to check expected dnode sizes
  39. #
  40. TEST_FS=$TESTPOOL/large_dnode
  41. verify_runnable "both"
  42. function cleanup
  43. {
  44. datasetexists $TEST_FS && log_must zfs destroy $TEST_FS
  45. }
  46. log_onexit cleanup
  47. log_assert "dnode sizes are consistent with dnodesize dataset property"
  48. log_must zfs create $TEST_FS
  49. set -A dnsizes "512" "1k" "2k" "4k" "8k" "16k"
  50. set -A inodes
  51. for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
  52. size=${dnsizes[$i]}
  53. if [[ $size == "512" ]] ; then
  54. size="legacy"
  55. fi
  56. file=/$TEST_FS/file.$size
  57. log_must zfs set dnsize=$size $TEST_FS
  58. touch $file
  59. inodes[$i]=$(ls -li $file | awk '{print $1}')
  60. done
  61. log_must zfs umount $TEST_FS
  62. for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
  63. dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} |
  64. awk '/ZFS plain file/ {print $6}' | tr K k)
  65. if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then
  66. log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})"
  67. fi
  68. done
  69. log_pass "dnode sizes are consistent with dnodesize dataset property"