Public bug reported:

Release: Ubuntu 26.04.1, kernel 7.0.0-38-generic, zfs-linux 2.4.1-1ubuntu5.1 
(zfs-dkms /
zfsutils-linux). The affected code is identical in upstream master.

Under memory pressure, arc_read() allocates memory while holding an ARC hash 
lock. With a large
page cache and little free memory the allocation goes into direct reclaim, and 
on this kernel
(MGLRU) a reclaim pass that has to walk the page tables of many large mmap() 
readers takes
minutes. For that whole time every thread that releases a cached dbuf runs 
dbuf_evict_one()
(dbuf_evict_notify()), which blocks in arc_buf_destroy() -> 
mutex_enter(hash_lock) behind that
one thread, and so do the dbuf_evict thread, txg_sync and the ZIO threads. Pool 
I/O stops, nfsd
stops answering, journald and udevd are watchdog-killed, sometimes the host 
resets through
softlockup_panic.

We hit this several times a day on a 90-host HTCondor simulation cluster (16 
jobs per 16-core /
121 GiB host, each job mmap(MAP_POPULATE)ing gigabytes of data from a local 
pool that is also
exported over NFS; zfs_arc_max was 2 GiB). Symptom for users: NFS mounts of the 
pool vanish on
the clients for 30-75 minutes.

Kernel log:

    INFO: task dbuf_evict:982 blocked for more than 122 seconds.
    task:dbuf_evict state:D  __mutex_lock_slowpath -> mutex_lock -> 
arc_buf_destroy
      -> dbuf_destroy -> dbuf_evict_one -> dbuf_evict_thread
    INFO: task dbuf_evict:982 is blocked on a mutex likely owned by task 
Matrix:684006.
    task:Matrix state:R  evict_folios -> shrink_node -> try_to_free_pages -> 
__alloc_pages_noprof
      -> abd_alloc_chunks -> abd_alloc -> arc_hdr_alloc_abd -> arc_read -> 
dbuf_issue_final_prefetch
      -> dmu_zfetch_run -> dmu_buf_hold_array_by_dnode -> dmu_read -> 
zfs_fillpage -> zfs_getpage
      -> zpl_read_folio -> filemap_fault
    INFO: task txg_sync:1221 blocked for more than 122 seconds.

Reproducer (KVM guest, 16 vCPU, 32 GiB, zfs_arc_max=2 GiB): pool with 160 x 1 
GiB incompressible
files, 14 processes mmap(MAP_PRIVATE|MAP_POPULATE)ing them in a loop, 8 readers 
streaming 40 GiB
of ext4 files to keep the page cache full, one dd with fsync. bpftrace shows 
~1,600
arc_buf_destroy() calls per 10 minutes waiting more than 16 ms for a hash lock 
and ~870
buf_hash_find() calls waiting more than 16 ms; in production the holds last 
minutes.

Upstream: issue https://github.com/openzfs/zfs/issues/19779 with the analysis; 
fixes in
https://github.com/openzfs/zfs/pull/19780 (dbuf_evict_one() takes the hash lock 
with
mutex_tryenter() and skips a busy header; the new-header ABD is allocated before
buf_hash_insert()) and https://github.com/openzfs/zfs/pull/19781 (the caller's 
buffer is
allocated before the hash lock is taken). All three patches apply to 
2.4.1-1ubuntu5.1 without
changes (the 2.4.1 versions are attached) and have been running on all 90 hosts 
since 2026-11-09
with no recurrence; a 6 h production A/B on one host showed dbuf_evict_one() 
hash-lock blocks
897 -> 0 and no buf_hash_find() over 1 s under heavier reclaim than the stock 
window saw.

Workarounds that stop the stalls (but leave the lock hold): zfs_arc_max=16 GiB,
vm.min_free_kbytes=4 GiB, a cgroup memory.high on the job runner.

Request: once merged upstream, please consider these for an SRU of zfs-linux in 
26.04 (and
26.10); they are small, self-contained and do not change on-disk format or any 
interface.

Related: bug #2170426 (dnode pruning under memory pressure, upstream PR
19275, merged upstream but in no release yet).

** Affects: zfs
     Importance: Undecided
         Status: New

** Affects: zfs-linux (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2173776

Title:
  zfs-linux: arc_read() holds an ARC hash lock across direct reclaim;
  dbuf_evict and txg_sync hang for minutes, NFS exports stop (upstream
  openzfs/zfs#19779)

To manage notifications about this bug go to:
https://bugs.launchpad.net/zfs/+bug/2173776/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to