aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh
blob: 783484f52c13c13e747d60a7538d3bc0bd0dfcd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#

#
# Copyright (c) 2020, Adam Moss. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/l2arc/l2arc.cfg

#
# DESCRIPTION:
#	l2arc_misses does not increment upon reads from a pool without l2arc
#
# STRATEGY:
#	1. Create pool with a cache device.
#	2. Create pool without a cache device.
#	3. Create a random file in the no-cache-device pool,
#		and random read for 10 sec.
#	4. Check that l2arc_misses hasn't risen
#	5. Create a random file in the pool with the cache device,
#		and random read for 10 sec.
#	6. Check that l2arc_misses has risen
#

verify_runnable "global"

log_assert "l2arc_misses does not increment upon reads from a pool without l2arc."

function cleanup
{
	if poolexists $TESTPOOL ; then
		destroy_pool $TESTPOOL
	fi
	if poolexists $TESTPOOL1 ; then
		destroy_pool $TESTPOOL1
	fi
}
log_onexit cleanup

typeset fill_mb=800
typeset cache_sz=$(( 1.4 * $fill_mb ))
export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M

log_must truncate -s ${cache_sz}M $VDEV_CACHE

log_must zpool create -O compression=off -f $TESTPOOL $VDEV cache $VDEV_CACHE
log_must zpool create -O compression=off -f $TESTPOOL1 $VDEV1

# I/O to pool without l2arc - expect that l2_misses stays constant
export DIRECTORY=/$TESTPOOL1
log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio
# attempt to remove entries for pool from ARC so we would try
#    to hit the nonexistent L2ARC for subsequent reads
log_must zpool export $TESTPOOL1
log_must zpool import $TESTPOOL1 -d $VDEV1

typeset starting_miss_count=$(get_arcstat l2_misses)

log_must fio $FIO_SCRIPTS/random_reads.fio
log_must test $(get_arcstat l2_misses) -eq $starting_miss_count

# I/O to pool with l2arc - expect that l2_misses rises
export DIRECTORY=/$TESTPOOL
log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio
# wait for L2ARC writes to actually happen
arcstat_quiescence_noecho l2_size
# attempt to remove entries for pool from ARC so we would try
#    to hit L2ARC for subsequent reads
log_must zpool export $TESTPOOL
log_must zpool import $TESTPOOL -d $VDEV

log_must fio $FIO_SCRIPTS/random_reads.fio
log_must test $(get_arcstat l2_misses) -gt $starting_miss_count

log_must zpool destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL1

log_pass "l2arc_misses does not increment upon reads from a pool without l2arc."