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, George Amanakis. 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_mfuonly does not cache MRU buffers 27# 28# STRATEGY: 29# 1. Set l2arc_mfuonly=yes 30# 2. Create pool with a cache device. 31# 3. Create a random file in that pool, smaller than the cache device 32# and random read for 10 sec. 33# 4. Export and re-import the pool. This is necessary as some MFU ghost 34# buffers with prefetch status may transition to MRU eventually. 35# By re-importing the pool the l2 arcstats reflect the ARC state 36# of L2ARC buffers upon their caching in L2ARC. 37# 5. Verify l2arc_mru_asize is 0. 38# 39 40verify_runnable "global" 41 42command -v fio > /dev/null || log_unsupported "fio missing" 43 44log_assert "l2arc_mfuonly does not cache MRU buffers." 45 46function cleanup 47{ 48 if poolexists $TESTPOOL ; then 49 destroy_pool $TESTPOOL 50 fi 51 52 log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch 53 log_must set_tunable32 L2ARC_MFUONLY $mfuonly 54 log_must set_tunable32 PREFETCH_DISABLE $zfsprefetch 55} 56log_onexit cleanup 57 58# L2ARC_NOPREFETCH is set to 1 as some prefetched buffers may 59# transition to MRU. 60typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) 61log_must set_tunable32 L2ARC_NOPREFETCH 1 62 63typeset mfuonly=$(get_tunable L2ARC_MFUONLY) 64log_must set_tunable32 L2ARC_MFUONLY 1 65 66typeset zfsprefetch=$(get_tunable PREFETCH_DISABLE) 67log_must set_tunable32 PREFETCH_DISABLE 1 68 69typeset fill_mb=800 70typeset cache_sz=$(( 1.4 * $fill_mb )) 71export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 72 73log_must truncate -s ${cache_sz}M $VDEV_CACHE 74 75typeset log_blk_start=$(get_arcstat l2_log_blk_writes) 76 77log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 78 79log_must fio $FIO_SCRIPTS/mkfiles.fio 80log_must fio $FIO_SCRIPTS/random_reads.fio 81 82log_must zpool export $TESTPOOL 83log_must zpool import -d $VDIR $TESTPOOL 84 85# Regardless of l2arc_noprefetch, some MFU buffers might be evicted 86# from ARC, accessed later on as prefetches and transition to MRU as 87# prefetches. 88# If accessed again they are counted as MRU and the l2arc_mru_asize arcstat 89# will not be 0 (mentioned also in zfs.4) 90# For the purposes of this test we mitigate this by disabling (predictive) 91# ZFS prefetches with zfs_prefetch_disable=1. 92log_must test $(get_arcstat l2_mru_asize) -eq 0 93 94log_must zpool destroy -f $TESTPOOL 95 96log_pass "l2arc_mfuonly does not cache MRU buffers." 97