From 9249f1272ec08316f4482cba145b42ba935d3b02 Mon Sep 17 00:00:00 2001 From: George Amanakis Date: Fri, 17 Apr 2020 12:27:40 -0400 Subject: [PATCH] Persistent L2ARC minor fixes Minor fixes on persistent L2ARC improving code readability and fixing a typo in zdb.c when byte-swapping a log block. It also improves the pesist_l2arc_007_pos.ksh test by giving it more time to retrieve log blocks on the cache device. Reviewed-by: Brian Behlendorf Reviewed-by: Adam D. Moss Signed-off-by: George Amanakis Closes #10210 --- cmd/zdb/zdb.c | 3 +-- module/zfs/arc.c | 14 ++++++-------- .../persist_l2arc/persist_l2arc_007_pos.ksh | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index dab0d8b68f88..f5492666f10e 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3606,8 +3606,7 @@ dump_l2arc_log_blocks(int fd, l2arc_dev_hdr_phys_t l2dhdr) } if (this_lb.lb_magic == BSWAP_64(L2ARC_LOG_BLK_MAGIC)) - byteswap_uint64_array(&this_lb, psize); - + byteswap_uint64_array(&this_lb, sizeof (this_lb)); if (this_lb.lb_magic != L2ARC_LOG_BLK_MAGIC) { (void) printf("Invalid log block magic\n\n"); break; diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 74bfbfc7029d..5b34d4abd4ac 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -9578,6 +9578,7 @@ l2arc_log_blk_read(l2arc_dev_t *dev, int err = 0; zio_cksum_t cksum; abd_t *abd = NULL; + uint64_t psize; ASSERT(this_lbp != NULL && next_lbp != NULL); ASSERT(this_lb != NULL && next_lb != NULL); @@ -9616,8 +9617,8 @@ l2arc_log_blk_read(l2arc_dev_t *dev, } /* Make sure the buffer checks out */ - fletcher_4_native(this_lb, - L2BLK_GET_PSIZE((this_lbp)->lbp_prop), NULL, &cksum); + psize = L2BLK_GET_PSIZE((this_lbp)->lbp_prop); + fletcher_4_native(this_lb, psize, NULL, &cksum); if (!ZIO_CHECKSUM_EQUAL(cksum, this_lbp->lbp_cksum)) { ARCSTAT_BUMP(arcstat_l2_rebuild_abort_cksum_lb_errors); zfs_dbgmsg("L2ARC log block cksum failed, offset: %llu, " @@ -9633,14 +9634,11 @@ l2arc_log_blk_read(l2arc_dev_t *dev, case ZIO_COMPRESS_OFF: break; case ZIO_COMPRESS_LZ4: - abd = abd_alloc_for_io(L2BLK_GET_PSIZE( - (this_lbp)->lbp_prop), B_TRUE); - abd_copy_from_buf_off(abd, this_lb, 0, - L2BLK_GET_PSIZE((this_lbp)->lbp_prop)); + abd = abd_alloc_for_io(psize, B_TRUE); + abd_copy_from_buf_off(abd, this_lb, 0, psize); if ((err = zio_decompress_data( L2BLK_GET_COMPRESS((this_lbp)->lbp_prop), - abd, this_lb, L2BLK_GET_PSIZE((this_lbp)->lbp_prop), - sizeof (*this_lb))) != 0) { + abd, this_lb, psize, sizeof (*this_lb))) != 0) { err = SET_ERROR(EINVAL); goto cleanup; } diff --git a/tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_007_pos.ksh b/tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_007_pos.ksh index e3c983be847a..c79c3927652d 100755 --- a/tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_007_pos.ksh @@ -72,7 +72,7 @@ log_must fio $FIO_SCRIPTS/random_reads.fio log_must zpool offline $TESTPOOL $VDEV_CACHE -sleep 5 +sleep 10 typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) @@ -81,7 +81,7 @@ typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ log_must zpool online $TESTPOOL $VDEV_CACHE -sleep 5 +sleep 10 typeset l2_rebuild_log_blk_end=$(get_arcstat l2_rebuild_log_blks)