dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / compression / compress_003_pos.ksh
blobe0a450dd42a03d35df45d022f67a826d6e8b8783
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
35 # DESCRIPTION:
36 # With 'compression' or 'compress' set, changing filesystem blocksize cannot
37 # cause system panic
39 # STRATEGY:
40 # 1. Set 'compression' or "compress" to on
41 # 2. Set different blocksize with ZFS filesystem
42 # 3. Use 'mkfile' create single block and multi-block files
43 # 4. Verify the system continued work
46 verify_runnable "both"
48 function cleanup
50 rm -f $TESTDIR/*
53 log_assert "Changing blocksize doesn't casue system panic with compression settings"
54 log_onexit cleanup
56 fs=$TESTPOOL/$TESTFS
57 single_blk_file=$TESTDIR/singleblkfile.$$
58 multi_blk_file=$TESTDIR/multiblkfile.$$
59 typeset -i blksize=512
60 typeset -i fsize=0
61 typeset -i offset=0
63 for propname in "compression" "compress"
65 for value in $(get_compress_opts zfs_compress)
67 log_must zfs set $propname=$value $fs
68 if [[ $value == "gzip-6" ]]; then
69 value="gzip"
71 real_val=$(get_prop $propname $fs)
72 [[ $real_val != $value ]] && \
73 log_fail "Set property $propname=$value failed."
75 (( blksize = 512 ))
76 while (( blksize <= 131072 )); do
77 log_must zfs set recordsize=$blksize $fs
78 (( offset = $RANDOM ))
79 if (( offset > blksize )); then
80 (( offset = offset % blksize ))
82 if (( (offset % 2) == 0 )); then
83 #keep offset as non-power-of-2
84 (( offset = offset + 1 ))
86 (( fsize = offset ))
87 log_must mkfile $fsize $single_blk_file
88 (( fsize = blksize + offset ))
89 log_must mkfile $fsize $multi_blk_file
91 (( blksize = blksize * 2 ))
92 done
93 done
94 done
96 log_pass "The system works as expected while changing blocksize with compression settings"