PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/zfsonlinux/zfs
Korn Shell | 90 lines | 58 code | 7 blank | 25 comment | 1 complexity | 2fa879338930c23895e0518b3b669ddf 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 duplicate writes to a clone are accounted as new data if the
  20. # prerequisites for nopwrite are not met.
  21. #
  22. # Scenarios:
  23. # 1. The file in the origin ds is written without compression or sha256.
  24. # 2. The file in the origin ds is written before sha256 checksum is turned on.
  25. # 3. The clone does not have compression.
  26. # 4. The clone does not have the appropriate checksum.
  27. #
  28. verify_runnable "global"
  29. origin="$TESTPOOL/$TESTFS"
  30. log_onexit cleanup
  31. function cleanup
  32. {
  33. datasetexists $origin && log_must zfs destroy -R $origin
  34. log_must zfs create -o mountpoint=$TESTDIR $origin
  35. }
  36. log_assert "nopwrite isn't enabled without the prerequisites"
  37. # Data written into origin fs without compression or sha256
  38. dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
  39. >/dev/null 2>&1 || log_fail "dd of $TESTDIR/file failed."
  40. zfs snapshot $origin@a || log_fail "zfs snap failed"
  41. log_must zfs clone -o compress=on $origin@a $origin/clone
  42. log_must zfs set checksum=sha256 $origin/clone
  43. dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
  44. conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
  45. log_mustnot verify_nopwrite $origin $origin@a $origin/clone
  46. zfs destroy -R $origin@a || log_fail "zfs destroy failed"
  47. log_must rm -f $TESTDIR/file
  48. # Data written to origin fs before checksum enabled
  49. log_must zfs set compress=on $origin
  50. dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
  51. >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
  52. log_must zfs set checksum=sha256 $origin
  53. zfs snapshot $origin@a || log_fail "zfs snap failed"
  54. log_must zfs clone $origin@a $origin/clone
  55. dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
  56. conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
  57. log_mustnot verify_nopwrite $origin $origin@a $origin/clone
  58. zfs destroy -R $origin@a || log_fail "zfs destroy failed"
  59. log_must rm -f $TESTDIR/file
  60. # Clone with compression=off
  61. dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
  62. >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
  63. zfs snapshot $origin@a || log_fail "zfs snap failed"
  64. log_must zfs clone -o compress=off $origin@a $origin/clone
  65. dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
  66. conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
  67. log_mustnot verify_nopwrite $origin $origin@a $origin/clone
  68. zfs destroy -R $origin@a || log_fail "zfs destroy failed"
  69. log_must rm -f $TESTDIR/file
  70. # Clone with fletcher4, rather than sha256
  71. dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
  72. >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
  73. zfs snapshot $origin@a || log_fail "zfs snap failed"
  74. log_must zfs clone -o checksum=fletcher4 $origin@a $origin/clone
  75. dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
  76. conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
  77. log_mustnot verify_nopwrite $origin $origin@a $origin/clone
  78. log_pass "nopwrite isn't enabled without the prerequisites"