/tests/zfs-tests/tests/functional/redacted_send/redacted_deleted.ksh

https://github.com/adilger/zfs · Korn Shell · 103 lines · 48 code · 10 blank · 45 comment · 0 complexity · 1d2565b826a1b4044304f044db8c61af MD5 · raw file

  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) 2017, 2018 by Delphix. All rights reserved.
  14. #
  15. . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
  16. #
  17. # Description:
  18. # Verify redaction works as expected with respect to deleted files
  19. #
  20. # Strategy:
  21. # 1. A file on the delete queue counts as deleted when using it to calculate
  22. # redaction.
  23. # 2. A file that is removed in the tosnap of an incremental, where the fromsnap
  24. # is a redaction bookmark that contains references to that file, does not
  25. # result in records for that file.
  26. #
  27. typeset ds_name="deleted"
  28. typeset sendfs="$POOL/$ds_name"
  29. typeset recvfs="$POOL2/$ds_name"
  30. typeset clone="$POOL/${ds_name}_clone"
  31. typeset clone2="$POOL/${ds_name}_clone2"
  32. typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
  33. typeset stream=$(mktemp $tmpdir/stream.XXXX)
  34. setup_dataset $ds_name ''
  35. typeset clone_mnt="$(get_prop mountpoint $clone)"
  36. typeset send_mnt="$(get_prop mountpoint $sendfs)"
  37. typeset recv_mnt="/$POOL2/$ds_name"
  38. log_onexit redacted_cleanup $sendfs $recvfs
  39. #
  40. # A file on the delete queue counts as deleted when using it to calculate
  41. # redaction.
  42. #
  43. #
  44. # Open file descriptor 5 for appending to $clone_mnt/f1 so that it will go on
  45. # the delete queue when we rm it.
  46. #
  47. exec 5>>$clone_mnt/f1
  48. log_must dd if=/dev/urandom of=$clone_mnt/f1 bs=512 count=1 conv=notrunc
  49. log_must rm $clone_mnt/f1
  50. log_must zfs snapshot $clone@snap1
  51. # Close file descriptor 5
  52. exec 5>&-
  53. log_must zfs redact $sendfs@snap book1 $clone@snap1
  54. log_must eval "zfs send --redact book1 $sendfs@snap >$stream"
  55. log_must eval "zfs recv $recvfs <$stream"
  56. log_must mount_redacted -f $recvfs
  57. #
  58. # We have temporarily disabled redaction blkptrs, so this will not
  59. # fail as was originally intended. We should uncomment this line
  60. # when we re-enable redaction blkptrs.
  61. #
  62. #log_mustnot dd if=$recv_mnt/f1 of=/dev/null bs=512 count=1
  63. log_must diff $send_mnt/f2 $recv_mnt/f2
  64. log_must zfs rollback -R $clone@snap
  65. log_must zfs destroy -R $recvfs
  66. #
  67. # A file that is removed in the tosnap of an incremental, where the fromsnap
  68. # is a redaction bookmark that contains references to that file, does not
  69. # result in records for that file.
  70. #
  71. log_must zfs clone $sendfs@snap $clone2
  72. typeset clone2_mnt="$(get_prop mountpoint $clone2)"
  73. log_must rm -rf $clone2_mnt/*
  74. log_must zfs snapshot $clone2@snap
  75. log_must zfs redact $sendfs@snap book2 $clone2@snap
  76. log_must zfs destroy -R $clone2
  77. log_must eval "zfs send --redact book2 $sendfs@snap >$stream"
  78. log_must eval "zfs recv $recvfs <$stream"
  79. log_must rm $send_mnt/f1
  80. log_must zfs snapshot $sendfs@snap2
  81. log_must zfs clone $sendfs@snap2 $clone2
  82. typeset clone2_mnt="$(get_prop mountpoint $clone2)"
  83. log_must rm $clone2_mnt/*
  84. log_must zfs snapshot $clone2@snap
  85. log_must zfs redact $sendfs@snap2 book3 $clone2@snap
  86. log_must zfs destroy -R $clone2
  87. log_must eval "zfs send -i $sendfs#book2 --redact book3 $sendfs@snap2 >$stream"
  88. log_must eval "zfs recv $recvfs <$stream"
  89. log_must mount_redacted -f $recvfs
  90. log_must diff <(ls $send_mnt) <(ls $recv_mnt)
  91. log_must zfs destroy -R $recvfs
  92. log_must zfs rollback -R $sendfs@snap
  93. log_pass "Verify Redaction works as expected with respect to deleted files."