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 46function test_cleanup 47{ 48 poolexists $NESTEDPOOL && destroy_pool $NESTEDPOOL 49 set_tunable32 SPA_ASIZE_INFLATION 24 50 cleanup_test_pool 51} 52 53verify_runnable "global" 54 55setup_test_pool 56log_onexit test_cleanup 57log_must set_tunable32 SPA_ASIZE_INFLATION 4 58 59log_must zfs create $DISKFS 60 61log_must mkfile $FILEDISKSIZE $FILEDISK1 62log_must zpool create $NESTEDPOOL $FILEDISK1 63 64log_must zfs create -o compression=lz4 -o recordsize=8k $NESTEDFS0 65log_must dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=700 66FILE0INTRO=$(head -c 100 $NESTEDFS0FILE) 67 68log_must zpool checkpoint $NESTEDPOOL 69log_must rm $NESTEDFS0FILE 70 71# 72# only for debugging purposes 73# 74log_must zpool list $NESTEDPOOL 75 76log_mustnot dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=300 77 78# 79# only for debugging purposes 80# 81log_must zpool list $NESTEDPOOL 82 83log_must zpool export $NESTEDPOOL 84log_must zdb -e -p $FILEDISKDIR -kc $NESTEDPOOL 85 86log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL 87 88log_must [ "$(head -c 100 $NESTEDFS0FILE)" = "$FILE0INTRO" ] 89 90log_must zpool export $NESTEDPOOL 91log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL 92 93log_pass "Do not reuse checkpointed space at low capacity." 94