git: f566b7eb8d94 - releng/14.1 - Destroy ARC buffer in case of fill error

From: Gordon Tetlow <gordon_at_FreeBSD.org>
Date: Wed, 19 Jun 2024 20:36:48 UTC
The branch releng/14.1 has been updated by gordon:

URL: https://cgit.FreeBSD.org/src/commit/?id=f566b7eb8d94bdde7ad9ddf9bdc9cf336678c386

commit f566b7eb8d94bdde7ad9ddf9bdc9cf336678c386
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2024-05-25 02:11:18 +0000
Commit:     Gordon Tetlow <gordon@FreeBSD.org>
CommitDate: 2024-06-18 17:35:52 +0000

    Destroy ARC buffer in case of fill error
    
    In case of error dmu_buf_fill_done() returns the buffer back into
    DB_UNCACHED state.  Since during transition from DB_UNCACHED into
    DB_FILL state dbuf_noread() allocates an ARC buffer, we must free
    it here, otherwise it will be leaked.
    
    Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Reviewed-by: Jorgen Lundman <lundman@lundman.net>
    Signed-off-by: Alexander Motin <mav@FreeBSD.org>
    Sponsored by: iXsystems, Inc.
    Closes #15665
    Closes #15802
    Closes #16216
    
    PR:     276341
    Approved by:    so
    Security:       FreeBSD-EN-24:10.zfs
    
    (cherry picked from commit 02c5aa9b092818785ed8db4e2246a828278138e3)
    (cherry picked from commit 1c27279ed22d2b5226f31836da041bae45a9c77b)
---
 sys/contrib/openzfs/module/zfs/dbuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c
index bb921af6d78a..0576da6475b1 100644
--- a/sys/contrib/openzfs/module/zfs/dbuf.c
+++ b/sys/contrib/openzfs/module/zfs/dbuf.c
@@ -2840,6 +2840,7 @@ dmu_buf_fill_done(dmu_buf_t *dbuf, dmu_tx_t *tx, boolean_t failed)
 			failed = B_FALSE;
 		} else if (failed) {
 			VERIFY(!dbuf_undirty(db, tx));
+			arc_buf_destroy(db->db_buf, db);
 			db->db_buf = NULL;
 			dbuf_clear_data(db);
 			DTRACE_SET_STATE(db, "fill failed");