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 https://opensource.org/licenses/CDDL-1.0.
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 (c) 2021 by Lawrence Livermore National Security, LLC.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/mmap/mmap.cfg
29
30#
31# DESCRIPTION:
32# lseek() data/holes for an mmap()'d file.
33#
34# STRATEGY:
35# 1. Enable compression and hole reporting for dirty files.
36# 2. Call mmap_seek binary test case for various record sizes.
37#
38
39verify_runnable "global"
40
41function cleanup
42{
43	log_must zfs set compression=off $TESTPOOL/$TESTFS
44	log_must zfs set recordsize=128k $TESTPOOL/$TESTFS
45	log_must rm -f $TESTDIR/test-mmap-file
46	log_must set_tunable64 DMU_OFFSET_NEXT_SYNC $dmu_offset_next_sync
47}
48
49log_assert "lseek() data/holes for an mmap()'d file."
50
51log_onexit cleanup
52
53# Enable hole reporting for dirty files.
54typeset dmu_offset_next_sync=$(get_tunable DMU_OFFSET_NEXT_SYNC)
55log_must set_tunable64 DMU_OFFSET_NEXT_SYNC 1
56
57# Compression must be enabled to convert zero'd blocks to holes.
58# This behavior is checked by the mmap_seek test.
59log_must zfs set compression=on $TESTPOOL/$TESTFS
60
61for bs in 4096 8192 16384 32768 65536 131072; do
62	log_must zfs set recordsize=$bs $TESTPOOL/$TESTFS
63	log_must mmap_seek $TESTDIR/test-mmap-file $((1024*1024)) $bs
64	log_must rm $TESTDIR/test-mmap-file
65done
66
67log_pass "lseek() data/holes for an mmap()'d file succeeded."
68