PageRenderTime 118ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/reservation/reservation_003_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 137 lines | 44 code | 26 blank | 67 comment | 8 complexity | d83af99f286d344738e664c851647151 MD5 | raw file
  1. #! /usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)reservation_003_pos.ksh 1.3 09/08/06 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/reservation/reservation.kshlib
  31. ###############################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: reservation_003_pos
  36. #
  37. # DESCRIPTION:
  38. #
  39. # Verify that it's possible to set a reservation on a filesystem,
  40. # or volume multiple times, without resetting the reservation
  41. # to none.
  42. #
  43. # STRATEGY:
  44. # 1) Create a regular volume and a sparse volume
  45. # 2) Get the space available in the pool
  46. # 3) Set a reservation on the filesystem less than the space available.
  47. # 4) Verify that the 'reservation' property for the filesystem has
  48. # the correct value.
  49. # 5) Repeat 2-4 for different reservation values
  50. # 6) Repeat 3-5 for regular and sparse volume
  51. #
  52. # TESTABILITY: explicit
  53. #
  54. # TEST_AUTOMATION_LEVEL: automated
  55. #
  56. # CODING_STATUS: COMPLETED (2005-07-19)
  57. #
  58. # __stc_assertion_end
  59. #
  60. ################################################################################
  61. verify_runnable "both"
  62. log_assert "Verify it is possible to set reservations multiple times " \
  63. "on a filesystem regular and sparse volume"
  64. #
  65. # Set a reservation $RESV_ITER times on a dataset and verify that
  66. # the reservation is correctly set each time.
  67. #
  68. function multiple_resv { #dataset
  69. typeset -i i=0
  70. dataset=$1
  71. log_must zero_reservation $dataset
  72. space_avail=`get_prop available $TESTPOOL`
  73. (( resv_size = ( space_avail - RESV_DELTA ) / RESV_ITER ))
  74. #
  75. # For regular (non-sparse) volumes the upper limit is determined
  76. # not by the space available in the pool but rather by the size
  77. # of the volume itself.
  78. #
  79. [[ $obj == $TESTPOOL/$TESTVOL ]] && \
  80. (( resv_size = ( vol_set_size - RESV_DELTA ) / RESV_ITER ))
  81. resv_size_set=$resv_size
  82. while (( $i < $RESV_ITER )); do
  83. (( i = i + 1 ))
  84. (( resv_size_set = resv_size * i ))
  85. log_must $ZFS set reservation=$resv_size_set $dataset
  86. resv_size_get=`get_prop reservation $dataset`
  87. if [[ $resv_size_set != $resv_size_get ]]; then
  88. log_fail "Reservation not the expected value " \
  89. "($resv_size_set != $resv_size_get)"
  90. fi
  91. done
  92. log_must zero_reservation $dataset
  93. }
  94. space_avail=`get_prop available $TESTPOOL`
  95. if ! is_global_zone ; then
  96. OBJ_LIST=""
  97. else
  98. OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2"
  99. (( vol_set_size = space_avail / 4 ))
  100. vol_set_size=$(floor_volsize $vol_set_size)
  101. (( sparse_vol_set_size = space_avail * 4 ))
  102. sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size)
  103. log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL
  104. log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL
  105. log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2
  106. fi
  107. for obj in $TESTPOOL/$TESTFS $OBJ_LIST ; do
  108. multiple_resv $obj
  109. done
  110. log_pass "Multiple reservations successfully set on filesystem" \
  111. " and both volume types"