]> git.proxmox.com Git - mirror_zfs.git/commit - cmd/zdb/zdb.c
Add L2ARC arcstats for MFU/MRU buffers and buffer content type
authorGeorge Amanakis <gamanakis@gmail.com>
Mon, 14 Sep 2020 17:10:44 +0000 (13:10 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Sep 2020 17:10:44 +0000 (10:10 -0700)
commit085321621e79a75bea41c2b6511da6ebfbf2ba0a
tree99d378ac2dac5029e64382107b7fd2d648b00b69
parentd0cea309e7e2c3de7d08be017341b6c42f3366c9
Add L2ARC arcstats for MFU/MRU buffers and buffer content type

Currently the ARC state (MFU/MRU) of cached L2ARC buffer and their
content type is unknown. Knowing this information may prove beneficial
in adjusting the L2ARC caching policy.

This commit adds L2ARC arcstats that display the aligned size
(in bytes) of L2ARC buffers according to their content type
(data/metadata) and according to their ARC state (MRU/MFU or
prefetch). It also expands the existing evict_l2_eligible arcstat to
differentiate between MFU and MRU buffers.

L2ARC caches buffers from the MRU and MFU lists of ARC. Upon caching a
buffer, its ARC state (MRU/MFU) is stored in the L2 header
(b_arcs_state). The l2_m{f,r}u_asize arcstats reflect the aligned size
(in bytes) of L2ARC buffers according to their ARC state (based on
b_arcs_state). We also account for the case where an L2ARC and ARC
cached MRU or MRU_ghost buffer transitions to MFU. The l2_prefetch_asize
reflects the alinged size (in bytes) of L2ARC buffers that were cached
while they had the prefetch flag set in ARC. This is dynamically updated
as the prefetch flag of L2ARC buffers changes.

When buffers are evicted from ARC, if they are determined to be L2ARC
eligible then their logical size is recorded in
evict_l2_eligible_m{r,f}u arcstats according to their ARC state upon
eviction.

Persistent L2ARC:
When committing an L2ARC buffer to a log block (L2ARC metadata) its
b_arcs_state and prefetch flag is also stored. If the buffer changes
its arcstate or prefetch flag this is reflected in the above arcstats.
However, the L2ARC metadata cannot currently be updated to reflect this
change.
Example: L2ARC caches an MRU buffer. L2ARC metadata and arcstats count
this as an MRU buffer. The buffer transitions to MFU. The arcstats are
updated to reflect this. Upon pool re-import or on/offlining the L2ARC
device the arcstats are cleared and the buffer will now be counted as an
MRU buffer, as the L2ARC metadata were not updated.

Bug fix:
- If l2arc_noprefetch is set, arc_read_done clears the L2CACHE flag of
  an ARC buffer. However, prefetches may be issued in a way that
  arc_read_done() is bypassed. Instead, move the related code in
  l2arc_write_eligible() to account for those cases too.

Also add a test and update manpages for l2arc_mfuonly module parameter,
and update the manpages and code comments for l2arc_noprefetch.
Move persist_l2arc tests to l2arc.

Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #10743
38 files changed:
cmd/arc_summary/arc_summary2
cmd/arc_summary/arc_summary3
cmd/arcstat/arcstat.in
cmd/zdb/zdb.c
configure.ac
include/sys/arc_impl.h
man/man1/arcstat.1
man/man5/zfs-module-parameters.5
module/zfs/arc.c
tests/runfiles/common.run
tests/zfs-tests/include/tunables.cfg
tests/zfs-tests/tests/functional/Makefile.am
tests/zfs-tests/tests/functional/l2arc/Makefile.am [new file with mode: 0644]
tests/zfs-tests/tests/functional/l2arc/cleanup.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/l2arc.cfg [new file with mode: 0644]
tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_006_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_007_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/persist_l2arc_008_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/l2arc/setup.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/persist_l2arc/Makefile.am [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/cleanup.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc.cfg [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_001_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_002_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_003_neg.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_004_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_005_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_006_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_007_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/persist_l2arc_008_pos.ksh [deleted file]
tests/zfs-tests/tests/functional/persist_l2arc/setup.ksh [deleted file]