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 41command -v fio > /dev/null || log_unsupported "fio missing" 42 43log_assert "Persistent L2ARC fails as expected when L2ARC_REBUILD_ENABLED = 0." 44 45function cleanup 46{ 47 if poolexists $TESTPOOL ; then 48 destroy_pool $TESTPOOL 49 fi 50 51 log_must set_tunable32 L2ARC_REBUILD_ENABLED $rebuild_enabled 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 60# disable L2ARC rebuild 61typeset rebuild_enabled=$(get_tunable L2ARC_REBUILD_ENABLED) 62log_must set_tunable32 L2ARC_REBUILD_ENABLED 0 63 64typeset fill_mb=800 65typeset cache_sz=$(( 2 * $fill_mb )) 66export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 67 68log_must truncate -s ${cache_sz}M $VDEV_CACHE 69 70log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 71 72log_must fio $FIO_SCRIPTS/mkfiles.fio 73log_must fio $FIO_SCRIPTS/random_reads.fio 74 75log_must zpool export $TESTPOOL 76 77typeset l2_success_start=$(get_arcstat l2_rebuild_success) 78 79log_must zpool import -d $VDIR $TESTPOOL 80log_mustnot test "$(zpool iostat -Hpv $TESTPOOL $VDEV_CACHE | awk '{print $2}')" -gt 80000000 81 82typeset l2_success_end=$(get_arcstat l2_rebuild_success) 83 84log_mustnot test $l2_success_end -gt $l2_success_start 85 86log_must zpool destroy -f $TESTPOOL 87log_must set_tunable32 L2ARC_REBUILD_ENABLED $rebuild_enabled 88 89log_pass "Persistent L2ARC fails as expected when L2ARC_REBUILD_ENABLED = 0." 90