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, 2018 by Delphix. All rights reserved.
18 .
$STF_SUITE/tests
/functional
/pool_checkpoint
/pool_checkpoint.kshlib
22 # Discard checkpoint on a stressed pool. Ensure that we can
23 # export and import the pool while discarding but not run any
24 # operations that have to do with the checkpoint or change the
28 # 1. Import pools that's slightly fragmented
30 # 3. Do more random writes to "free" checkpointed blocks
31 # 4. Start discarding checkpoint
32 # 5. Export pool while discarding checkpoint
33 # 6. Attempt to rewind (should fail)
34 # 7. Import pool and ensure that discard is still running
35 # 8. Attempt to run checkpoint commands, or commands that
36 # change the pool's config (should fail)
39 verify_runnable
"global"
43 # reset memory limit to 16M
44 mdb_ctf_set_int zfs_spa_discard_memory_limit
1000000
48 setup_nested_pool_state
49 log_onexit test_cleanup
52 # Force discard to happen slower so it spans over
55 # Set memory limit to 128 bytes. Assuming that we
56 # use 64-bit words for encoding space map entries,
57 # ZFS will discard 8 non-debug entries per txg
58 # (so at most 16 space map entries in debug-builds
59 # due to debug entries).
61 # That should give us more than enough txgs to be
62 # discarding the checkpoint for a long time as with
63 # the current setup the checkpoint space maps should
64 # have tens of thousands of entries.
66 mdb_ctf_set_int zfs_spa_discard_memory_limit
0t128
68 log_must zpool checkpoint
$NESTEDPOOL
70 fragment_after_checkpoint_and_verify
72 log_must zpool checkpoint
-d $NESTEDPOOL
74 log_must zpool
export $NESTEDPOOL
77 # Verify on-disk state while pool is exported
79 log_must zdb
-e -p $FILEDISKDIR $NESTEDPOOL
82 # Attempt to rewind on a pool that is discarding
85 log_mustnot zpool import
-d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
87 log_must zpool import
-d $FILEDISKDIR $NESTEDPOOL
90 # Discarding should continue after import, so
91 # all the following operations should fail.
93 log_mustnot zpool checkpoint
$NESTEDPOOL
94 log_mustnot zpool checkpoint
-d $NESTEDPOOL
95 log_mustnot zpool remove
$NESTEDPOOL $FILEDISK1
96 log_mustnot zpool reguid
$NESTEDPOOL
98 # reset memory limit to 16M
99 mdb_ctf_set_int zfs_spa_discard_memory_limit
1000000
101 nested_wait_discard_finish
103 log_must zdb
$NESTEDPOOL
105 log_pass
"Can export/import but not rewind/checkpoint/discard or " \
106 "change pool's config while discarding."