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, Adam Moss. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/l2arc/l2arc.cfg 23 24# 25# DESCRIPTION: 26# l2arc_misses does not increment upon reads from a pool without l2arc 27# 28# STRATEGY: 29# 1. Create pool with a cache device. 30# 2. Create pool without a cache device. 31# 3. Create a random file in the no-cache-device pool, 32# and random read for 10 sec. 33# 4. Check that l2arc_misses hasn't risen 34# 5. Create a random file in the pool with the cache device, 35# and random read for 10 sec. 36# 6. Check that l2arc_misses has risen 37# 38 39verify_runnable "global" 40 41command -v fio > /dev/null || log_unsupported "fio missing" 42 43log_assert "l2arc_misses does not increment upon reads from a pool without l2arc." 44 45function cleanup 46{ 47 if poolexists $TESTPOOL ; then 48 destroy_pool $TESTPOOL 49 fi 50 if poolexists $TESTPOOL1 ; then 51 destroy_pool $TESTPOOL1 52 fi 53} 54log_onexit cleanup 55 56typeset fill_mb=800 57typeset cache_sz=$(( 1.4 * $fill_mb )) 58export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 59 60log_must truncate -s ${cache_sz}M $VDEV_CACHE 61 62log_must zpool create -O compression=off -f $TESTPOOL $VDEV cache $VDEV_CACHE 63log_must zpool create -O compression=off -f $TESTPOOL1 $VDEV1 64 65# I/O to pool without l2arc - expect that l2_misses stays constant 66export DIRECTORY=/$TESTPOOL1 67log_must fio $FIO_SCRIPTS/mkfiles.fio 68log_must fio $FIO_SCRIPTS/random_reads.fio 69# attempt to remove entries for pool from ARC so we would try 70# to hit the nonexistent L2ARC for subsequent reads 71log_must zpool export $TESTPOOL1 72log_must zpool import $TESTPOOL1 -d $VDEV1 73 74typeset starting_miss_count=$(get_arcstat l2_misses) 75 76log_must fio $FIO_SCRIPTS/random_reads.fio 77log_must test $(get_arcstat l2_misses) -eq $starting_miss_count 78 79# I/O to pool with l2arc - expect that l2_misses rises 80export DIRECTORY=/$TESTPOOL 81log_must fio $FIO_SCRIPTS/mkfiles.fio 82log_must fio $FIO_SCRIPTS/random_reads.fio 83# wait for L2ARC writes to actually happen 84arcstat_quiescence_noecho l2_size 85# attempt to remove entries for pool from ARC so we would try 86# to hit L2ARC for subsequent reads 87log_must zpool export $TESTPOOL 88log_must zpool import $TESTPOOL -d $VDEV 89 90log_must fio $FIO_SCRIPTS/random_reads.fio 91log_must test $(get_arcstat l2_misses) -gt $starting_miss_count 92 93log_must zpool destroy -f $TESTPOOL 94log_must zpool destroy -f $TESTPOOL1 95 96log_pass "l2arc_misses does not increment upon reads from a pool without l2arc." 97