1#! /bin/ksh -p 2# 3# CDDL HEADER START 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# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2018 by Delphix. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/removal/removal.kshlib 23 24# 25# BACKGROUND: 26# 27# ztest hit an issue where it ran zdb and zdb failed because 28# it couldn't access some indirect mappings at the end of a 29# vdev. The issue was that the vdev's ms_shift had changed after 30# it was removed by the addition of another vdev. This test is 31# a regression test for ensuring this case doesn't come up again. 32# 33 34 35TMPDIR=${TMPDIR:-/tmp} 36DISK0=$TMPDIR/dsk0 37DISK1=$TMPDIR/dsk1 38DISK2=$TMPDIR/dsk2 39 40log_must mkfile -n $MINVDEVSIZE $DISK0 41log_must mkfile -n $(($MINVDEVSIZE * 3)) $DISK1 42log_must mkfile -n $MINVDEVSIZE $DISK2 43 44function cleanup 45{ 46 default_cleanup_noexit 47 log_must rm -f $DISK0 $DISK1 $DISK2 48} 49 50# 51# Setup the pool with one disk . 52# 53log_must default_setup_noexit "$DISK0" 54log_onexit cleanup 55 56# 57# Expand vdev. 58# 59log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK0 60log_must zpool reopen $TESTPOOL 61log_must zpool online -e $TESTPOOL $DISK0 62 63# 64# Fill up the whole vdev. 65# 66dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=8M 67 68# 69# Add another vdev and remove the first vdev creating indirect 70# mappings for nearly all the allocatable space from the first 71# vdev. Wait for removal to finish. 72# 73log_must zpool add $TESTPOOL $DISK1 74log_must zpool remove $TESTPOOL $DISK0 75log_must wait_for_removal $TESTPOOL 76 77# 78# Add a new vdev that will trigger a change in the config. 79# Run sync once to ensure that the config actually changed. 80# 81log_must zpool add $TESTPOOL $DISK2 82log_must sync 83 84# 85# Ensure that zdb does not find any problems with this. 86# 87log_must zdb $TESTPOOL 88 89log_pass "Removal of expanded vdev doesn't cause any problems." 90