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
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.
18 # Copyright (c) 2020, George Amanakis. All rights reserved.
21 .
$STF_SUITE/include
/libtest.shlib
22 .
$STF_SUITE/tests
/functional
/l2arc
/l2arc.cfg
26 # l2arc_mfuonly does not cache MRU buffers
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.
40 verify_runnable
"global"
42 log_assert
"l2arc_mfuonly does not cache MRU buffers."
46 if poolexists
$TESTPOOL ; then
47 destroy_pool
$TESTPOOL
50 log_must set_tunable32 L2ARC_NOPREFETCH
$noprefetch
51 log_must set_tunable32 L2ARC_MFUONLY
$mfuonly
52 log_must set_tunable32 PREFETCH_DISABLE
$zfsprefetch
56 # L2ARC_NOPREFETCH is set to 1 as some prefetched buffers may
58 typeset noprefetch
=$
(get_tunable L2ARC_NOPREFETCH
)
59 log_must set_tunable32 L2ARC_NOPREFETCH
1
61 typeset mfuonly
=$
(get_tunable L2ARC_MFUONLY
)
62 log_must set_tunable32 L2ARC_MFUONLY
1
64 typeset zfsprefetch
=$
(get_tunable PREFETCH_DISABLE
)
65 log_must set_tunable32 PREFETCH_DISABLE
1
68 typeset cache_sz
=$
(( 1.4 * $fill_mb ))
69 export FILE_SIZE
=$
(( floor
($fill_mb / $NUMJOBS) ))M
71 log_must truncate
-s ${cache_sz}M
$VDEV_CACHE
73 typeset log_blk_start
=$
(get_arcstat l2_log_blk_writes
)
75 log_must zpool create
-f $TESTPOOL $VDEV cache
$VDEV_CACHE
77 log_must fio
$FIO_SCRIPTS/mkfiles.fio
78 log_must fio
$FIO_SCRIPTS/random_reads.fio
80 log_must zpool
export $TESTPOOL
81 log_must zpool import
-d $VDIR $TESTPOOL
83 # Regardless of l2arc_noprefetch, some MFU buffers might be evicted
84 # from ARC, accessed later on as prefetches and transition to MRU as
86 # If accessed again they are counted as MRU and the l2arc_mru_asize arcstat
87 # will not be 0 (mentioned also in zfs.4)
88 # For the purposes of this test we mitigate this by disabling (predictive)
89 # ZFS prefetches with zfs_prefetch_disable=1.
90 log_must
test $
(get_arcstat l2_mru_asize
) -eq 0
92 log_must zpool destroy
-f $TESTPOOL
94 log_pass
"l2arc_mfuonly does not cache MRU buffers."