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# Persistent L2ARC restores all written log blocks 27# 28# STRATEGY: 29# 1. Create pool with a cache device. 30# 2. Create a random file in that pool, smaller than the cache device 31# and random read for 10 sec. 32# 3. Export pool. 33# 4. Read amount of log blocks written. 34# 5. Import pool. 35# 6. Read amount of log blocks built. 36# 7. Compare the two amounts. 37# 8. Read the file written in (2) and check if l2_hits in 38# /proc/spl/kstat/zfs/arcstats increased. 39# 9. Check if the labels of the L2ARC device are intact. 40# 41 42verify_runnable "global" 43 44log_assert "Persistent L2ARC restores all written log blocks." 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} 54log_onexit cleanup 55 56# l2arc_noprefetch is set to 0 to let L2ARC handle prefetches 57typeset noprefetch=$(get_tunable l2arc_noprefetch) 58log_must set_tunable32 l2arc_noprefetch 0 59 60typeset fill_mb=800 61typeset cache_sz=$(( 2 * $fill_mb )) 62export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 63 64log_must truncate -s ${cache_sz}M $VDEV_CACHE 65 66typeset log_blk_start=$(get_arcstat l2_log_blk_writes) 67 68log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 69 70log_must fio $FIO_SCRIPTS/mkfiles.fio 71log_must fio $FIO_SCRIPTS/random_reads.fio 72 73arcstat_quiescence_noecho l2_size 74log_must zpool export $TESTPOOL 75arcstat_quiescence_noecho l2_feeds 76 77typeset log_blk_end=$(get_arcstat l2_log_blk_writes) 78typeset log_blk_rebuild_start=$(get_arcstat l2_rebuild_log_blks) 79 80log_must zpool import -d $VDIR $TESTPOOL 81 82typeset l2_hits_start=$(get_arcstat l2_hits) 83 84log_must fio $FIO_SCRIPTS/random_reads.fio 85arcstat_quiescence_noecho l2_size 86 87typeset log_blk_rebuild_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) 88typeset l2_hits_end=$(get_arcstat l2_hits) 89 90log_must test $(( $log_blk_rebuild_end - $log_blk_rebuild_start )) -eq \ 91 $(( $log_blk_end - $log_blk_start )) 92 93log_must test $l2_hits_end -gt $l2_hits_start 94 95log_must zpool offline $TESTPOOL $VDEV_CACHE 96arcstat_quiescence_noecho l2_size 97 98log_must zdb -lq $VDEV_CACHE 99 100log_must zpool destroy -f $TESTPOOL 101 102log_pass "Persistent L2ARC restores all written log blocks." 103