1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2020 The FreeBSD Foundation [1]
19#
20# [1] Portions of this software were developed by Allan Jude
21#     under sponsorship from the FreeBSD Foundation.
22
23. $STF_SUITE/include/libtest.shlib
24
25export SIZE=1G
26export VDIR=$TESTDIR/disk.persist_l2arc
27export VDEV="$VDIR/a"
28export VDEV_CACHE="$VDIR/b"
29
30# fio options
31export DIRECTORY=/$TESTPOOL-l2arc
32export NUMJOBS=4
33export RUNTIME=30
34export PERF_RANDSEED=1234
35export PERF_COMPPERCENT=66
36export PERF_COMPCHUNK=0
37export BLOCKSIZE=128K
38export SYNC_TYPE=0
39export DIRECT=1
40
41#
42# DESCRIPTION:
43#	System with compressed_arc disabled succeeds at reading from L2ARC
44#
45# STRATEGY:
46#	1. Disable compressed_arc.
47#	2. Create pool with a cache device and compression enabled.
48#	3. Read the number of L2ARC checksum failures.
49#	4. Create a random file in that pool and random read for 30 sec.
50#	5. Read the number of L2ARC checksum failures.
51#
52
53verify_runnable "global"
54
55log_assert "L2ARC with compressed_arc disabled succeeds."
56
57origin_carc_setting=$(get_tunable zfs_compressed_arc_enabled)
58
59function cleanup
60{
61	if poolexists $TESTPOOL-l2arc ; then
62		destroy_pool $TESTPOOL-l2arc
63	fi
64
65	log_must set_tunable64 zfs_compressed_arc_enabled $origin_carc_setting
66}
67log_onexit cleanup
68
69log_must rm -rf $VDIR
70log_must mkdir -p $VDIR
71log_must mkfile $SIZE $VDEV
72
73# Disable Compressed ARC so that in-ARC and on-disk will not match
74log_must set_tunable64 zfs_compressed_arc_enabled 0
75
76typeset fill_mb=800
77typeset cache_sz=$(( floor($fill_mb / 2) ))
78export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
79
80log_must truncate -s ${cache_sz}M $VDEV_CACHE
81
82log_must zpool create -O compression=lz4 -f $TESTPOOL-l2arc $VDEV \
83    cache $VDEV_CACHE
84
85l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
86
87log_must fio $FIO_SCRIPTS/mkfiles.fio
88log_must fio $FIO_SCRIPTS/random_reads.fio
89
90l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
91
92log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
93	"$l2_cksum_bad_end"
94log_must test $(( $l2_cksum_bad_end - $l2_cksum_bad_start )) -eq 0
95
96log_must zpool destroy -f $TESTPOOL-l2arc
97
98log_pass "L2ARC with compressed_arc disabled does not result in checksum"\
99	"errors."
100