4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2014, 2016 by Delphix. All rights reserved.
20 # Verify that holes can be written and read back correctly in ZFS.
23 # 1. Create a testfile with varying holes and data throughout the file.
24 # 2. Verify that each created file has the correct number of holes and
25 # data blocks as seen by both lseek and libzfs.
26 # 3. Do the same verification for a largefile.
27 # 4. Repeat for each recsize.
30 .
$STF_SUITE/include
/libtest.shlib
31 .
$STF_SUITE/tests
/functional
/holes
/holes.shlib
33 verify_runnable
"both"
34 testfile
="$TESTDIR/testfile"
36 for bs
in 512 1024 2048 4096 8192 16384 32768 65536 131072; do
37 log_must zfs
set recsize
=$bs $TESTPOOL/$TESTFS
40 # Create combinations of holes and data to verify holes ending files
41 # and the like. (hhh, hhd, hdh...)
43 log_must mkholes
-h 0:$
((bs
* 6)) $testfile
44 verify_holes_and_data_blocks
$testfile 6 0
47 log_must mkholes
-h 0:$
((bs
* 4)) -d $
((bs
* 4)):$
((bs
* 2)) $testfile
48 verify_holes_and_data_blocks
$testfile 4 2
51 log_must mkholes
-h 0:$
((bs
* 2)) -d $
((bs
* 2)):$
((bs
* 2)) \
52 -h $
((bs
* 4)):$
((bs
* 2)) $testfile
53 verify_holes_and_data_blocks
$testfile 4 2
56 log_must mkholes
-h 0:$
((bs
* 2)) -d $
((bs
* 2)):$
((bs
* 4)) $testfile
57 verify_holes_and_data_blocks
$testfile 2 4
60 log_must mkholes
-d 0:$
((bs
* 2)) -h $
((bs
* 2)):$
((bs
* 4)) $testfile
61 verify_holes_and_data_blocks
$testfile 4 2
64 log_must mkholes
-d 0:$
((bs
* 2)) -h $
((bs
* 2)):$
((bs
* 2)) \
65 -d $
((bs
* 4)):$
((bs
* 2)) $testfile
66 verify_holes_and_data_blocks
$testfile 2 4
69 log_must mkholes
-d 0:$
((bs
* 4)) -h $
((bs
* 4)):$
((bs
* 2)) $testfile
70 verify_holes_and_data_blocks
$testfile 2 4
73 log_must mkholes
-d 0:$
((bs
* 6)) $testfile
74 verify_holes_and_data_blocks
$testfile 0 6
77 # Verify holes are correctly seen past the largefile limit.
80 log_must mkholes
-h 0:$len -d $len:$bs $testfile
81 verify_holes_and_data_blocks
$testfile $nblks 1
85 log_pass
"Basic hole tests pass."