4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2017 by Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
22 # Ensure that we don't reuse checkpointed blocks when the
23 # pool hits ENOSPC errors because of the slop space limit.
24 # This test also ensures that the DSL layer correctly takes
25 # into account the space used by the checkpoint when deciding
26 # whether to allow operations based on the reserved slop
30 # 1. Create pool with one disk of 1G size
31 # 2. Create a file with random data of 700M in size.
32 # leaving ~200M left in pool capacity.
33 # 3. Checkpoint the pool
34 # 4. Remove the file. All of its blocks should stay around
35 # in ZFS as they are part of the checkpoint.
36 # 5. Create a new empty file and attempt to write ~300M
37 # of data to it. This should fail, as the reserved
38 # SLOP space for the pool should be ~128M, and we should
39 # be hitting that limit getting ENOSPC.
40 # 6. Use zdb to traverse and checksum all the checkpointed
41 # data to ensure its integrity.
42 # 7. Export the pool and rewind to ensure that everything
43 # is actually there as expected.
48 poolexists $NESTEDPOOL && destroy_pool $NESTEDPOOL
49 log_must set_tunable32 spa_asize_inflation 24
53 verify_runnable "global"
56 log_onexit test_cleanup
57 log_must set_tunable32 spa_asize_inflation 4
59 log_must zfs create $DISKFS
61 log_must mkfile $FILEDISKSIZE $FILEDISK1
62 log_must zpool create $NESTEDPOOL $FILEDISK1
64 log_must zfs create -o compression=lz4 -o recordsize=8k $NESTEDFS0
65 log_must dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=700
66 FILE0INTRO=$(head -c 100 $NESTEDFS0FILE)
68 log_must zpool checkpoint $NESTEDPOOL
69 log_must rm $NESTEDFS0FILE
72 # only for debugging purposes
74 log_must zpool list $NESTEDPOOL
76 log_mustnot dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=300
79 # only for debugging purposes
81 log_must zpool list $NESTEDPOOL
83 log_must zdb -kc $NESTEDPOOL
85 log_must zpool export $NESTEDPOOL
86 log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
88 log_must [ "$(head -c 100 $NESTEDFS0FILE)" = "$FILE0INTRO" ]
90 log_must zdb $NESTEDPOOL
92 log_pass "Do not reuse checkpointed space at low capacity."