1#!/usr/bin/ksh 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) 2012 by Delphix. All rights reserved. 16# 17 18. $STF_SUITE/include/libtest.shlib 19. $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib 20 21# 22# Description: 23# Verify that duplicate writes to a clone are accounted as new data if the 24# prerequisites for nopwrite are not met. 25# 26# Scenarios: 27# 1. The file in the origin ds is written without compression or sha256. 28# 2. The file in the origin ds is written before sha256 checksum is turned on. 29# 3. The clone does not have compression. 30# 4. The clone does not have the appropriate checksum. 31# 32 33verify_runnable "global" 34origin="$TESTPOOL/$TESTFS" 35log_onexit cleanup 36 37function cleanup 38{ 39 datasetexists $origin && log_must $ZFS destroy -R $origin 40 log_must $ZFS create -o mountpoint=$TESTDIR $origin 41} 42 43log_assert "nopwrite isn't enabled without the prerequisites" 44 45# Data written into origin fs without compression or sha256 46$DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \ 47 >/dev/null 2>&1 || log_fail "dd of $TESTDIR/file failed." 48$ZFS snapshot $origin@a || log_fail "zfs snap failed" 49log_must $ZFS clone -o compress=on $origin@a $origin/clone 50log_must $ZFS set checksum=sha256 $origin/clone 51$DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \ 52 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed." 53log_mustnot verify_nopwrite $origin $origin@a $origin/clone 54$ZFS destroy -R $origin@a || log_fail "zfs destroy failed" 55log_must $RM -f $TESTDIR/file 56 57# Data written to origin fs before checksum enabled 58log_must $ZFS set compress=on $origin 59$DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \ 60 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed." 61log_must $ZFS set checksum=sha256 $origin 62$ZFS snapshot $origin@a || log_fail "zfs snap failed" 63log_must $ZFS clone $origin@a $origin/clone 64$DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \ 65 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed." 66log_mustnot verify_nopwrite $origin $origin@a $origin/clone 67$ZFS destroy -R $origin@a || log_fail "zfs destroy failed" 68log_must $RM -f $TESTDIR/file 69 70# Clone with compression=off 71$DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \ 72 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed." 73$ZFS snapshot $origin@a || log_fail "zfs snap failed" 74log_must $ZFS clone -o compress=off $origin@a $origin/clone 75$DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \ 76 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed." 77log_mustnot verify_nopwrite $origin $origin@a $origin/clone 78$ZFS destroy -R $origin@a || log_fail "zfs destroy failed" 79log_must $RM -f $TESTDIR/file 80 81# Clone with fletcher4, rather than sha256 82$DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \ 83 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed." 84$ZFS snapshot $origin@a || log_fail "zfs snap failed" 85log_must $ZFS clone -o checksum=fletcher4 $origin@a $origin/clone 86$DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \ 87 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed." 88log_mustnot verify_nopwrite $origin $origin@a $origin/clone 89 90log_pass "nopwrite isn't enabled without the prerequisites" 91