]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / compression / l2arc_encrypted_no_compressed_arc.ksh
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
25 export SIZE=1G
26 export VDIR=$TESTDIR/disk.persist_l2arc
27 export VDEV="$VDIR/a"
28 export VDEV_CACHE="$VDIR/b"
29 export PASSPHRASE="password"
30
31 # fio options
32 export DIRECTORY=/$TESTPOOL-l2arc/encrypted
33 export NUMJOBS=4
34 export RUNTIME=30
35 export PERF_RANDSEED=1234
36 export PERF_COMPPERCENT=66
37 export PERF_COMPCHUNK=0
38 export BLOCKSIZE=128K
39 export SYNC_TYPE=0
40 export DIRECT=1
41
42 #
43 # DESCRIPTION:
44 #       System with compressed_arc disabled succeeds at reading from L2ARC
45 #
46 # STRATEGY:
47 #       1. Disable compressed_arc.
48 #       2. Create pool with a cache device, encryption, and compression enabled.
49 #       3. Read the number of L2ARC checksum failures.
50 #       4. Create a random file in that pool and random read for 30 sec.
51 #       5. Read the number of L2ARC checksum failures.
52 #
53
54 verify_runnable "global"
55
56 log_assert "L2ARC with compressed_arc disabled succeeds."
57
58 origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED)
59
60 function cleanup
61 {
62         if poolexists $TESTPOOL-l2arc ; then
63                 destroy_pool $TESTPOOL-l2arc
64         fi
65
66         log_must set_tunable64 COMPRESSED_ARC_ENABLED $origin_carc_setting
67 }
68 log_onexit cleanup
69
70 log_must rm -rf $VDIR
71 log_must mkdir -p $VDIR
72 log_must mkfile $SIZE $VDEV
73
74 # Disable Compressed ARC so that in-ARC and on-disk will not match
75 log_must set_tunable64 COMPRESSED_ARC_ENABLED 0
76
77 typeset fill_mb=800
78 typeset cache_sz=$(( floor($fill_mb / 2) ))
79 export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
80
81 log_must truncate -s ${cache_sz}M $VDEV_CACHE
82
83 log_must zpool create -O compression=zstd -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE
84
85 log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
86         "-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
87         "$TESTPOOL-l2arc/encrypted"
88
89 l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
90
91 log_must fio $FIO_SCRIPTS/mkfiles.fio
92 log_must fio $FIO_SCRIPTS/random_reads.fio
93
94 l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
95
96 log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
97         "$l2_cksum_bad_end"
98 log_must test $(( $l2_cksum_bad_end - $l2_cksum_bad_start )) -eq 0
99
100 log_must zpool destroy -f $TESTPOOL-l2arc
101
102 log_pass "L2ARC with encryption enabled and compressed_arc disabled does not"\
103         "result in checksum errors."