PageRenderTime 29ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/nopwrite/nopwrite_volume.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 59 lines | 26 code | 9 blank | 24 comment | 4 complexity | 360470d86a972b201b0534164360367d MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  14. #
  15. . $STF_SUITE/include/libtest.shlib
  16. . $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib
  17. #
  18. # Description:
  19. # Verify that nopwrite cannot be enabled on volumes
  20. #
  21. # Strategy:
  22. # 1. Create a clone of a volume that fits the criteria for nopwrite.
  23. # 2. Overwrite the same blocks from the origin vol and verify that
  24. # new space is consumed.
  25. #
  26. verify_runnable "global"
  27. origin="$TESTPOOL/$TESTVOL"
  28. clone="$TESTPOOL/clone"
  29. vol="${ZVOL_RDEVDIR}/$origin"
  30. volclone="${ZVOL_RDEVDIR}/$clone"
  31. log_onexit cleanup
  32. function cleanup
  33. {
  34. datasetexists $origin && log_must zfs destroy -R $origin
  35. # No need to recreate the volume as no other tests expect it.
  36. }
  37. log_assert "nopwrite works on volumes"
  38. log_must zfs set compress=on $origin
  39. log_must zfs set checksum=sha256 $origin
  40. dd if=/dev/urandom of=$vol bs=8192 count=4096 conv=notrunc >/dev/null \
  41. 2>&1 || log_fail "dd into $origin failed."
  42. zfs snapshot $origin@a || log_fail "zfs snap failed"
  43. log_must zfs clone $origin@a $clone
  44. log_must zfs set compress=on $clone
  45. log_must zfs set checksum=sha256 $clone
  46. block_device_wait
  47. dd if=$vol of=$volclone bs=8192 count=4096 conv=notrunc >/dev/null 2>&1 || \
  48. log_fail "dd into $clone failed."
  49. log_must verify_nopwrite $origin $origin@a $clone
  50. log_pass "nopwrite works on volumes"