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 fails as expected when l2arc_rebuild_enabled = 0 27# 28# STRATEGY: 29# 1. Set l2arc_rebuild_enabled = 0 30# 2. Create pool with a cache device. 31# 3. Create a random file in that pool and random read for 10 sec. 32# 4. Export pool. 33# 5. Import pool. 34# 6. Check in zpool iostat if the cache device has space allocated. 35# 7. Read the file written in (3) and check if l2_hits in 36# /proc/spl/kstat/zfs/arcstats increased. 37# 38 39verify_runnable "global" 40 41log_assert "Persistent L2ARC fails as expected when l2arc_rebuild_enabled = 0." 42 43function cleanup 44{ 45 if poolexists $TESTPOOL ; then 46 destroy_pool $TESTPOOL 47 fi 48 49 log_must set_tunable32 l2arc_rebuild_enabled $rebuild_enabled 50 log_must set_tunable32 l2arc_noprefetch $noprefetch 51} 52log_onexit cleanup 53 54# l2arc_noprefetch is set to 0 to let L2ARC handle prefetches 55typeset noprefetch=$(get_tunable l2arc_noprefetch) 56log_must set_tunable32 l2arc_noprefetch 0 57 58# disable L2ARC rebuild 59typeset rebuild_enabled=$(get_tunable l2arc_rebuild_enabled) 60log_must set_tunable32 l2arc_rebuild_enabled 0 61 62typeset fill_mb=800 63typeset cache_sz=$(( 2 * $fill_mb )) 64export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 65 66log_must truncate -s ${cache_sz}M $VDEV_CACHE 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 73log_must zpool export $TESTPOOL 74 75typeset l2_success_start=$(get_arcstat l2_rebuild_success) 76 77log_must zpool import -d $VDIR $TESTPOOL 78log_mustnot test "$(zpool iostat -Hpv $TESTPOOL $VDEV_CACHE | awk '{print $2}')" -gt 80000000 79 80typeset l2_success_end=$(get_arcstat l2_rebuild_success) 81 82log_mustnot test $l2_success_end -gt $l2_success_start 83 84log_must zpool destroy -f $TESTPOOL 85log_must set_tunable32 l2arc_rebuild_enabled $rebuild_enabled 86 87log_pass "Persistent L2ARC fails as expected when l2arc_rebuild_enabled = 0." 88