aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh
blob: 15afc4adf4bc8ab0211e46b631313ee508512c99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/ksh -p

#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright (c) 2017 by Delphix. All rights reserved.
#

. $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib

#
# DESCRIPTION:
#	Ensure that we don't reuse checkpointed blocks when the
#	pool hits ENOSPC errors because of the slop space limit.
#	This test also ensures that the DSL layer correctly takes
#	into account the space used by the checkpoint when deciding
#	whether to allow operations based on the reserved slop
#	space.
#
# STRATEGY:
#	1. Create pool with one disk of 1G size
#	2. Create a file with random data of 700M in size.
#	   leaving ~200M left in pool capacity.
#	3. Checkpoint the pool
#	4. Remove the file. All of its blocks should stay around
#	   in ZFS as they are part of the checkpoint.
#	5. Create a new empty file and attempt to write ~300M
#	   of data to it. This should fail, as the reserved
#	   SLOP space for the pool should be ~128M, and we should
#	   be hitting that limit getting ENOSPC.
#	6. Use zdb to traverse and checksum all the checkpointed
#	   data to ensure its integrity.
#	7. Export the pool and rewind to ensure that everything
#	   is actually there as expected.
#

function test_cleanup
{
	poolexists $NESTEDPOOL && destroy_pool $NESTEDPOOL
	set_tunable32 SPA_ASIZE_INFLATION 24
	cleanup_test_pool
}

verify_runnable "global"

setup_test_pool
log_onexit test_cleanup
log_must set_tunable32 SPA_ASIZE_INFLATION 4

log_must zfs create $DISKFS

log_must mkfile $FILEDISKSIZE $FILEDISK1
log_must zpool create $NESTEDPOOL $FILEDISK1

log_must zfs create -o compression=lz4 -o recordsize=8k $NESTEDFS0
log_must dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=700
FILE0INTRO=$(head -c 100 $NESTEDFS0FILE)

log_must zpool checkpoint $NESTEDPOOL
log_must rm $NESTEDFS0FILE

#
# only for debugging purposes
#
log_must zpool list $NESTEDPOOL

log_mustnot dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=300

#
# only for debugging purposes
#
log_must zpool list $NESTEDPOOL

log_must zdb -kc $NESTEDPOOL

log_must zpool export $NESTEDPOOL
log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL

log_must [ "$(head -c 100 $NESTEDFS0FILE)" = "$FILE0INTRO" ]

log_must zdb $NESTEDPOOL

log_pass "Do not reuse checkpointed space at low capacity."