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 2016, OmniTI Computer Consulting, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# refquota, like regular quota, is loosely enforced. A dataset 26# can exceed its refquota by one transaction. This loose enforcement 27# used to cause problems upon receiving a datastream where its 28# refquota is slightly exceeded. This test confirms that we can 29# successfully receive a slightly over refquota stream. 30# 31# STRATEGY: 32# 1. Create a filesystem. 33# 2. Set a refquota. 34# 3. Snapshot the filesystem. 35# 4. Send a replication stream to a new filesystem. 36# 5. On the original filesystem, fill it up to its quota. 37# 6. Snapshot the original filesystem again. 38# 7. Send an incremental stream to the same new filesystem. 39# 40 41verify_runnable "both" 42 43typeset streamfile=/var/tmp/streamfile.$$ 44 45function cleanup 46{ 47 log_must rm $streamfile 48 log_must zfs destroy -rf $TESTPOOL/$TESTFS1 49 log_must zfs destroy -rf $TESTPOOL/$TESTFS2 50} 51 52log_assert "The allowable slight refquota overage is properly sent-and-" \ 53 "received." 54log_onexit cleanup 55 56orig=$TESTPOOL/$TESTFS1 57dest=$TESTPOOL/$TESTFS2 58 59# 1. Create a filesystem. 60log_must zfs create $orig 61origdir=$(get_prop mountpoint $orig) 62 63# 2. Set a refquota. 64log_must zfs set refquota=50M $orig 65 66# 3. Snapshot the filesystem. 67log_must zfs snapshot $orig@1 68 69# 4. Send a replication stream to a new filesystem. 70log_must eval "zfs send -R $orig@1 > $streamfile" 71log_must eval "zfs recv $dest < $streamfile" 72 73# 5. On the original filesystem, fill it up to its quota. 74cat < /dev/urandom > $origdir/fill-it-up 75 76# 6. Snapshot the original filesystem again. 77log_must zfs snapshot $orig@2 78 79# 7. Send an incremental stream to the same new filesystem. 80log_must eval "zfs send -I 1 -R $orig@2 > $streamfile" 81log_must eval "zfs recv $dest < $streamfile" 82 83log_pass "Verified receiving a slightly-over-refquota stream succeeds." 84