xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_big_rewind.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14
15#
16# Copyright (c) 2017, 2018 by Delphix. All rights reserved.
17#
18
19. $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
20
21#
22# DESCRIPTION:
23#	Rewind to checkpoint on a stressed pool. We basically try to
24#	fragment the pool before and after taking a checkpoint and
25#	see if zdb finds any checksum or other errors that imply that
26#	blocks from the checkpoint have been reused.
27#
28# STRATEGY:
29#	1. Import pool that's slightly fragmented
30#	2. Take checkpoint
31#	3. Apply a destructive action and do more random writes
32#	4. Run zdb on both current and checkpointed data and make
33#	   sure that zdb returns with no errors
34#	5. Rewind to checkpoint
35#	6. Run zdb again
36#
37
38verify_runnable "global"
39
40setup_nested_pool_state
41log_onexit cleanup_nested_pools
42
43log_must zpool checkpoint $NESTEDPOOL
44
45#
46# Destroy one dataset, modify an existing one and create a
47# a new one. Do more random writes in an attempt to raise
48# more fragmentation. Then verify both current and checkpointed
49# states.
50#
51fragment_after_checkpoint_and_verify
52
53log_must zpool export $NESTEDPOOL
54log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
55
56log_must zpool export $NESTEDPOOL
57log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL
58
59log_pass "Rewind to checkpoint on a stressed pool."
60