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 42log_assert "l2arc_mfuonly does not cache MRU buffers." 43 44function cleanup 45{ 46 if poolexists $TESTPOOL ; then 47 destroy_pool $TESTPOOL 48 fi 49 50 log_must set_tunable32 l2arc_noprefetch $noprefetch 51 log_must set_tunable32 l2arc_mfuonly $mfuonly 52 log_must set_tunable32 zfs_prefetch_disable $zfsprefetch 53} 54log_onexit cleanup 55 56# l2arc_noprefetch is set to 1 as some prefetched buffers may 57# transition to MRU. 58typeset noprefetch=$(get_tunable l2arc_noprefetch) 59log_must set_tunable32 l2arc_noprefetch 1 60 61typeset mfuonly=$(get_tunable l2arc_mfuonly) 62log_must set_tunable32 l2arc_mfuonly 1 63 64typeset zfsprefetch=$(get_tunable zfs_prefetch_disable) 65log_must set_tunable32 zfs_prefetch_disable 1 66 67typeset fill_mb=800 68typeset cache_sz=$(( 1.4 * $fill_mb )) 69export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 70 71log_must truncate -s ${cache_sz}M $VDEV_CACHE 72 73typeset log_blk_start=$(get_arcstat l2_log_blk_writes) 74 75log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 76 77log_must fio $FIO_SCRIPTS/mkfiles.fio 78log_must fio $FIO_SCRIPTS/random_reads.fio 79 80log_must zpool export $TESTPOOL 81log_must zpool import -d $VDIR $TESTPOOL 82 83# Regardless of l2arc_noprefetch, some MFU buffers might be evicted 84# from ARC, accessed later on as prefetches and transition to MRU as 85# prefetches. 86# If accessed again they are counted as MRU and the l2arc_mru_asize arcstat 87# will not be 0 (mentioned also in zfs-module-parameters.5) 88# For the purposes of this test we mitigate this by disabling (predictive) 89# ZFS prefetches with zfs_prefetch_disable=1. 90log_must test $(get_arcstat l2_mru_asize) -eq 0 91 92log_must zpool destroy -f $TESTPOOL 93 94log_pass "l2arc_mfuonly does not cache MRU buffers." 95