186714001SSerapheim Dimitropoulos#!/usr/bin/ksh -p
286714001SSerapheim Dimitropoulos
386714001SSerapheim Dimitropoulos#
486714001SSerapheim Dimitropoulos# This file and its contents are supplied under the terms of the
586714001SSerapheim Dimitropoulos# Common Development and Distribution License ("CDDL"), version 1.0.
686714001SSerapheim Dimitropoulos# You may only use this file in accordance with the terms of version
786714001SSerapheim Dimitropoulos# 1.0 of the CDDL.
886714001SSerapheim Dimitropoulos#
986714001SSerapheim Dimitropoulos# A full copy of the text of the CDDL should have accompanied this
1086714001SSerapheim Dimitropoulos# source.  A copy of the CDDL is also available via the Internet at
1186714001SSerapheim Dimitropoulos# http://www.illumos.org/license/CDDL.
1286714001SSerapheim Dimitropoulos#
1386714001SSerapheim Dimitropoulos
1486714001SSerapheim Dimitropoulos#
15*a0b03b16SSerapheim Dimitropoulos# Copyright (c) 2017, 2018 by Delphix. All rights reserved.
1686714001SSerapheim Dimitropoulos#
1786714001SSerapheim Dimitropoulos
1886714001SSerapheim Dimitropoulos. $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
1986714001SSerapheim Dimitropoulos
2086714001SSerapheim Dimitropoulos#
2186714001SSerapheim Dimitropoulos# DESCRIPTION:
22*a0b03b16SSerapheim Dimitropoulos#	The maximum address that can be described by a single-word
23*a0b03b16SSerapheim Dimitropoulos#	space map entry limits the maximum allocatable space of any
24*a0b03b16SSerapheim Dimitropoulos#	top-level vdev to 64PB whenever a vdev-wide space map is used.
2586714001SSerapheim Dimitropoulos#
2686714001SSerapheim Dimitropoulos#	Since a vdev-wide space map is introduced for the checkpoint
27*a0b03b16SSerapheim Dimitropoulos#	we want to ensure that we cannot checkpoint a pool that does
28*a0b03b16SSerapheim Dimitropoulos#	not use the new space map encoding (V2) and has a top-level
29*a0b03b16SSerapheim Dimitropoulos#	vdev with more than 64PB of allocatable space.
3086714001SSerapheim Dimitropoulos#
3186714001SSerapheim Dimitropoulos#	Note: Since this is a pool created from file-based vdevs we
3286714001SSerapheim Dimitropoulos#	      are guaranteed that vdev_ashift  is SPA_MINBLOCKSHIFT
3386714001SSerapheim Dimitropoulos#	      [which is currently 9 and (1 << 9) = 512], so the numbers
3486714001SSerapheim Dimitropoulos#	      work out for this test.
3586714001SSerapheim Dimitropoulos#
3686714001SSerapheim Dimitropoulos# STRATEGY:
3786714001SSerapheim Dimitropoulos#	1. Create pool with a disk of exactly 64PB
38*a0b03b16SSerapheim Dimitropoulos#	   (so ~63.5PB of allocatable space) and
39*a0b03b16SSerapheim Dimitropoulos#	   ensure that has the checkpoint feature
40*a0b03b16SSerapheim Dimitropoulos#	   enabled but not space map V2
4186714001SSerapheim Dimitropoulos#	2. Ensure that you can checkpoint it
4286714001SSerapheim Dimitropoulos#	3. Create pool with a disk of exactly 65PB
43*a0b03b16SSerapheim Dimitropoulos#	   (so ~64.5PB of allocatable space) with
44*a0b03b16SSerapheim Dimitropoulos#	   the same setup
4586714001SSerapheim Dimitropoulos#	4. Ensure we fail trying to checkpoint it
4686714001SSerapheim Dimitropoulos#
47*a0b03b16SSerapheim Dimitropoulos# Note:
48*a0b03b16SSerapheim Dimitropoulos# This test used to create the two pools and attempt to checkpoint
49*a0b03b16SSerapheim Dimitropoulos# them at the same time, then destroy them. We later had to change
50*a0b03b16SSerapheim Dimitropoulos# this to test one pool at a time as the metaslabs (even though empty)
51*a0b03b16SSerapheim Dimitropoulos# consumed a lot of memory, especially on a machine that has been
52*a0b03b16SSerapheim Dimitropoulos# running with debug enabled. To give an example, each metaslab
53*a0b03b16SSerapheim Dimitropoulos# structure is ~1712 bytes (at the time of this writing), and each
54*a0b03b16SSerapheim Dimitropoulos# vdev has 128K metaslabs, which means that just the structures
55*a0b03b16SSerapheim Dimitropoulos# consume 131071 * 1712 = ~224M.
56*a0b03b16SSerapheim Dimitropoulos#
5786714001SSerapheim Dimitropoulos
5886714001SSerapheim Dimitropoulosverify_runnable "global"
5986714001SSerapheim Dimitropoulos
6086714001SSerapheim DimitropoulosTESTPOOL1=testpool1
6186714001SSerapheim DimitropoulosTESTPOOL2=testpool2
6286714001SSerapheim Dimitropoulos
6386714001SSerapheim DimitropoulosDISK64PB=/$DISKFS/disk64PB
6486714001SSerapheim DimitropoulosDISK65PB=/$DISKFS/disk65PB
6586714001SSerapheim Dimitropoulos
6686714001SSerapheim Dimitropoulosfunction test_cleanup
6786714001SSerapheim Dimitropoulos{
6886714001SSerapheim Dimitropoulos	poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
6986714001SSerapheim Dimitropoulos	poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
7086714001SSerapheim Dimitropoulos	log_must rm -f $DISK64PB $DISK65PB
7186714001SSerapheim Dimitropoulos	cleanup_test_pool
7286714001SSerapheim Dimitropoulos}
7386714001SSerapheim Dimitropoulos
7486714001SSerapheim Dimitropoulossetup_test_pool
7586714001SSerapheim Dimitropouloslog_onexit test_cleanup
7686714001SSerapheim Dimitropoulos
7786714001SSerapheim Dimitropouloslog_must zfs create $DISKFS
7886714001SSerapheim Dimitropouloslog_must mkfile -n $((64 * 1024 * 1024))g $DISK64PB
7986714001SSerapheim Dimitropouloslog_must mkfile -n $((65 * 1024 * 1024))g $DISK65PB
8086714001SSerapheim Dimitropoulos
81*a0b03b16SSerapheim Dimitropouloslog_must zpool create -d $TESTPOOL1 $DISK64PB
82*a0b03b16SSerapheim Dimitropouloslog_must zpool set feature@zpool_checkpoint=enabled $TESTPOOL1
8386714001SSerapheim Dimitropouloslog_must zpool checkpoint $TESTPOOL1
84*a0b03b16SSerapheim Dimitropoulosdestroy_pool $TESTPOOL1
85*a0b03b16SSerapheim Dimitropoulos
86*a0b03b16SSerapheim Dimitropouloslog_must zpool create -d $TESTPOOL2 $DISK65PB
87*a0b03b16SSerapheim Dimitropouloslog_must zpool set feature@zpool_checkpoint=enabled $TESTPOOL2
8886714001SSerapheim Dimitropouloslog_mustnot zpool checkpoint $TESTPOOL2
89*a0b03b16SSerapheim Dimitropoulosdestroy_pool $TESTPOOL2
9086714001SSerapheim Dimitropoulos
91*a0b03b16SSerapheim Dimitropouloslog_pass "Fail to checkpoint pool with old spacemap encoding" \
92*a0b03b16SSerapheim Dimitropoulos    " and a vdev that's more than 64PB."
93