1d583b39bSJohn Wren Kennedy#!/usr/bin/ksh 2d583b39bSJohn Wren Kennedy 3d583b39bSJohn Wren Kennedy# 4d583b39bSJohn Wren Kennedy# This file and its contents are supplied under the terms of the 5d583b39bSJohn Wren Kennedy# Common Development and Distribution License ("CDDL"), version 1.0. 6d583b39bSJohn Wren Kennedy# You may only use this file in accordance with the terms of version 7d583b39bSJohn Wren Kennedy# 1.0 of the CDDL. 8d583b39bSJohn Wren Kennedy# 9d583b39bSJohn Wren Kennedy# A full copy of the text of the CDDL should have accompanied this 10d583b39bSJohn Wren Kennedy# source. A copy of the CDDL is also available via the Internet at 11d583b39bSJohn Wren Kennedy# http://www.illumos.org/license/CDDL. 12d583b39bSJohn Wren Kennedy# 13d583b39bSJohn Wren Kennedy 14d583b39bSJohn Wren Kennedy# 15*1d32ba66SJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 16d583b39bSJohn Wren Kennedy# 17d583b39bSJohn Wren Kennedy 18d583b39bSJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 19d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib 20d583b39bSJohn Wren Kennedy 21d583b39bSJohn Wren Kennedy# 22d583b39bSJohn Wren Kennedy# Description: 23d583b39bSJohn Wren Kennedy# Verify that nopwrite still works for a dataset that becomes a clone via 24d583b39bSJohn Wren Kennedy# promotion. 25d583b39bSJohn Wren Kennedy# 26d583b39bSJohn Wren Kennedy# Strategy: 27d583b39bSJohn Wren Kennedy# 1. Create a clone suitable for nopwrite. 28d583b39bSJohn Wren Kennedy# 2. Disable compression and checksum on the clone, and promote it. 29d583b39bSJohn Wren Kennedy# 3. Overwrite the file in the clone (former origin fs) and verify it 30d583b39bSJohn Wren Kennedy# consumes no additional space. 31d583b39bSJohn Wren Kennedy# 32d583b39bSJohn Wren Kennedy 33d583b39bSJohn Wren Kennedyverify_runnable "global" 34d583b39bSJohn Wren Kennedyorigin="$TESTPOOL/$TESTFS" 35d583b39bSJohn Wren Kennedylog_onexit cleanup 36d583b39bSJohn Wren Kennedy 37d583b39bSJohn Wren Kennedyfunction cleanup 38d583b39bSJohn Wren Kennedy{ 39*1d32ba66SJohn Wren Kennedy datasetexists $origin && log_must zfs destroy -R $TESTPOOL/clone 40*1d32ba66SJohn Wren Kennedy log_must zfs create -o mountpoint=$TESTDIR $origin 41d583b39bSJohn Wren Kennedy} 42d583b39bSJohn Wren Kennedy 43d583b39bSJohn Wren Kennedylog_assert "nopwrite works on a dataset that becomes a clone via promotion." 44d583b39bSJohn Wren Kennedy 45*1d32ba66SJohn Wren Kennedylog_must zfs set compress=on $origin 46*1d32ba66SJohn Wren Kennedylog_must zfs set checksum=sha256 $origin 47*1d32ba66SJohn Wren Kennedydd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \ 48d583b39bSJohn Wren Kennedy >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed." 49*1d32ba66SJohn Wren Kennedyzfs snapshot $origin@a || log_fail "zfs snap failed" 50*1d32ba66SJohn Wren Kennedylog_must zfs clone $origin@a $TESTPOOL/clone 51*1d32ba66SJohn Wren Kennedylog_must zfs set compress=off $TESTPOOL/clone 52*1d32ba66SJohn Wren Kennedylog_must zfs set checksum=off $TESTPOOL/clone 53*1d32ba66SJohn Wren Kennedylog_must zfs promote $TESTPOOL/clone 54*1d32ba66SJohn Wren Kennedydd if=/$TESTPOOL/clone/file of=/$TESTDIR/file bs=1024k count=$MEGS \ 55d583b39bSJohn Wren Kennedy conv=notrunc >/dev/null 2>&1 || log_fail "dd failed." 56d583b39bSJohn Wren Kennedylog_must verify_nopwrite $TESTPOOL/clone $TESTPOOL/clone@a $origin 57d583b39bSJohn Wren Kennedy 58d583b39bSJohn Wren Kennedylog_pass "nopwrite works on a dataset that becomes a clone via promotion." 59