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 (c) 2014, 2016 by Delphix. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22. $STF_SUITE/tests/functional/no_space/enospc.cfg
23
24#
25# DESCRIPTION:
26# After filling a filesystem, certain zfs commands are allowed.
27#
28
29verify_runnable "both"
30
31log_assert "ENOSPC is returned when file system is full."
32sync
33log_must zfs set compression=off $TESTPOOL/$TESTFS
34log_must zfs snapshot $TESTPOOL/$TESTFS@snap
35
36log_note "Writing file: $TESTFILE0 until ENOSPC."
37file_write -o create -f $TESTDIR/$TESTFILE0 -b $BLOCKSZ \
38    -c $NUM_WRITES -d $DATA
39ret=$?
40
41(( $ret != $ENOSPC )) && \
42    log_fail "$TESTFILE0 returned: $ret rather than ENOSPC."
43
44log_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs
45log_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone
46log_mustnot_expect space zfs snapshot $TESTPOOL/$TESTFS@snap2
47log_mustnot_expect space zfs bookmark \
48    $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS#bookmark
49
50log_must zfs send $TESTPOOL/$TESTFS@snap >/tmp/stream.$$
51log_mustnot_expect space zfs receive $TESTPOOL/$TESTFS/recvd </tmp/stream.$$
52log_must rm /tmp/stream.$$
53
54log_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname
55log_must zfs rename $TESTPOOL/$TESTFS@snap_newname $TESTPOOL/$TESTFS@snap
56log_must zfs rename $TESTPOOL/$TESTFS $TESTPOOL/${TESTFS}_newname
57log_must zfs rename $TESTPOOL/${TESTFS}_newname $TESTPOOL/$TESTFS
58log_must zfs allow staff snapshot $TESTPOOL/$TESTFS
59log_must zfs unallow staff snapshot $TESTPOOL/$TESTFS
60log_must zfs set user:prop=value $TESTPOOL/$TESTFS
61log_must zfs set quota=1EB $TESTPOOL/$TESTFS
62log_must zfs set quota=none $TESTPOOL/$TESTFS
63log_must zfs set reservation=1KB $TESTPOOL/$TESTFS
64log_must zfs set reservation=none $TESTPOOL/$TESTFS
65log_must zpool scrub $TESTPOOL
66zpool scrub -s $TESTPOOL
67log_must zpool set comment="Use the force, Luke." $TESTPOOL
68log_must zpool set comment="" $TESTPOOL
69
70# destructive tests must come last
71log_must zfs rollback $TESTPOOL/$TESTFS@snap
72log_must zfs destroy $TESTPOOL/$TESTFS@snap
73
74log_pass "ENOSPC returned as expected."
75