1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright (c) 2021 by vStack. All rights reserved. 25# 26 27. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# 'zpool attach poolname raidz ...' should reject device attach if pool 32# is in checkpointed state. If checkpoint creation requested on 33# expanding pool, the request should be rejected. 34 35# 36# STRATEGY: 37# 1. Create block device files for the test raidz pool. 38# 2. Create pool and checkpoint it. 39# 3. Try to expand raidz, ensure that request rejected. 40# 4. Recreate the pool. 41# 5. Apply raidz expansion. 42# 6. Ensure, that checkpoint cannot be created. 43 44typeset -r devs=6 45typeset -r dev_size_mb=512 46 47typeset -a disks 48 49prefetch_disable=$(get_tunable PREFETCH_DISABLE) 50 51function cleanup 52{ 53 poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL" 54 55 for i in {0..$devs}; do 56 log_must rm -f "$TEST_BASE_DIR/dev-$i" 57 done 58 59 log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable 60 log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0 61} 62 63log_onexit cleanup 64 65log_must set_tunable32 PREFETCH_DISABLE 1 66 67# Disk files which will be used by pool 68for i in {0..$(($devs))}; do 69 device=$TEST_BASE_DIR/dev-$i 70 log_must truncate -s ${dev_size_mb}M $device 71 disks[${#disks[*]}+1]=$device 72done 73 74nparity=1 75raid=raidz$nparity 76pool=$TESTPOOL 77opts="-o cachefile=none" 78 79# case 1: checkpoint exist, try to expand 80log_must zpool create -f $opts $pool $raid ${disks[1..$(($devs-1))]} 81log_must zfs set primarycache=metadata $pool 82log_must zpool checkpoint $pool 83log_mustnot zpool attach $pool ${raid}-0 ${disks[$devs]} 84log_must zpool destroy $pool 85 86# 87# case 2: expansion in progress, try to checkpoint 88# 89# Sets pause point at 25% of allocated space so that we know an 90# expansion is still in progress when we attempt the checkpoint 91# 92log_must zpool create -f $opts $pool $raid ${disks[1..$(($devs-1))]} 93log_must zfs set primarycache=metadata $pool 94log_must zfs create $pool/fs 95log_must fill_fs /$pool/fs 1 512 100 1024 R 96allocated=$(zpool list -Hp -o allocated $pool) 97log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $((allocated / 4)) 98log_must zpool attach $pool ${raid}-0 ${disks[$devs]} 99log_mustnot zpool checkpoint $pool 100log_must zpool destroy $pool 101 102log_pass "raidz expansion test succeeded." 103