1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# This file and its contents are supplied under the terms of the 7# Common Development and Distribution License ("CDDL"), version 1.0. 8# You may only use this file in accordance with the terms of version 9# 1.0 of the CDDL. 10# 11# A full copy of the text of the CDDL should have accompanied this 12# source. A copy of the CDDL is also available via the Internet at 13# http://www.illumos.org/license/CDDL. 14# 15# CDDL HEADER END 16# 17 18# 19# Copyright (c) 2020, Adam Moss. All rights reserved. 20# 21 22. $STF_SUITE/include/libtest.shlib 23. $STF_SUITE/tests/functional/l2arc/l2arc.cfg 24 25# 26# DESCRIPTION: 27# l2arc_misses does not increment upon reads from a pool without l2arc 28# 29# STRATEGY: 30# 1. Create pool with a cache device. 31# 2. Create pool without a cache device. 32# 3. Create a random file in the no-cache-device pool, 33# and random read for 10 sec. 34# 4. Check that l2arc_misses hasn't risen 35# 5. Create a random file in the pool with the cache device, 36# and random read for 10 sec. 37# 6. Check that l2arc_misses has risen 38# 39 40verify_runnable "global" 41 42command -v fio > /dev/null || log_unsupported "fio missing" 43 44log_assert "l2arc_misses does not increment upon reads from a pool without l2arc." 45 46function cleanup 47{ 48 if poolexists $TESTPOOL ; then 49 destroy_pool $TESTPOOL 50 fi 51 if poolexists $TESTPOOL1 ; then 52 destroy_pool $TESTPOOL1 53 fi 54} 55log_onexit cleanup 56 57typeset fill_mb=800 58typeset cache_sz=$(( 1.4 * $fill_mb )) 59export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 60 61log_must truncate -s ${cache_sz}M $VDEV_CACHE 62 63log_must zpool create -O compression=off -f $TESTPOOL $VDEV cache $VDEV_CACHE 64log_must zpool create -O compression=off -f $TESTPOOL1 $VDEV1 65 66# I/O to pool without l2arc - expect that l2_misses stays constant 67export DIRECTORY=/$TESTPOOL1 68log_must fio $FIO_SCRIPTS/mkfiles.fio 69log_must fio $FIO_SCRIPTS/random_reads.fio 70# attempt to remove entries for pool from ARC so we would try 71# to hit the nonexistent L2ARC for subsequent reads 72log_must zpool export $TESTPOOL1 73log_must zpool import $TESTPOOL1 -d $VDEV1 74 75typeset starting_miss_count=$(kstat arcstats.l2_misses) 76 77log_must fio $FIO_SCRIPTS/random_reads.fio 78log_must test $(kstat arcstats.l2_misses) -eq $starting_miss_count 79 80# I/O to pool with l2arc - expect that l2_misses rises 81export DIRECTORY=/$TESTPOOL 82log_must fio $FIO_SCRIPTS/mkfiles.fio 83log_must fio $FIO_SCRIPTS/random_reads.fio 84# wait for L2ARC writes to actually happen 85arcstat_quiescence_noecho l2_size 86# attempt to remove entries for pool from ARC so we would try 87# to hit L2ARC for subsequent reads 88log_must zpool export $TESTPOOL 89log_must zpool import $TESTPOOL -d $VDEV 90 91log_must fio $FIO_SCRIPTS/random_reads.fio 92log_must test $(kstat arcstats.l2_misses) -gt $starting_miss_count 93 94log_must zpool destroy -f $TESTPOOL 95log_must zpool destroy -f $TESTPOOL1 96 97log_pass "l2arc_misses does not increment upon reads from a pool without l2arc." 98