From nobody Tue Nov 17 17:07:59 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTWQ85V97z71SKw for ; Tue, 17 Nov 2026 17:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWQ80Q2fz4MPL for ; Tue, 17 Nov 2026 17:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SH6TozRvRV5iyQOuJ69IUNg9gojbqVXTo4LY0e9hMGQ=; b=Pg3kFIT1+e2V4U+Z4t1ryA7Nj8ZnRgJmEZNWzeJK9+4BFAOB46djHC6HLD3TQEtY2PAS9K aDKfm4v7vxMmcsRCxJae9CYBHyXC0p1P/vLcJXHZolMsT7Ke+Q4NRlzcfWeK+TOUAohnHO GAPWajFY6dRCfd+0tvo+V6IQwuuA1Vo7ReJvq5q0Lp2tRJbYOLiz6eKeJOGChuAVUhQesL QUczYP3H1CrbUCV+TKsC1SOiVp65+wUo9bpdHVoT15zd5U0uNxYP9Sef4cfPUgQ8BECBwB fa9ZufcVmpMP6XWuTZ50PBbmvrv3ctrXSJOErx3rKIYDmJPJ/dOjNDfzAAtwoQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935280; b=q1weHPDiGnTfJhQCG3YAUtGhlZCdHtJOEumYla861JGA2OHFJnm0CF6xzZbEsXh9L8PkHX fcfQCxj8gUNUl3ccHk2zu4dci9L4KJQuq5YJHmQyIr+mxu+tds+e8CSRbS92rVklwTFyWs bID5f41EG1DC8wbqIc3Ti0a1u212gE7nIYXXfqk0oQdle5eQuS1NaOpoVnXelheWnYfp7X uvSbFfaF66VZkVDAAd4K1P9Mpv/47uxtvlii8qcKRgbJ7kE/SC3Pvo7g9sT/mWH7rHbelQ 2YXDt/1tDNOkHCwW2A6TkvUD+J9Xl6CM8ViP/aNdjHbBpsA2pFLLVIe+SJSmiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SH6TozRvRV5iyQOuJ69IUNg9gojbqVXTo4LY0e9hMGQ=; b=opH05QH2synb5FItjNT+w6/tUqSRfTBExccYivMvcOrXanhat1eyKWLSMyZF2Cd7r6zY83 10CFNDl0zAxnOUz+xkGpCN7mCikaUROR7E6Z69BrqTm6EKYWr5/flDj+A2gjp8lUUWG0hL aFTLvXXCm2PWaetVJGiLpREPZWe9anlgoWfAy3+fd3VH2rvg70L2sAWG//ugnFrfUvvp0G jePOdRuotHu40ldEv/scOWM5A6NwWA7FPvjX5NCBmhLxmqrtI7IGc/kPEeAlLUT33FsqGF sLMZF90YqNPHAqQZepzEwQalBnJ+ukLoZA08mTPI29y5MDwQIOEQBEAbAIKMjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWQ76pxHzrpq for ; Tue, 17 Nov 2026 17:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 47c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:07:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wale Zhang From: Mark Johnston Subject: git: 685617cf0ebd - releng/15.1 - Fix direct reads of blocks pending free List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.1 X-Git-Reftype: branch X-Git-Commit: 685617cf0ebddcc68e506f5b28e91dbad336df8e Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:07:59 +0000 Message-Id: <6afc89ef.47c.2e26c48c@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=685617cf0ebddcc68e506f5b28e91dbad336df8e commit 685617cf0ebddcc68e506f5b28e91dbad336df8e Author: Wale Zhang AuthorDate: 2026-11-05 04:31:09 +0000 Commit: Mark Johnston CommitDate: 2026-11-15 17:57:38 +0000 Fix direct reads of blocks pending free Direct reads only check the on-disk block pointer for holes, so they can read stale data after a block has been freed but before the free has synced. Share buffered read hole detection with direct reads to honor pending frees as well. Keep cached data ahead of hole detection and preserve the transaction ordering of block clone and direct write overrides. Retain the block pointer recheck after dnode_block_freed() for concurrent syncing. Reviewed-by: Brian Behlendorf Signed-off-by: Wale Zhang Closes #19633 Approved by: so Security: FreeBSD-EN-26:32.zfs Approved by: kevans (mentor) (cherry picked from commit 924b8c89c04e324649855b05986f686b58ca4cb9) (cherry picked from commit afc7fc2abe807780e6f9cba96ab73105ebd2a07f) --- sys/contrib/openzfs/include/sys/dbuf.h | 1 + sys/contrib/openzfs/module/zfs/dbuf.c | 28 ++++++++++++++++++++-------- sys/contrib/openzfs/module/zfs/dmu_direct.c | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/sys/contrib/openzfs/include/sys/dbuf.h b/sys/contrib/openzfs/include/sys/dbuf.h index 0b379ee79caa..a583cbb4d95c 100644 --- a/sys/contrib/openzfs/include/sys/dbuf.h +++ b/sys/contrib/openzfs/include/sys/dbuf.h @@ -389,6 +389,7 @@ dbuf_dirty_record_t *dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx); dbuf_dirty_record_t *dbuf_dirty_lightweight(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx); boolean_t dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx); +boolean_t dbuf_is_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp); int dmu_buf_get_bp_from_dbuf(dmu_buf_impl_t *db, blkptr_t **bp); int dmu_buf_untransform_direct(dmu_buf_impl_t *db, spa_t *spa); void dmu_buf_write_embedded(dmu_buf_t *dbuf, void *data, diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index aeb697eb1645..040924450c3d 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1465,17 +1465,15 @@ dbuf_handle_indirect_hole(void *data, dnode_t *dn, blkptr_t *dbbp) } /* - * Handle reads on dbufs that are holes, if necessary. This function - * requires that the dbuf's mutex is held. Returns success (0) if action - * was taken, ENOENT if no action was taken. + * Check for a hole, including frees which have not yet been synced. + * The caller must hold db_mtx to stabilize the dirty records. */ -static int -dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) +boolean_t +dbuf_is_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) { ASSERT(MUTEX_HELD(&db->db_mtx)); - arc_buf_t *db_data; - int is_hole = bp == NULL || BP_IS_HOLE(bp); + boolean_t is_hole = bp == NULL || BP_IS_HOLE(bp); /* * For level 0 blocks only, if the above check didn't find a hole, * consult dnode_block_freed() to check for pending frees. @@ -1505,7 +1503,21 @@ dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) } } - if (is_hole) { + return (is_hole); +} + +/* + * Handle reads on dbufs that are holes, if necessary. This function + * requires that the dbuf's mutex is held. Returns success (0) if action + * was taken, ENOENT if no action was taken. + */ +static int +dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) +{ + ASSERT(MUTEX_HELD(&db->db_mtx)); + arc_buf_t *db_data; + + if (dbuf_is_hole(db, dn, bp)) { db_data = dbuf_alloc_arcbuf(db); memset(db_data->b_data, 0, db->db.db_size); diff --git a/sys/contrib/openzfs/module/zfs/dmu_direct.c b/sys/contrib/openzfs/module/zfs/dmu_direct.c index 5b00698da728..496f4d2afdf2 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_direct.c +++ b/sys/contrib/openzfs/module/zfs/dmu_direct.c @@ -298,7 +298,7 @@ dmu_read_abd(dnode_t *dn, uint64_t offset, uint64_t size, * cached. This will not be considered a direct read for IO * accounting in the same way that an ARC hit is not counted. */ - if (bp == NULL || BP_IS_HOLE(bp) || db->db_state == DB_CACHED) { + if (db->db_state == DB_CACHED || dbuf_is_hole(db, dn, bp)) { size_t aoff = offset < db->db.db_offset ? db->db.db_offset - offset : 0; size_t boff = offset > db->db.db_offset ?