]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / pool_checkpoint / checkpoint_capacity.ksh
1 #!/bin/ksh -p
2
3 #
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
7 # 1.0 of the CDDL.
8 #
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.
12 #
13
14 #
15 # Copyright (c) 2017 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
19
20 #
21 # DESCRIPTION:
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
27 #       space.
28 #
29 # STRATEGY:
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.
44 #
45
46 function test_cleanup
47 {
48         poolexists $NESTEDPOOL && destroy_pool $NESTEDPOOL
49         set_tunable32 SPA_ASIZE_INFLATION 24
50         cleanup_test_pool
51 }
52
53 verify_runnable "global"
54
55 setup_test_pool
56 log_onexit test_cleanup
57 log_must set_tunable32 SPA_ASIZE_INFLATION 4
58
59 log_must zfs create $DISKFS
60
61 log_must mkfile $FILEDISKSIZE $FILEDISK1
62 log_must zpool create $NESTEDPOOL $FILEDISK1
63
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)
67
68 log_must zpool checkpoint $NESTEDPOOL
69 log_must rm $NESTEDFS0FILE
70
71 #
72 # only for debugging purposes
73 #
74 log_must zpool list $NESTEDPOOL
75
76 log_mustnot dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=300
77
78 #
79 # only for debugging purposes
80 #
81 log_must zpool list $NESTEDPOOL
82
83 log_must zdb -kc $NESTEDPOOL
84
85 log_must zpool export $NESTEDPOOL
86 log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
87
88 log_must [ "$(head -c 100 $NESTEDFS0FILE)" = "$FILE0INTRO" ]
89
90 log_must zdb $NESTEDPOOL
91
92 log_pass "Do not reuse checkpointed space at low capacity."