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 https://opensource.org/licenses/CDDL-1.0. 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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28. $STF_SUITE/tests/functional/rsend/rsend.kshlib 29 30# 31# DESCRIPTION: 32# Verify send streams which contain holes. 33# 34# STRATEGY: 35# 1. Create an initial file for the full send and snapshot. 36# 2. Permute the file with holes and snapshot. 37# 3. Send the full and incremental snapshots to a new pool. 38# 4. Verify the contents of the files match. 39# 40 41sendpool=$POOL 42sendfs=$sendpool/sendfs 43 44recvpool=$POOL2 45recvfs=$recvpool/recvfs 46 47verify_runnable "both" 48 49log_assert "Test hole_birth" 50log_onexit cleanup 51 52function cleanup 53{ 54 cleanup_pool $sendpool 55 cleanup_pool $recvpool 56 set_tunable64 SEND_HOLES_WITHOUT_BIRTH_TIME 1 57} 58 59function send_and_verify 60{ 61 log_must eval "zfs send $sendfs@snap1 > $BACKDIR/pool-snap1" 62 log_must eval "zfs receive -F $recvfs < $BACKDIR/pool-snap1" 63 64 log_must eval "zfs send -i $sendfs@snap1 $sendfs@snap2 " \ 65 ">$BACKDIR/pool-snap1-snap2" 66 log_must eval "zfs receive $recvfs < $BACKDIR/pool-snap1-snap2" 67 68 log_must cmp_md5s /$sendfs/file1 /$recvfs/file1 69} 70 71# By default sending hole_birth times is disabled. This functionality needs 72# to be re-enabled for this test case to verify correctness. Once we're 73# comfortable that all hole_birth bugs has been resolved this behavior may 74# be re-enabled by default. 75log_must set_tunable64 SEND_HOLES_WITHOUT_BIRTH_TIME 0 76 77# Incremental send truncating the file and adding new data. 78log_must zfs create -o recordsize=4k $sendfs 79 80log_must truncate -s 1G /$sendfs/file1 81log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=11264 seek=1152 82log_must zfs snapshot $sendfs@snap1 83 84log_must truncate -s 4M /$sendfs/file1 85log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=152 seek=384 \ 86 conv=notrunc 87log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=10 seek=1408 \ 88 conv=notrunc 89log_must zfs snapshot $sendfs@snap2 90 91send_and_verify 92log_must cleanup_pool $sendpool 93log_must cleanup_pool $recvpool 94 95# Incremental send appending a hole and data. 96log_must zfs create -o recordsize=512 $sendfs 97 98log_must dd if=/dev/urandom of=/$sendfs/file1 bs=128k count=1 seek=1 99log_must zfs snapshot $sendfs@snap1 100 101log_must dd if=/dev/urandom of=/$sendfs/file1 bs=128k count=1 102log_must dd if=/dev/urandom of=/$sendfs/file1 bs=128k count=1 seek=3 103log_must zfs snapshot $sendfs@snap2 104 105send_and_verify 106log_must cleanup_pool $sendpool 107log_must cleanup_pool $recvpool 108 109# Incremental send truncating the file and adding new data. 110log_must zfs create -o recordsize=512 $sendfs 111 112log_must truncate -s 300M /$sendfs/file1 113log_must dd if=/dev/urandom of=/$sendfs/file1 bs=512 count=128k conv=notrunc 114log_must zfs snapshot $sendfs@snap1 115 116log_must truncate -s 10M /$sendfs/file1 117log_must dd if=/dev/urandom of=/$sendfs/file1 bs=512 count=1 seek=96k \ 118 conv=notrunc 119log_must zfs snapshot $sendfs@snap2 120 121send_and_verify 122 123log_pass "Test hole_birth" 124