]> git.proxmox.com Git - mirror_zfs.git/commit
arc_read()/arc_access() refactoring and cleanup
authorAlexander Motin <mav@FreeBSD.org>
Thu, 22 Dec 2022 20:10:24 +0000 (15:10 -0500)
committerGitHub <noreply@github.com>
Thu, 22 Dec 2022 20:10:24 +0000 (12:10 -0800)
commitc935fe2e9267b2ea6e3187e205aac019f5e0c83f
tree5304ff8004ce1a7422665496a48a2d600a693375
parentdc8c2f615852cb79d3c4cae6c1fb738c7f4a793c
arc_read()/arc_access() refactoring and cleanup

ARC code was many times significantly modified over the years, that
created significant amount of tangled and potentially broken code.
This should make arc_access()/arc_read() code some more readable.

 - Decouple prefetch status tracking from b_refcnt.  It made sense
originally, but became highly cryptic over the years.  Move all the
logic into arc_access().  While there, clean up and comment state
transitions in arc_access().  Some transitions were weird IMO.
 - Unify arc_access() calls to arc_read() instead of sometimes calling
it from arc_read_done().  To avoid extra state changes and checks add
one more b_refcnt for ARC_FLAG_IO_IN_PROGRESS.
 - Reimplement ARC_FLAG_WAIT in case of ARC_FLAG_IO_IN_PROGRESS with
the same callback mechanism to not falsely account them as hits. Count
those as "iohits", an intermediate between "hits" and "misses". While
there, call read callbacks in original request order, that should be
good for fairness and random speculations/allocations/aggregations.
 - Introduce additional statistic counters for prefetch, accounting
predictive vs prescient and hits vs iohits vs misses.
 - Remove hash_lock argument from functions not needing it.
 - Remove ARC_FLAG_PREDICTIVE_PREFETCH, since it should be opposite
to ARC_FLAG_PRESCIENT_PREFETCH if ARC_FLAG_PREFETCH is set.  We may
wish to add ARC_FLAG_PRESCIENT_PREFETCH to few more places.
 - Fix few false positive tests found in the process.

Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #14123
include/os/linux/zfs/sys/trace_arc.h
include/sys/arc.h
include/sys/arc_impl.h
module/zfs/arc.c
module/zfs/dmu_traverse.c
module/zfs/dmu_zfetch.c
tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh
tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh
tests/zfs-tests/tests/functional/trim/autotrim_config.ksh
tests/zfs-tests/tests/functional/trim/trim_config.ksh
tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh