HomeFreeBSD

Block cloning conditionally destroy ARC buffer

Description

Block cloning conditionally destroy ARC buffer

dmu_buf_will_clone() calls arc_buf_destroy() if there is an associated
ARC buffer with the dbuf. However, this can only be done conditionally.
If the previous dirty record's dr_data is pointed at db_dbf then
destroying it can lead to NULL pointer deference when syncing out the
previous dirty record.

This updates dmu_buf_fill_clone() to only call arc_buf_destroy() if the
previous dirty records dr_data is not pointing to db_buf. The block
clone wil still set the dbuf's db_buf and db_data to NULL, but this will
not cause any issues as any previous dirty record dr_data will still be
pointing at the ARC buffer.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #16337

Details

Provenance
Brian Atkinson <batkinson@lanl.gov>Authored on Aug 2 2024, 1:22 AM
GitHub <noreply@github.com>Committed on Aug 2 2024, 1:22 AM
Parents
rGc092bddfe739: Fix sa.c to build on FreeBSD again. (#16403)
Branches
Unknown
Tags
Unknown