1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2017, loli10K. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/no_space/enospc.cfg
29. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
30
31#
32# DESCRIPTION:
33#	ENOSPC is returned on pools with large physical block size and small
34#	recordsize.
35#
36# STRATEGY:
37#	1. Create a pool with property ashift=13 (8K block size)
38#	2. Set property recordsize=512 and copies=3 on the root dataset
39#	3. Write a file until the file system is full
40#	4. Verify the return code is ENOSPC
41#
42
43verify_runnable "both"
44
45function cleanup
46{
47	poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
48	rm -f $testfile0
49}
50
51log_onexit cleanup
52
53log_assert "ENOSPC is returned on pools with large physical block size"
54
55typeset testfile0=${TESTDIR}/testfile0
56
57log_must zpool create -o ashift=13 $TESTPOOL1 $DISK_LARGE
58log_must zfs set mountpoint=$TESTDIR $TESTPOOL1
59log_must zfs set compression=off $TESTPOOL1
60log_must zfs set recordsize=512 $TESTPOOL1
61log_must zfs set copies=3 $TESTPOOL1
62
63log_note "Writing file: $testfile0 until ENOSPC."
64file_write -o create -f $testfile0 -b $BLOCKSZ \
65    -c $NUM_WRITES -d $DATA
66ret=$?
67
68(( $ret != $ENOSPC )) && \
69    log_fail "$testfile0 returned: $ret rather than ENOSPC."
70
71log_pass "ENOSPC returned as expected."
72