]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh
Move properties, parameters, events, and concepts around manual sections
[mirror_zfs.git] / tests / zfs-tests / tests / functional / l2arc / l2arc_mfuonly_pos.ksh
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
40 verify_runnable "global"
41
42 log_assert "l2arc_mfuonly does not cache MRU buffers."
43
44 function 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 PREFETCH_DISABLE $zfsprefetch
53 }
54 log_onexit cleanup
55
56 # L2ARC_NOPREFETCH is set to 1 as some prefetched buffers may
57 # transition to MRU.
58 typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH)
59 log_must set_tunable32 L2ARC_NOPREFETCH 1
60
61 typeset mfuonly=$(get_tunable L2ARC_MFUONLY)
62 log_must set_tunable32 L2ARC_MFUONLY 1
63
64 typeset zfsprefetch=$(get_tunable PREFETCH_DISABLE)
65 log_must set_tunable32 PREFETCH_DISABLE 1
66
67 typeset fill_mb=800
68 typeset cache_sz=$(( 1.4 * $fill_mb ))
69 export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
70
71 log_must truncate -s ${cache_sz}M $VDEV_CACHE
72
73 typeset log_blk_start=$(get_arcstat l2_log_blk_writes)
74
75 log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE
76
77 log_must fio $FIO_SCRIPTS/mkfiles.fio
78 log_must fio $FIO_SCRIPTS/random_reads.fio
79
80 log_must zpool export $TESTPOOL
81 log_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.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
91
92 log_must zpool destroy -f $TESTPOOL
93
94 log_pass "l2arc_mfuonly does not cache MRU buffers."