arc_loan_compressed_buf() increments arc_loaned_bytes by psize unconditionally.

In the case of zfs_compressed_arc_enabled=0, when the buf is returned via 
arc_return_buf(), if ARC_BUF_COMPRESSED(buf) is false, then arc_loaned_bytes is 
decremented by lsize, not psize.

Switch to using arc_buf_size(buf), instead of psize, which will return psize or 
lsize, depending on the result of ARC_BUF_COMPRESSED(buf)

To recreate the issue:
recv a compressed incremental replication stream (-c), and arc_loaned_bytes 
will underflow, triggering an assert:

panic: solaris assert: atomic_add_64_nv(&arc_loaned_bytes, 0) >= 0 
(0xffffffffffff20cc >= 0x0), file: 
line: 2834
cpuid = 1
time = 1519069857
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe002e5de990
vpanic() at vpanic+0x18d/frame 0xfffffe002e5de9f0
panic() at panic+0x43/frame 0xfffffe002e5dea50
assfail3() at assfail3+0x2c/frame 0xfffffe002e5dea70
dbuf_assign_arcbuf() at dbuf_assign_arcbuf+0x16e/frame 0xfffffe002e5deac0
dmu_assign_arcbuf() at dmu_assign_arcbuf+0x171/frame 0xfffffe002e5deb10
receive_writer_thread() at receive_writer_thread+0x938/frame 0xfffffe002e5debb0
fork_exit() at fork_exit+0x84/frame 0xfffffe002e5debf0
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe002e5debf0
You can view, comment on, or merge this pull request online at:

-- Commit Summary --

  * arc_loan_compressed_buf() can increment arc_loaned_bytes by the wrong value

-- File Changes --

    M usr/src/uts/common/fs/zfs/arc.c (2)

-- Patch Links --

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:

Powered by Topicbox:

Reply via email to