152244c09SJohn Wren Kennedy#!/bin/ksh 252244c09SJohn Wren Kennedy 352244c09SJohn Wren Kennedy# 452244c09SJohn Wren Kennedy# This file and its contents are supplied under the terms of the 552244c09SJohn Wren Kennedy# Common Development and Distribution License ("CDDL"), version 1.0. 652244c09SJohn Wren Kennedy# You may only use this file in accordance with the terms of version 752244c09SJohn Wren Kennedy# 1.0 of the CDDL. 852244c09SJohn Wren Kennedy# 952244c09SJohn Wren Kennedy# A full copy of the text of the CDDL should have accompanied this 1052244c09SJohn Wren Kennedy# source. A copy of the CDDL is also available via the Internet at 1152244c09SJohn Wren Kennedy# http://www.illumos.org/license/CDDL. 1252244c09SJohn Wren Kennedy# 1352244c09SJohn Wren Kennedy 1452244c09SJohn Wren Kennedy# 15*1d32ba66SJohn Wren Kennedy# Copyright (c) 2014, 2016 by Delphix. All rights reserved. 1652244c09SJohn Wren Kennedy# 1752244c09SJohn Wren Kennedy 1852244c09SJohn Wren Kennedy# 1952244c09SJohn Wren Kennedy# Description: 2052244c09SJohn Wren Kennedy# Verify that holes can be written and read back correctly in ZFS. 2152244c09SJohn Wren Kennedy# 2252244c09SJohn Wren Kennedy# Strategy: 2352244c09SJohn Wren Kennedy# 1. Create a testfile with varying holes and data throughout the file. 2452244c09SJohn Wren Kennedy# 2. Verify that each created file has the correct number of holes and 2552244c09SJohn Wren Kennedy# data blocks as seen by both lseek and libzfs. 2652244c09SJohn Wren Kennedy# 3. Do the same verification for a largefile. 2752244c09SJohn Wren Kennedy# 4. Repeat for each recsize. 2852244c09SJohn Wren Kennedy# 2952244c09SJohn Wren Kennedy 3052244c09SJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 3152244c09SJohn Wren Kennedy. $STF_SUITE/tests/functional/holes/holes.shlib 3252244c09SJohn Wren Kennedy 3352244c09SJohn Wren Kennedyverify_runnable "both" 3452244c09SJohn Wren Kennedytestfile="$TESTDIR/testfile" 3552244c09SJohn Wren Kennedy 3652244c09SJohn Wren Kennedyfor bs in 512 1024 2048 4096 8192 16384 32768 65536 131072; do 37*1d32ba66SJohn Wren Kennedy log_must zfs set recsize=$bs $TESTPOOL/$TESTFS 3852244c09SJohn Wren Kennedy 3952244c09SJohn Wren Kennedy # 4052244c09SJohn Wren Kennedy # Create combinations of holes and data to verify holes ending files 4152244c09SJohn Wren Kennedy # and the like. (hhh, hhd, hdh...) 4252244c09SJohn Wren Kennedy # 43*1d32ba66SJohn Wren Kennedy log_must mkholes -h 0:$((bs * 6)) $testfile 4452244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 6 0 45*1d32ba66SJohn Wren Kennedy log_must rm $testfile 4652244c09SJohn Wren Kennedy 47*1d32ba66SJohn Wren Kennedy log_must mkholes -h 0:$((bs * 4)) -d $((bs * 4)):$((bs * 2)) $testfile 4852244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 4 2 49*1d32ba66SJohn Wren Kennedy log_must rm $testfile 5052244c09SJohn Wren Kennedy 51*1d32ba66SJohn Wren Kennedy log_must mkholes -h 0:$((bs * 2)) -d $((bs * 2)):$((bs * 2)) \ 5252244c09SJohn Wren Kennedy -h $((bs * 4)):$((bs * 2)) $testfile 5352244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 4 2 54*1d32ba66SJohn Wren Kennedy log_must rm $testfile 5552244c09SJohn Wren Kennedy 56*1d32ba66SJohn Wren Kennedy log_must mkholes -h 0:$((bs * 2)) -d $((bs * 2)):$((bs * 4)) $testfile 5752244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 2 4 58*1d32ba66SJohn Wren Kennedy log_must rm $testfile 5952244c09SJohn Wren Kennedy 60*1d32ba66SJohn Wren Kennedy log_must mkholes -d 0:$((bs * 2)) -h $((bs * 2)):$((bs * 4)) $testfile 6152244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 4 2 62*1d32ba66SJohn Wren Kennedy log_must rm $testfile 6352244c09SJohn Wren Kennedy 64*1d32ba66SJohn Wren Kennedy log_must mkholes -d 0:$((bs * 2)) -h $((bs * 2)):$((bs * 2)) \ 6552244c09SJohn Wren Kennedy -d $((bs * 4)):$((bs * 2)) $testfile 6652244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 2 4 67*1d32ba66SJohn Wren Kennedy log_must rm $testfile 6852244c09SJohn Wren Kennedy 69*1d32ba66SJohn Wren Kennedy log_must mkholes -d 0:$((bs * 4)) -h $((bs * 4)):$((bs * 2)) $testfile 7052244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 2 4 71*1d32ba66SJohn Wren Kennedy log_must rm $testfile 7252244c09SJohn Wren Kennedy 73*1d32ba66SJohn Wren Kennedy log_must mkholes -d 0:$((bs * 6)) $testfile 7452244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile 0 6 75*1d32ba66SJohn Wren Kennedy log_must rm $testfile 7652244c09SJohn Wren Kennedy 7752244c09SJohn Wren Kennedy # Verify holes are correctly seen past the largefile limit. 7852244c09SJohn Wren Kennedy len=$((1024**3 * 5)) 7952244c09SJohn Wren Kennedy nblks=$((len / bs)) 80*1d32ba66SJohn Wren Kennedy log_must mkholes -h 0:$len -d $len:$bs $testfile 8152244c09SJohn Wren Kennedy verify_holes_and_data_blocks $testfile $nblks 1 82*1d32ba66SJohn Wren Kennedy log_must rm $testfile 8352244c09SJohn Wren Kennedydone 8452244c09SJohn Wren Kennedy 8552244c09SJohn Wren Kennedylog_pass "Basic hole tests pass." 86