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# Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not 27# present. 28# 29# STRATEGY: 30# 1. Create pool with a cache device. 31# 2. Create a random file in that pool and random read for 10 sec. 32# 3. Read the amount of log blocks written from the header of the 33# L2ARC device. 34# 4. Offline the L2ARC device and export pool. 35# 5. Import pool and online the L2ARC device. 36# 6. Read the amount of log blocks rebuilt in arcstats and compare to 37# (3). 38# 7. Check if the labels of the L2ARC device are intact. 39# 40 41verify_runnable "global" 42 43log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." 44 45function cleanup 46{ 47 if poolexists $TESTPOOL ; then 48 destroy_pool $TESTPOOL 49 fi 50 51 log_must set_tunable32 l2arc_noprefetch $noprefetch 52 log_must set_tunable32 l2arc_rebuild_blocks_min_l2size \ 53 $rebuild_blocks_min_l2size 54} 55log_onexit cleanup 56 57# l2arc_noprefetch is set to 0 to let L2ARC handle prefetches 58typeset noprefetch=$(get_tunable l2arc_noprefetch) 59typeset rebuild_blocks_min_l2size=$(get_tunable l2arc_rebuild_blocks_min_l2size) 60log_must set_tunable32 l2arc_noprefetch 0 61log_must set_tunable32 l2arc_rebuild_blocks_min_l2size 0 62 63typeset fill_mb=800 64typeset cache_sz=$(( floor($fill_mb / 2) )) 65export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 66 67log_must truncate -s ${cache_sz}M $VDEV_CACHE 68 69log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 70 71log_must fio $FIO_SCRIPTS/mkfiles.fio 72log_must fio $FIO_SCRIPTS/random_reads.fio 73 74arcstat_quiescence_noecho l2_size 75log_must zpool offline $TESTPOOL $VDEV_CACHE 76arcstat_quiescence_noecho l2_size 77log_must zpool export $TESTPOOL 78arcstat_quiescence_noecho l2_feeds 79 80typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) 81typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ 82 awk '{print $2}') 83 84log_must zpool import -d $VDIR $TESTPOOL 85log_must zpool online $TESTPOOL $VDEV_CACHE 86arcstat_quiescence_noecho l2_size 87 88typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) 89 90log_must test $l2_dh_log_blk -eq $(( $l2_rebuild_log_blk_end - \ 91 $l2_rebuild_log_blk_start )) 92log_must test $l2_dh_log_blk -gt 0 93 94log must zpool offline $TESTPOOL $VDEV_CACHE 95arcstat_quiescence_noecho l2_size 96 97log_must zdb -lq $VDEV_CACHE 98 99log_must zpool destroy -f $TESTPOOL 100 101log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." 102