]> git.proxmox.com Git - mirror_zfs.git/commit
Fix L2ARC reads when compressed ARC disabled
authorAllan Jude <allanjude@freebsd.org>
Fri, 14 Aug 2020 06:31:20 +0000 (02:31 -0400)
committerGitHub <noreply@github.com>
Fri, 14 Aug 2020 06:31:20 +0000 (23:31 -0700)
commitfc34dfba8e8238683e90e3fa83d16be3343886f6
tree88cf30c0ac2615a1bd358516be55474df56ac9be
parentfaa296c73c7ccd535c0874d4f7e8f7c4ea43eea6
Fix L2ARC reads when compressed ARC disabled

When reading compressed blocks from the L2ARC, with
compressed ARC disabled, arc_hdr_size() returns
LSIZE rather than PSIZE, but the actual read is PSIZE.
This causes l2arc_read_done() to compare the checksum
against the wrong size, resulting in checksum failure.

This manifests as an increase in the kstat l2_cksum_bad
and the read being retried from the main pool, making the
L2ARC ineffective.

Add new L2ARC tests with Compressed ARC enabled/disabled

Blocks are handled differently depending on the state of the
zfs_compressed_arc_enabled tunable.

If a block is compressed on-disk, and compressed_arc is enabled:
- the block is read from disk
- It is NOT decompressed
- It is added to the ARC in its compressed form
- l2arc_write_buffers() may write it to the L2ARC (as is)
- l2arc_read_done() compares the checksum to the BP (compressed)

However, if compressed_arc is disabled:
- the block is read from disk
- It is decompressed
- It is added to the ARC (uncompressed)
- l2arc_write_buffers() will use l2arc_apply_transforms() to
  recompress the block, before writing it to the L2ARC
- l2arc_read_done() compares the checksum to the BP (compressed)
- l2arc_read_done() will use l2arc_untransform() to uncompress it

This test writes out a test file to a pool consisting of one disk
and one cache device, then randomly reads from it. Since the arc_max
in the tests is low, this will feed the L2ARC, and result in reads
from the L2ARC.

We compare the value of the kstat l2_cksum_bad before and after
to determine if any blocks failed to survive the trip through the
L2ARC.

Sponsored-by: The FreeBSD Foundation
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allanjude@freebsd.org>
Closes #10693
module/zfs/arc.c
tests/runfiles/common.run
tests/zfs-tests/tests/functional/compression/Makefile.am
tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh [new file with mode: 0755]