diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 593ac863cf..81cb4dabc0 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -9743,85 +9743,12 @@ l2arc_vdev_get(vdev_t *vd) return (dev); } -/* - * Add a vdev for use by the L2ARC. By this point the spa has already - * validated the vdev and opened it. - */ -void -l2arc_add_vdev(spa_t *spa, vdev_t *vd) +static void +l2arc_rebuild_dev(l2arc_dev_t *dev, boolean_t reopen) { - l2arc_dev_t *adddev; - uint64_t l2dhdr_asize; - - ASSERT(!l2arc_vdev_present(vd)); - - /* - * Create a new l2arc device entry. - */ - adddev = vmem_zalloc(sizeof (l2arc_dev_t), KM_SLEEP); - adddev->l2ad_spa = spa; - adddev->l2ad_vdev = vd; - /* leave extra size for an l2arc device header */ - l2dhdr_asize = adddev->l2ad_dev_hdr_asize = - MAX(sizeof (*adddev->l2ad_dev_hdr), 1 << vd->vdev_ashift); - adddev->l2ad_start = VDEV_LABEL_START_SIZE + l2dhdr_asize; - adddev->l2ad_end = VDEV_LABEL_START_SIZE + vdev_get_min_asize(vd); - ASSERT3U(adddev->l2ad_start, <, adddev->l2ad_end); - adddev->l2ad_hand = adddev->l2ad_start; - adddev->l2ad_evict = adddev->l2ad_start; - adddev->l2ad_first = B_TRUE; - adddev->l2ad_writing = B_FALSE; - adddev->l2ad_trim_all = B_FALSE; - list_link_init(&adddev->l2ad_node); - adddev->l2ad_dev_hdr = kmem_zalloc(l2dhdr_asize, KM_SLEEP); - - mutex_init(&adddev->l2ad_mtx, NULL, MUTEX_DEFAULT, NULL); - /* - * This is a list of all ARC buffers that are still valid on the - * device. - */ - list_create(&adddev->l2ad_buflist, sizeof (arc_buf_hdr_t), - offsetof(arc_buf_hdr_t, b_l2hdr.b_l2node)); - - /* - * This is a list of pointers to log blocks that are still present - * on the device. - */ - list_create(&adddev->l2ad_lbptr_list, sizeof (l2arc_lb_ptr_buf_t), - offsetof(l2arc_lb_ptr_buf_t, node)); - - vdev_space_update(vd, 0, 0, adddev->l2ad_end - adddev->l2ad_hand); - zfs_refcount_create(&adddev->l2ad_alloc); - zfs_refcount_create(&adddev->l2ad_lb_asize); - zfs_refcount_create(&adddev->l2ad_lb_count); - - /* - * Add device to global list - */ - mutex_enter(&l2arc_dev_mtx); - list_insert_head(l2arc_dev_list, adddev); - atomic_inc_64(&l2arc_ndev); - mutex_exit(&l2arc_dev_mtx); - - /* - * Decide if vdev is eligible for L2ARC rebuild - */ - l2arc_rebuild_vdev(adddev->l2ad_vdev, B_FALSE); -} - -void -l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen) -{ - l2arc_dev_t *dev = NULL; - l2arc_dev_hdr_phys_t *l2dhdr; - uint64_t l2dhdr_asize; - spa_t *spa; - - dev = l2arc_vdev_get(vd); - ASSERT3P(dev, !=, NULL); - spa = dev->l2ad_spa; - l2dhdr = dev->l2ad_dev_hdr; - l2dhdr_asize = dev->l2ad_dev_hdr_asize; + l2arc_dev_hdr_phys_t *l2dhdr = dev->l2ad_dev_hdr; + uint64_t l2dhdr_asize = dev->l2ad_dev_hdr_asize; + spa_t *spa = dev->l2ad_spa; /* * The L2ARC has to hold at least the payload of one log block for @@ -9890,6 +9817,106 @@ l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen) } } +/* + * Add a vdev for use by the L2ARC. By this point the spa has already + * validated the vdev and opened it. + */ +void +l2arc_add_vdev(spa_t *spa, vdev_t *vd) +{ + l2arc_dev_t *adddev; + uint64_t l2dhdr_asize; + + ASSERT(!l2arc_vdev_present(vd)); + + /* + * Create a new l2arc device entry. + */ + adddev = vmem_zalloc(sizeof (l2arc_dev_t), KM_SLEEP); + adddev->l2ad_spa = spa; + adddev->l2ad_vdev = vd; + /* leave extra size for an l2arc device header */ + l2dhdr_asize = adddev->l2ad_dev_hdr_asize = + MAX(sizeof (*adddev->l2ad_dev_hdr), 1 << vd->vdev_ashift); + adddev->l2ad_start = VDEV_LABEL_START_SIZE + l2dhdr_asize; + adddev->l2ad_end = VDEV_LABEL_START_SIZE + vdev_get_min_asize(vd); + ASSERT3U(adddev->l2ad_start, <, adddev->l2ad_end); + adddev->l2ad_hand = adddev->l2ad_start; + adddev->l2ad_evict = adddev->l2ad_start; + adddev->l2ad_first = B_TRUE; + adddev->l2ad_writing = B_FALSE; + adddev->l2ad_trim_all = B_FALSE; + list_link_init(&adddev->l2ad_node); + adddev->l2ad_dev_hdr = kmem_zalloc(l2dhdr_asize, KM_SLEEP); + + mutex_init(&adddev->l2ad_mtx, NULL, MUTEX_DEFAULT, NULL); + /* + * This is a list of all ARC buffers that are still valid on the + * device. + */ + list_create(&adddev->l2ad_buflist, sizeof (arc_buf_hdr_t), + offsetof(arc_buf_hdr_t, b_l2hdr.b_l2node)); + + /* + * This is a list of pointers to log blocks that are still present + * on the device. + */ + list_create(&adddev->l2ad_lbptr_list, sizeof (l2arc_lb_ptr_buf_t), + offsetof(l2arc_lb_ptr_buf_t, node)); + + vdev_space_update(vd, 0, 0, adddev->l2ad_end - adddev->l2ad_hand); + zfs_refcount_create(&adddev->l2ad_alloc); + zfs_refcount_create(&adddev->l2ad_lb_asize); + zfs_refcount_create(&adddev->l2ad_lb_count); + + /* + * Decide if dev is eligible for L2ARC rebuild or whole device + * trimming. This has to happen before the device is added in the + * cache device list and l2arc_dev_mtx is released. Otherwise + * l2arc_feed_thread() might already start writing on the + * device. + */ + l2arc_rebuild_dev(adddev, B_FALSE); + + /* + * Add device to global list + */ + mutex_enter(&l2arc_dev_mtx); + list_insert_head(l2arc_dev_list, adddev); + atomic_inc_64(&l2arc_ndev); + mutex_exit(&l2arc_dev_mtx); +} + +/* + * Decide if a vdev is eligible for L2ARC rebuild, called from vdev_reopen() + * in case of onlining a cache device. + */ +void +l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen) +{ + l2arc_dev_t *dev = NULL; + + dev = l2arc_vdev_get(vd); + ASSERT3P(dev, !=, NULL); + + /* + * In contrast to l2arc_add_vdev() we do not have to worry about + * l2arc_feed_thread() invalidating previous content when onlining a + * cache device. The device parameters (l2ad*) are not cleared when + * offlining the device and writing new buffers will not invalidate + * all previous content. In worst case only buffers that have not had + * their log block written to the device will be lost. + * When onlining the cache device (ie offline->online without exporting + * the pool in between) this happens: + * vdev_reopen() -> vdev_open() -> l2arc_rebuild_vdev() + * | | + * vdev_is_dead() = B_FALSE l2ad_rebuild = B_TRUE + * During the time where vdev_is_dead = B_FALSE and until l2ad_rebuild + * is set to B_TRUE we might write additional buffers to the device. + */ + l2arc_rebuild_dev(dev, reopen); +} + /* * Remove a vdev from the L2ARC. */ diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 5f5e10d133..2421e8aa46 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -934,8 +934,7 @@ tags = ['functional', 'log_spacemap'] [tests/functional/l2arc] tests = ['l2arc_arcstats_pos', 'l2arc_mfuonly_pos', 'l2arc_l2miss_pos', 'persist_l2arc_001_pos', 'persist_l2arc_002_pos', - 'persist_l2arc_003_neg', 'persist_l2arc_004_pos', 'persist_l2arc_005_pos', - 'persist_l2arc_006_pos', 'persist_l2arc_007_pos', 'persist_l2arc_008_pos'] + 'persist_l2arc_003_neg', 'persist_l2arc_004_pos', 'persist_l2arc_005_pos'] tags = ['functional', 'l2arc'] [tests/functional/zpool_influxdb] diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 8c3bce1349..4661a47f55 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -223,8 +223,6 @@ maybe = { 'history/history_008_pos': ['FAIL', known_reason], 'history/history_010_pos': ['SKIP', exec_reason], 'io/mmap': ['SKIP', fio_reason], - 'l2arc/persist_l2arc_005_pos': ['FAIL', known_reason], - 'l2arc/persist_l2arc_007_pos': ['FAIL', '11887'], 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason], 'mmp/mmp_on_uberblocks': ['FAIL', known_reason], 'pyzfs/pyzfs_unittest': ['SKIP', python_deps_reason], diff --git a/tests/zfs-tests/tests/functional/l2arc/Makefile.am b/tests/zfs-tests/tests/functional/l2arc/Makefile.am index 9baf580eea..09f4c1d0d7 100644 --- a/tests/zfs-tests/tests/functional/l2arc/Makefile.am +++ b/tests/zfs-tests/tests/functional/l2arc/Makefile.am @@ -9,10 +9,7 @@ dist_pkgdata_SCRIPTS = \ persist_l2arc_002_pos.ksh \ persist_l2arc_003_neg.ksh \ persist_l2arc_004_pos.ksh \ - persist_l2arc_005_pos.ksh \ - persist_l2arc_006_pos.ksh \ - persist_l2arc_007_pos.ksh \ - persist_l2arc_008_pos.ksh + persist_l2arc_005_pos.ksh dist_pkgdata_DATA = \ l2arc.cfg diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh index 24fcefadfd..3e76347b02 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh @@ -96,7 +96,6 @@ typeset l2_mru_end=$(get_arcstat l2_mru_asize) typeset l2_prefetch_end=$(get_arcstat l2_prefetch_asize) typeset l2_asize_end=$(get_arcstat l2_asize) -log_must test $(( $l2_mfu_end - $l2_mfu_init )) -gt 0 log_must test $(( $l2_mru_end + $l2_mfu_end + $l2_prefetch_end - \ $l2_asize_end )) -eq 0 log_must test $(( $l2_mru_init + $l2_mfu_init + $l2_prefetch_init - \ diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh index 544e9291de..b407031806 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh @@ -23,25 +23,24 @@ # # DESCRIPTION: -# Persistent L2ARC restores all written log blocks +# Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not +# present. # # STRATEGY: # 1. Create pool with a cache device. -# 2. Create a random file in that pool, smaller than the cache device -# and random read for 10 sec. -# 3. Export pool. -# 4. Read amount of log blocks written. -# 5. Import pool. -# 6. Read amount of log blocks built. -# 7. Compare the two amounts. -# 8. Read the file written in (2) and check if l2_hits in -# /proc/spl/kstat/zfs/arcstats increased. -# 9. Check if the labels of the L2ARC device are intact. +# 2. Create a random file in that pool and random read for 10 sec. +# 3. Read the amount of log blocks written from the header of the +# L2ARC device. +# 4. Offline the L2ARC device and export pool. +# 5. Import pool and online the L2ARC device. +# 6. Read the amount of log blocks rebuilt in arcstats and compare to +# (3). +# 7. Check if the labels of the L2ARC device are intact. # verify_runnable "global" -log_assert "Persistent L2ARC restores all written log blocks." +log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." function cleanup { @@ -50,47 +49,47 @@ function cleanup fi log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch + log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE \ + $rebuild_blocks_min_l2size } log_onexit cleanup # L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) +typeset rebuild_blocks_min_l2size=$(get_tunable L2ARC_REBUILD_BLOCKS_MIN_L2SIZE) log_must set_tunable32 L2ARC_NOPREFETCH 0 +log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE 0 typeset fill_mb=800 -typeset cache_sz=$(( 2 * $fill_mb )) +typeset cache_sz=$(( floor($fill_mb / 2) )) export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M log_must truncate -s ${cache_sz}M $VDEV_CACHE -typeset log_blk_start=$(get_arcstat l2_log_blk_writes) - log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE log_must fio $FIO_SCRIPTS/mkfiles.fio log_must fio $FIO_SCRIPTS/random_reads.fio +arcstat_quiescence_noecho l2_size +log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds -typeset log_blk_end=$(get_arcstat l2_log_blk_writes) -typeset log_blk_rebuild_start=$(get_arcstat l2_rebuild_log_blks) +typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ + awk '{print $2}') log_must zpool import -d $VDIR $TESTPOOL - -typeset l2_hits_start=$(get_arcstat l2_hits) - -log_must fio $FIO_SCRIPTS/random_reads.fio +log_must zpool online $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size -typeset log_blk_rebuild_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) -typeset l2_hits_end=$(get_arcstat l2_hits) +typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) -log_must test $(( $log_blk_rebuild_end - $log_blk_rebuild_start )) -eq \ - $(( $log_blk_end - $log_blk_start )) - -log_must test $l2_hits_end -gt $l2_hits_start +log_must test $l2_dh_log_blk -eq $(( $l2_rebuild_log_blk_end - \ + $l2_rebuild_log_blk_start )) +log_must test $l2_dh_log_blk -gt 0 log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size @@ -99,4 +98,4 @@ log_must zdb -lq $VDEV_CACHE log_must zpool destroy -f $TESTPOOL -log_pass "Persistent L2ARC restores all written log blocks." +log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh index ee46e7b8ca..8ad648519f 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh @@ -20,31 +20,26 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/l2arc/l2arc.cfg -. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib # # DESCRIPTION: -# Persistent L2ARC restores all written log blocks with encryption +# Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present. # # STRATEGY: # 1. Create pool with a cache device. -# 2. Create a an encrypted ZFS file system. -# 3. Create a random file in the entrypted file system, -# smaller than the cache device, and random read for 10 sec. -# 4. Export pool. -# 5. Read amount of log blocks written. -# 6. Import pool. -# 7. Mount the encrypted ZFS file system. -# 8. Read amount of log blocks built. -# 9. Compare the two amounts. -# 10. Read the file written in (3) and check if l2_hits in -# /proc/spl/kstat/zfs/arcstats increased. -# 11. Check if the labels of the L2ARC device are intact. +# 2. Create a random file in that pool and random read for 10 sec. +# 3. Offline the L2ARC device. +# 4. Read the amount of log blocks written from the header of the +# L2ARC device. +# 5. Online the L2ARC device. +# 6. Read the amount of log blocks rebuilt in arcstats and compare to +# (4). +# 7. Check if the labels of the L2ARC device are intact. # verify_runnable "global" -log_assert "Persistent L2ARC restores all written log blocks with encryption." +log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." function cleanup { @@ -53,51 +48,49 @@ function cleanup fi log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch + log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE \ + $rebuild_blocks_min_l2size } log_onexit cleanup # L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) +typeset rebuild_blocks_min_l2size=$(get_tunable L2ARC_REBUILD_BLOCKS_MIN_L2SIZE) log_must set_tunable32 L2ARC_NOPREFETCH 0 +log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE 0 typeset fill_mb=800 -typeset cache_sz=$(( 2 * $fill_mb )) +typeset cache_sz=$(( floor($fill_mb / 2) )) export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M log_must truncate -s ${cache_sz}M $VDEV_CACHE -typeset log_blk_start=$(get_arcstat l2_log_blk_writes) - log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE -log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ - "-o keyformat=passphrase $TESTPOOL/$TESTFS1" - log_must fio $FIO_SCRIPTS/mkfiles.fio log_must fio $FIO_SCRIPTS/random_reads.fio arcstat_quiescence_noecho l2_size -log_must zpool export $TESTPOOL -arcstat_quiescence_noecho l2_feeds - -typeset log_blk_end=$(get_arcstat l2_log_blk_writes) -typeset log_blk_rebuild_start=$(get_arcstat l2_rebuild_log_blks) - -log_must zpool import -d $VDIR $TESTPOOL -log_must eval "echo $PASSPHRASE | zfs mount -l $TESTPOOL/$TESTFS1" - -typeset l2_hits_start=$(get_arcstat l2_hits) - -log_must fio $FIO_SCRIPTS/random_reads.fio +log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size -typeset log_blk_rebuild_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) -typeset l2_hits_end=$(get_arcstat l2_hits) +typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ + awk '{print $2}') -log_must test $(( $log_blk_rebuild_end - $log_blk_rebuild_start )) -eq \ - $(( $log_blk_end - $log_blk_start )) +log_must zpool online $TESTPOOL $VDEV_CACHE +arcstat_quiescence_noecho l2_size -log_must test $l2_hits_end -gt $l2_hits_start +typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) + +# Upon onlining the cache device we might write additional blocks to it +# before it is marked for rebuild as the l2ad_* parameters are not cleared +# when offlining the device. See comment in l2arc_rebuild_vdev(). +# So we cannot compare the amount of rebuilt log blocks to the amount of log +# blocks read from the header of the device. +log_must test $(( $l2_rebuild_log_blk_end - \ + $l2_rebuild_log_blk_start )) -gt 0 +log_must test $l2_dh_log_blk -gt 0 log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size @@ -106,4 +99,4 @@ log_must zdb -lq $VDEV_CACHE log_must zpool destroy -f $TESTPOOL -log_pass "Persistent L2ARC restores all written log blocks with encryption." +log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_006_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_006_pos.ksh deleted file mode 100755 index 0517735402..0000000000 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_006_pos.ksh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/ksh -p -# -# CDDL HEADER START -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# -# CDDL HEADER END -# - -# -# Copyright (c) 2020, George Amanakis. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib -. $STF_SUITE/tests/functional/l2arc/l2arc.cfg - -# -# DESCRIPTION: -# Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not -# present. -# -# STRATEGY: -# 1. Create pool with a cache device. -# 2. Create a random file in that pool and random read for 10 sec. -# 3. Read the amount of log blocks written from the header of the -# L2ARC device. -# 4. Offline the L2ARC device and export pool. -# 5. Import pool and online the L2ARC device. -# 6. Read the amount of log blocks rebuilt in arcstats and compare to -# (3). -# 7. Check if the labels of the L2ARC device are intact. -# - -verify_runnable "global" - -log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." - -function cleanup -{ - if poolexists $TESTPOOL ; then - destroy_pool $TESTPOOL - fi - - log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch - log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE \ - $rebuild_blocks_min_l2size -} -log_onexit cleanup - -# L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches -typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) -typeset rebuild_blocks_min_l2size=$(get_tunable L2ARC_REBUILD_BLOCKS_MIN_L2SIZE) -log_must set_tunable32 L2ARC_NOPREFETCH 0 -log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE 0 - -typeset fill_mb=800 -typeset cache_sz=$(( floor($fill_mb / 2) )) -export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M - -log_must truncate -s ${cache_sz}M $VDEV_CACHE - -log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE - -log_must fio $FIO_SCRIPTS/mkfiles.fio -log_must fio $FIO_SCRIPTS/random_reads.fio - -arcstat_quiescence_noecho l2_size -log_must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size -log_must zpool export $TESTPOOL -arcstat_quiescence_noecho l2_feeds - -typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') - -log_must zpool import -d $VDIR $TESTPOOL -log_must zpool online $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) - -log_must test $l2_dh_log_blk -eq $(( $l2_rebuild_log_blk_end - \ - $l2_rebuild_log_blk_start )) -log_must test $l2_dh_log_blk -gt 0 - -log must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -log_must zdb -lq $VDEV_CACHE - -log_must zpool destroy -f $TESTPOOL - -log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_007_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_007_pos.ksh deleted file mode 100755 index 9208b81d49..0000000000 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_007_pos.ksh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/ksh -p -# -# CDDL HEADER START -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# -# CDDL HEADER END -# - -# -# Copyright (c) 2020, George Amanakis. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib -. $STF_SUITE/tests/functional/l2arc/l2arc.cfg - -# -# DESCRIPTION: -# Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present. -# -# STRATEGY: -# 1. Create pool with a cache device. -# 2. Create a random file in that pool and random read for 10 sec. -# 3. Offline the L2ARC device. -# 4. Read the amount of log blocks written from the header of the -# L2ARC device. -# 5. Online the L2ARC device. -# 6. Read the amount of log blocks rebuilt in arcstats and compare to -# (4). -# 7. Check if the labels of the L2ARC device are intact. -# - -verify_runnable "global" - -log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." - -function cleanup -{ - if poolexists $TESTPOOL ; then - destroy_pool $TESTPOOL - fi - - log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch - log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE \ - $rebuild_blocks_min_l2size -} -log_onexit cleanup - -# L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches -typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) -typeset rebuild_blocks_min_l2size=$(get_tunable L2ARC_REBUILD_BLOCKS_MIN_L2SIZE) -log_must set_tunable32 L2ARC_NOPREFETCH 0 -log_must set_tunable32 L2ARC_REBUILD_BLOCKS_MIN_L2SIZE 0 - -typeset fill_mb=800 -typeset cache_sz=$(( floor($fill_mb / 2) )) -export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M - -log_must truncate -s ${cache_sz}M $VDEV_CACHE - -log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE - -log_must fio $FIO_SCRIPTS/mkfiles.fio -log_must fio $FIO_SCRIPTS/random_reads.fio - -arcstat_quiescence_noecho l2_size -log_must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') - -log_must zpool online $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) - -log_must test $l2_dh_log_blk -eq $(( $l2_rebuild_log_blk_end - \ - $l2_rebuild_log_blk_start )) -log_must test $l2_dh_log_blk -gt 0 - -log_must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -log_must zdb -lq $VDEV_CACHE - -log_must zpool destroy -f $TESTPOOL - -log_pass "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_008_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_008_pos.ksh deleted file mode 100755 index 5a79ff31ba..0000000000 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_008_pos.ksh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/ksh -p -# -# CDDL HEADER START -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# -# CDDL HEADER END -# - -# -# Copyright (c) 2020, George Amanakis. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib -. $STF_SUITE/tests/functional/l2arc/l2arc.cfg - -# -# DESCRIPTION: -# Off/onlining an L2ARC device restores all written blocks, vdev present. -# -# STRATEGY: -# 1. Create pool with a cache device. -# 2. Create a random file in that pool and random read for 10 sec. -# 3. Read the amount of log blocks written from the header of the -# L2ARC device. -# 4. Offline the L2ARC device. -# 5. Online the L2ARC device. -# 6. Read the amount of log blocks rebuilt in arcstats and compare to -# (3). -# 7. Create another random file in that pool and random read for 10 sec. -# 8. Read the amount of log blocks written from the header of the -# L2ARC device. -# 9. Offline the L2ARC device. -# 10. Online the L2ARC device. -# 11. Read the amount of log blocks rebuilt in arcstats and compare to -# (8). -# 12. Check if the amount of log blocks on the cache device has -# increased. -# 13. Export the pool. -# 14. Read the amount of log blocks on the cache device. -# 15. Import the pool. -# 16. Read the amount of log blocks rebuilt in arcstats and compare to -# (14). -# 17. Check if the labels of the L2ARC device are intact. -# - -verify_runnable "global" - -log_assert "Off/onlining an L2ARC device restores all written blocks , vdev present." - -function cleanup -{ - if poolexists $TESTPOOL ; then - destroy_pool $TESTPOOL - fi - - log_must set_tunable32 L2ARC_NOPREFETCH $noprefetch -} -log_onexit cleanup - -# L2ARC_NOPREFETCH is set to 0 to let L2ARC handle prefetches -typeset noprefetch=$(get_tunable L2ARC_NOPREFETCH) -log_must set_tunable32 L2ARC_NOPREFETCH 0 - -typeset fill_mb=400 -typeset cache_sz=$(( 3 * $fill_mb )) -export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M - -log_must truncate -s ${cache_sz}M $VDEV_CACHE - -log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE - -log_must fio $FIO_SCRIPTS/mkfiles.fio -log_must fio $FIO_SCRIPTS/random_reads.fio - -arcstat_quiescence_noecho l2_size -log_must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_dh_log_blk1=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') -typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) - -log_must zpool online $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) - -log_must test $l2_dh_log_blk1 -eq $(( $l2_rebuild_log_blk_end - \ - $l2_rebuild_log_blk_start )) -log_must test $l2_dh_log_blk1 -gt 0 - -log_must fio $FIO_SCRIPTS/mkfiles.fio -log_must fio $FIO_SCRIPTS/random_reads.fio - -arcstat_quiescence_noecho l2_size -log_must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_dh_log_blk2=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') -typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) - -log_must zpool online $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) - -log_must test $l2_dh_log_blk2 -eq $(( $l2_rebuild_log_blk_end - \ - $l2_rebuild_log_blk_start )) -log_must test $l2_dh_log_blk2 -gt $l2_dh_log_blk1 - -log_must zpool export $TESTPOOL -arcstat_quiescence_noecho l2_feeds - -typeset l2_dh_log_blk3=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') -typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) - -log_must zpool import -d $VDIR $TESTPOOL -arcstat_quiescence_noecho l2_size - -typeset l2_rebuild_log_blk_end=$(arcstat_quiescence_echo l2_rebuild_log_blks) - -log_must test $l2_dh_log_blk3 -eq $(( $l2_rebuild_log_blk_end - \ - $l2_rebuild_log_blk_start )) -log_must test $l2_dh_log_blk3 -gt 0 - -log must zpool offline $TESTPOOL $VDEV_CACHE -arcstat_quiescence_noecho l2_size - -log_must zdb -lq $VDEV_CACHE - -log_must zpool destroy -f $TESTPOOL - -log_pass "Off/onlining an L2ARC device restores all written blocks, vdev present."