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

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

http://github.com/zfsonlinux/zfs
Korn Shell | 114 lines | 54 code | 16 blank | 44 comment | 10 complexity | d7049f4cf9401cb48be4cf52df246351 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 2009 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/refreserv/refreserv.cfg
  31. #
  32. # DESCRIPTION:
  33. # Setting full size as refreservation, verify no snapshot can be created.
  34. #
  35. # STRATEGY:
  36. # 1. Setting full size as refreservation on pool
  37. # 2. Verify no snapshot can be created on this pool
  38. # 3. Setting full size as refreservation on filesystem
  39. # 4. Verify no snapshot can be created on it and its subfs
  40. #
  41. verify_runnable "both"
  42. function cleanup
  43. {
  44. if is_global_zone ; then
  45. log_must zfs set refreservation=none $TESTPOOL
  46. if datasetexists $TESTPOOL@snap ; then
  47. log_must zfs destroy -f $TESTPOOL@snap
  48. fi
  49. fi
  50. log_must zfs destroy -rf $TESTPOOL/$TESTFS
  51. log_must zfs create $TESTPOOL/$TESTFS
  52. log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  53. }
  54. # This function iteratively increases refreserv to its highest possible
  55. # value. Simply setting refreserv == quota can allow enough writes to
  56. # complete that the test fails.
  57. function max_refreserv
  58. {
  59. typeset ds=$1
  60. typeset -i incsize=131072
  61. typeset -i rr=$(get_prop available $ds)
  62. log_must zfs set refreserv=$rr $ds
  63. while :; do
  64. zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1
  65. if [[ $? == 0 ]]; then
  66. ((rr += incsize))
  67. continue
  68. else
  69. ((incsize /= 2))
  70. ((incsize == 0)) && break
  71. fi
  72. done
  73. }
  74. log_assert "Setting full size as refreservation, verify no snapshot " \
  75. "can be created."
  76. log_onexit cleanup
  77. log_must zfs create $TESTPOOL/$TESTFS/subfs
  78. typeset datasets
  79. if is_global_zone; then
  80. datasets="$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs"
  81. else
  82. datasets="$TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs"
  83. fi
  84. for ds in $datasets; do
  85. #
  86. # Verify refreservation on dataset
  87. #
  88. log_must zfs set quota=25M $ds
  89. max_refreserv $ds
  90. log_mustnot zfs snapshot $ds@snap
  91. if datasetexists $ds@snap ; then
  92. log_fail "ERROR: $ds@snap should not exists."
  93. fi
  94. log_must zfs set quota=none $ds
  95. log_must zfs set refreservation=none $ds
  96. done
  97. log_pass "Setting full size as refreservation, verify no snapshot " \
  98. "can be created."