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 restores all written blocks, vdev present. 27# 28# STRATEGY: 29# 1. Create pool with a cache device. 30# 2. Create a random file in that pool and random read for 10 sec. 31# 3. Read the amount of log blocks written from the header of the 32# L2ARC device. 33# 4. Offline the L2ARC device. 34# 5. Online the L2ARC device. 35# 6. Read the amount of log blocks rebuilt in arcstats and compare to 36# (3). 37# 7. Create another random file in that pool and random read for 10 sec. 38# 8. Read the amount of log blocks written from the header of the 39# L2ARC device. 40# 9. Offline the L2ARC device. 41# 10. Online the L2ARC device. 42# 11. Read the amount of log blocks rebuilt in arcstats and compare to 43# (8). 44# 12. Check if the amount of log blocks on the cache device has 45# increased. 46# 13. Export the pool. 47# 14. Read the amount of log blocks on the cache device. 48# 15. Import the pool. 49# 16. Read the amount of log blocks rebuilt in arcstats and compare to 50# (14). 51# 17. Check if the labels of the L2ARC device are intact. 52# 53 54verify_runnable "global" 55 56log_assert "Off/onlining an L2ARC device restores all written blocks , vdev present." 57 58function cleanup 59{ 60 if poolexists $TESTPOOL ; then 61 destroy_pool $TESTPOOL 62 fi 63 64 log_must set_tunable32 l2arc_noprefetch $noprefetch 65} 66log_onexit cleanup 67 68# l2arc_noprefetch is set to 0 to let L2ARC handle prefetches 69typeset noprefetch=$(get_tunable l2arc_noprefetch) 70log_must set_tunable32 l2arc_noprefetch 0 71 72typeset fill_mb=400 73typeset cache_sz=$(( 3 * $fill_mb )) 74export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M 75 76log_must truncate -s ${cache_sz}M $VDEV_CACHE 77 78log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE 79 80log_must fio $FIO_SCRIPTS/mkfiles.fio 81log_must fio $FIO_SCRIPTS/random_reads.fio 82 83arcstat_quiescence_noecho l2_size 84log_must zpool offline $TESTPOOL $VDEV_CACHE 85arcstat_quiescence_noecho l2_size 86 87typeset l2_dh_log_blk1=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ 88 awk '{print $2}') 89typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) 90 91log_must zpool online $TESTPOOL $VDEV_CACHE 92arcstat_quiescence_noecho l2_size 93 94typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) 95 96log_must test $l2_dh_log_blk1 -eq $(( $l2_rebuild_log_blk_end - \ 97 $l2_rebuild_log_blk_start )) 98log_must test $l2_dh_log_blk1 -gt 0 99 100log_must fio $FIO_SCRIPTS/mkfiles.fio 101log_must fio $FIO_SCRIPTS/random_reads.fio 102 103arcstat_quiescence_noecho l2_size 104log_must zpool offline $TESTPOOL $VDEV_CACHE 105arcstat_quiescence_noecho l2_size 106 107typeset l2_dh_log_blk2=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ 108 awk '{print $2}') 109typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) 110 111log_must zpool online $TESTPOOL $VDEV_CACHE 112arcstat_quiescence_noecho l2_size 113 114typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) 115 116log_must test $l2_dh_log_blk2 -eq $(( $l2_rebuild_log_blk_end - \ 117 $l2_rebuild_log_blk_start )) 118log_must test $l2_dh_log_blk2 -gt $l2_dh_log_blk1 119 120log_must zpool export $TESTPOOL 121arcstat_quiescence_noecho l2_feeds 122 123typeset l2_dh_log_blk3=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ 124 awk '{print $2}') 125typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) 126 127log_must zpool import -d $VDIR $TESTPOOL 128arcstat_quiescence_noecho l2_size 129 130typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) 131 132log_must test $l2_dh_log_blk3 -eq $(( $l2_rebuild_log_blk_end - \ 133 $l2_rebuild_log_blk_start )) 134log_must test $l2_dh_log_blk3 -gt 0 135 136log must zpool offline $TESTPOOL $VDEV_CACHE 137arcstat_quiescence_noecho l2_size 138 139log_must zdb -lq $VDEV_CACHE 140 141log_must zpool destroy -f $TESTPOOL 142 143log_pass "Off/onlining an L2ARC device restores all written blocks, vdev present." 144