git: 1c27279ed22d - stable/14 - Destroy ARC buffer in case of fill error

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 17 Jun 2024 14:35:24 UTC
The branch stable/14 has been updated by markj:

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

commit 1c27279ed22d2b5226f31836da041bae45a9c77b
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2024-05-25 02:11:18 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-17 14:25:59 +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
    
    (cherry picked from commit 02c5aa9b092818785ed8db4e2246a828278138e3)
---
 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");