L2ARC: Relax locking during write
commit997f85b4d3123286a584bbd3aaac3077a8067abb
authorAlexander Motin <mav@FreeBSD.org>
Tue, 9 Apr 2024 23:23:19 +0000 (9 19:23 -0400)
committerGitHub <noreply@github.com>
Tue, 9 Apr 2024 23:23:19 +0000 (9 16:23 -0700)
treeb3a030b82d45d080230cd3444248b9843137a204
parent9e63631dea553fb81fe10710e626fae26ff5c14f
L2ARC: Relax locking during write

Previous code held ARC state sublist lock throughout all L2ARC
write process, which included number of allocations and even ZIO
issues.  Being blocked in any of those places the code could also
block ARC eviction, that could cause OOM activation or even dead-
lock if system is low on memory or one is too fragmented.

Fix it by dropping the lock as soon as we see a block eligible
for L2ARC writing and pick it up later using earlier inserted
marker.  While there, also reduce scope of hash lock, moving
ZIO allocation and other operations not requiring header access
out of it.  All operations requiring header access move under
hash lock, since L2_WRITING flag does not prevent header eviction
only transition to arc_l2c_only state with L1 header.

To be able to manipulate sublist lock and marker as needed add few
more multilist functions and modify one.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16040
include/sys/multilist.h
module/zfs/arc.c
module/zfs/dbuf.c
module/zfs/dmu_objset.c
module/zfs/metaslab.c
module/zfs/multilist.c