17d46dc6cSMatthew Ahrens#!/bin/ksh -p 27d46dc6cSMatthew Ahrens# 37d46dc6cSMatthew Ahrens# CDDL HEADER START 47d46dc6cSMatthew Ahrens# 57d46dc6cSMatthew Ahrens# This file and its contents are supplied under the terms of the 67d46dc6cSMatthew Ahrens# Common Development and Distribution License ("CDDL"), version 1.0. 77d46dc6cSMatthew Ahrens# You may only use this file in accordance with the terms of version 87d46dc6cSMatthew Ahrens# 1.0 of the CDDL. 97d46dc6cSMatthew Ahrens# 107d46dc6cSMatthew Ahrens# A full copy of the text of the CDDL should have accompanied this 117d46dc6cSMatthew Ahrens# source. A copy of the CDDL is also available via the Internet at 127d46dc6cSMatthew Ahrens# http://www.illumos.org/license/CDDL. 137d46dc6cSMatthew Ahrens# 147d46dc6cSMatthew Ahrens# CDDL HEADER END 157d46dc6cSMatthew Ahrens# 167d46dc6cSMatthew Ahrens 177d46dc6cSMatthew Ahrens# 181d32ba66SJohn Wren Kennedy# Copyright (c) 2014, 2016 by Delphix. All rights reserved. 197d46dc6cSMatthew Ahrens# 207d46dc6cSMatthew Ahrens 217d46dc6cSMatthew Ahrens. $STF_SUITE/include/libtest.shlib 227d46dc6cSMatthew Ahrens. $STF_SUITE/tests/functional/no_space/enospc.cfg 237d46dc6cSMatthew Ahrens 247d46dc6cSMatthew Ahrens# 257d46dc6cSMatthew Ahrens# DESCRIPTION: 267d46dc6cSMatthew Ahrens# After filling a filesystem, certain zfs commands are allowed. 277d46dc6cSMatthew Ahrens# 287d46dc6cSMatthew Ahrens 297d46dc6cSMatthew Ahrensverify_runnable "both" 307d46dc6cSMatthew Ahrens 31*00f13cd3SBrian Behlendorffunction cleanup 32*00f13cd3SBrian Behlendorf{ 33*00f13cd3SBrian Behlendorf log_must_busy zpool destroy -f $TESTPOOL 34*00f13cd3SBrian Behlendorf} 35*00f13cd3SBrian Behlendorf 36*00f13cd3SBrian Behlendorflog_onexit cleanup 37*00f13cd3SBrian Behlendorf 387d46dc6cSMatthew Ahrenslog_assert "ENOSPC is returned when file system is full." 39*00f13cd3SBrian Behlendorf 401d32ba66SJohn Wren Kennedylog_must zfs set compression=off $TESTPOOL/$TESTFS 411d32ba66SJohn Wren Kennedylog_must zfs snapshot $TESTPOOL/$TESTFS@snap 427d46dc6cSMatthew Ahrens 43*00f13cd3SBrian Behlendorf# 44*00f13cd3SBrian Behlendorf# Completely fill the pool in order to ensure the commands below will more 45*00f13cd3SBrian Behlendorf# reliably succeed or fail as a result of lack of space. Care is taken to 46*00f13cd3SBrian Behlendorf# force multiple transaction groups to ensure as many recently freed blocks 47*00f13cd3SBrian Behlendorf# as possible are reallocated. 48*00f13cd3SBrian Behlendorf# 49*00f13cd3SBrian Behlendorf 50*00f13cd3SBrian Behlendorflog_note "Writing files until ENOSPC." 51*00f13cd3SBrian Behlendorf 52*00f13cd3SBrian Behlendorffor i in $(seq 100); do 53*00f13cd3SBrian Behlendorf file_write -o create -f $TESTDIR/file.$i -b $BLOCKSZ \ 54*00f13cd3SBrian Behlendorf -c $NUM_WRITES -d $DATA 55*00f13cd3SBrian Behlendorf ret=$? 56*00f13cd3SBrian Behlendorf (( ret != ENOSPC )) && \ 57*00f13cd3SBrian Behlendorf log_fail "file.$i returned: $ret rather than ENOSPC." 587d46dc6cSMatthew Ahrens 59*00f13cd3SBrian Behlendorf sync_all_pools true 60*00f13cd3SBrian Behlendorfdone 617d46dc6cSMatthew Ahrens 621d32ba66SJohn Wren Kennedylog_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs 631d32ba66SJohn Wren Kennedylog_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone 647d46dc6cSMatthew Ahrens 65*00f13cd3SBrian Behlendorflog_must zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$ 66*00f13cd3SBrian Behlendorflog_mustnot_expect space zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$ 67*00f13cd3SBrian Behlendorflog_must rm $TEST_BASE_DIR/stream.$$ 687d46dc6cSMatthew Ahrens 691d32ba66SJohn Wren Kennedylog_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname 701d32ba66SJohn Wren Kennedylog_must zfs rename $TESTPOOL/$TESTFS@snap_newname $TESTPOOL/$TESTFS@snap 711d32ba66SJohn Wren Kennedylog_must zfs rename $TESTPOOL/$TESTFS $TESTPOOL/${TESTFS}_newname 721d32ba66SJohn Wren Kennedylog_must zfs rename $TESTPOOL/${TESTFS}_newname $TESTPOOL/$TESTFS 731d32ba66SJohn Wren Kennedylog_must zfs allow staff snapshot $TESTPOOL/$TESTFS 741d32ba66SJohn Wren Kennedylog_must zfs unallow staff snapshot $TESTPOOL/$TESTFS 751d32ba66SJohn Wren Kennedylog_must zfs set user:prop=value $TESTPOOL/$TESTFS 761d32ba66SJohn Wren Kennedylog_must zfs set quota=1EB $TESTPOOL/$TESTFS 771d32ba66SJohn Wren Kennedylog_must zfs set quota=none $TESTPOOL/$TESTFS 781d32ba66SJohn Wren Kennedylog_must zfs set reservation=1KB $TESTPOOL/$TESTFS 791d32ba66SJohn Wren Kennedylog_must zfs set reservation=none $TESTPOOL/$TESTFS 801d32ba66SJohn Wren Kennedylog_must zpool scrub $TESTPOOL 811d32ba66SJohn Wren Kennedyzpool scrub -s $TESTPOOL 821d32ba66SJohn Wren Kennedylog_must zpool set comment="Use the force, Luke." $TESTPOOL 831d32ba66SJohn Wren Kennedylog_must zpool set comment="" $TESTPOOL 847d46dc6cSMatthew Ahrens 857d46dc6cSMatthew Ahrens# destructive tests must come last 861d32ba66SJohn Wren Kennedylog_must zfs rollback $TESTPOOL/$TESTFS@snap 871d32ba66SJohn Wren Kennedylog_must zfs destroy $TESTPOOL/$TESTFS@snap 887d46dc6cSMatthew Ahrens 897d46dc6cSMatthew Ahrenslog_pass "ENOSPC returned as expected." 90