From nobody Sat Nov 14 17:26:26 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 4jRgyq5L6Jz6y1GN for ; Sat, 14 Nov 2026 17:26:27 +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 4jRgyp6XBrz4nkR for ; Sat, 14 Nov 2026 17:26:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677186; 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=qChDJTDr83opAh6P+hHbuvm/4Tya3GzsJHIjlmEc7do=; b=TxZ5kQ1ekhZC4sYzQVD/Ev4YCuhKr3lFZb3Ihoau7Pf9T9o1nm0GNvf5KMdqBRtANDaicF IdRPd68hSjIEcEuFKPF6s9WknvdTSOsKIea2SuATHJA1BGTnJ/eG3YgRi2Dd1LGTYhkwuh 3amfQ0exdmxgHw/Miq45pVjT9WmIkEjoIgHgf0bpy9ankxwKIoyYU2+Y1Z2H+qi5Ja+E5A TmY6yBhiW/rUNVjTucJByWMiY947Kp3/gYXHJMhXpdwhtur9CmHQwAfFabQk+HY79E9VZn +qClJ12BtBdmGWh38PK13SknyNUrlGV+LJLBt2+MCep98vDzZiPMkYh5mE4akQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794677186; b=CO6WA1ncBl5sYlU1npwF4XPie7zW/Og5FFh7dlTw9gxmDi1hrx50oiwa1+en+OC7MwyYOq pMhY5TW2TqJGYwbj8LGcXqG5eboKBVj8xwpeg/WOjHvD8R/aYk2OZ4shzwNMUddomjSEVu ADLC80r/FiUhm0quP7F0Y99h/bj+0cWP2c4X2I31X2DJ0rpXKIgk5V2KTC97q009Knol57 oCUBqlRgekgJFSjUpL+z3bhnpqGZSHxNwdyRUPZUSXDnfAop/jC7TReDJC9sh+Leg8yJoW ndAZ7JSjYfX/nhItmYEFYg0iB10a6iuPc8MsOyKOIHqAj9LIdf9nQUzgxy0onQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677186; 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=qChDJTDr83opAh6P+hHbuvm/4Tya3GzsJHIjlmEc7do=; b=BH2gN6fugS4+oYWYLNZZY2x22gi1UbwnCo5Me9COs0ws1bGFxS83dYbtWjT5o9LnRimQXD lRIvm9bVb7O509bj3QcxWOaklvCAIlL7nhbg6dHXlHnrcQxvDOSRRAJdBvZfu89sUxzKN0 2eiHfuEMmEgzxnKcJBU37SGWoDH1nEVavF1nM3oQbr5SXGsAgr+znuE1gn+QiAym7b1W+F umcMbNv30HJR61Ua2hObaV7CmaNn8jNG6eYwmCrUX7deqtpvT+kASbg8sUBBu88sk8r9y7 AYCvOQBI99fONuLLN50fWOq9g6TGeZf6pN5f/EP+nn5NUCotDHlZPEJqMzzL5g== 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 4jRgyp64NQzVGJ for ; Sat, 14 Nov 2026 17:26:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e093 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 17:26:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wale Zhang From: Colin Percival Subject: git: 9917744f7998 - releng/15.2 - 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.2 X-Git-Reftype: branch X-Git-Commit: 9917744f7998298409f754c98af6591ae297660e Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 17:26:26 +0000 Message-Id: <6af899c2.1e093.7d0e9617@gitrepo.freebsd.org> The branch releng/15.2 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=9917744f7998298409f754c98af6591ae297660e commit 9917744f7998298409f754c98af6591ae297660e Author: Wale Zhang AuthorDate: 2026-11-05 04:31:09 +0000 Commit: Colin Percival CommitDate: 2026-11-14 17:25:56 +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: re (cperciva) 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 9e899e3ea334..1bf22b2639b2 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1464,17 +1464,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. @@ -1496,7 +1494,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 ?