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) 2015, 2017 by Delphix. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/removal/removal.kshlib 23 24default_setup_noexit "$DISKS" 25log_onexit default_cleanup_noexit 26 27log_must dd if=/dev/zero of=$TESTDIR/file bs=1024k count=300 28 29log_must zfs snapshot $TESTPOOL/$TESTFS@snap-pre1 30log_must dd if=/dev/zero of=$TESTDIR/file bs=1024k count=100 \ 31 conv=notrunc seek=100 32 33log_must zfs snapshot $TESTPOOL/$TESTFS@snap-pre2 34log_must dd if=/dev/zero of=$TESTDIR/file bs=1024k count=100 \ 35 conv=notrunc seek=200 36 37if is_linux || is_freebsd; then 38 log_must attempt_during_removal $TESTPOOL $REMOVEDISK zdb -cd $TESTPOOL 39else 40 log_must attempt_during_removal $TESTPOOL $REMOVEDISK 41fi 42log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK 43log_must zdb -cd $TESTPOOL 44 45# 46# Touch one block under each L1 indirect block, so that the other data blocks 47# will be remapped to their concrete locations. These parameters assume 48# recordsize=128K, indirect block size of 128K (1024 block pointers per 49# indirect block), and file size of less than 3*1024 blocks (384MB). 50# 51log_must stride_dd -i /dev/urandom -o $TESTDIR/file -b 131072 -c 3 -s 1024 52 53log_must zdb -cd $TESTPOOL 54 55log_must zfs snapshot $TESTPOOL/$TESTFS@snap-post3 56log_must zdb -cd $TESTPOOL 57 58log_must zfs snapshot $TESTPOOL/$TESTFS@snap-post4 59log_must zdb -cd $TESTPOOL 60 61# 62# Test case where block is moved from remap deadlist: blocks born before 63# snap-pre2 will be obsoleted. 64# 65log_must zfs destroy $TESTPOOL/$TESTFS@snap-pre2 66log_must zdb -cd $TESTPOOL 67 68# 69# Test case where we merge remap deadlists: blocks before snap-pre1 will 70# need to go on snap-post4's deadlist. 71# 72log_must zfs destroy $TESTPOOL/$TESTFS@snap-post3 73log_must zdb -cd $TESTPOOL 74 75log_must zfs destroy $TESTPOOL/$TESTFS@snap-post4 76 77# 78# Test rollback. 79# 80log_must zfs rollback $TESTPOOL/$TESTFS@snap-pre1 81log_must zfs destroy $TESTPOOL/$TESTFS@snap-pre1 82 83log_pass "Remove and remap works with snapshots and deadlists." 84