From nobody Sat Nov 14 04:47:07 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 4jRM6g71trz70gJ6 for ; Sat, 14 Nov 2026 04:47:07 +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 4jRM6g49mwz3HLH for ; Sat, 14 Nov 2026 04:47:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794631627; 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=nE86ZBKGS3/UMP0SF88YVLxB0sj8yg9+7zTjc9kxXLY=; b=ZqUZozs+Z8O2oeuCZzmFtVlMDZHp4f59U/rLnVwq0ecLwoezM3TnIwBtm18+CKoUtcBw/1 0jVe2DYR/cEmBpKhZ8SiQrENIqprKMZxemF2lbbUCxnwd1Jwp5OyVO/u2YKNOamLBZxQcm Axwc+vWVxwPUhxyPuHR8rGE6pytDNfbF/8Cw51gjFqo7rhUEZeB04KOwFi8VNGx6XfvOuv q8iVjKAWCpDMNiHpk7wsWUOxgHwivDkXXfxeR17vGLkBwhd63v3ZATCulMr9u7fuXcoQxp Geu1akqYklsqn03mvqKr4ownBK/cq7rVIfFdGfNNVJLQAbCXQU9zj3+qdzFNBA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794631627; b=bRX5S24aMNoLGTjawHGqeQJJkrodY0Ieehdu+g+cHetunjN+5KtkOuqAvEktGK53EBAPIy 3H6zXGcs/Yq8StOiqq2VVfxQQC+0/a7euHofib+k4yhiF79sjJqtnaMJXCvWATxZz+CSCw j0W2HSCa3k9RQ/HeLb7CL0y0jIpBpfbWPEsP9cWppFTz9DdUnpdnLKPUAyx2D40Cqg16Bo zeiesbwZ4YsKbUnWvdf9pmvVJXOO7JjhfObIs9TKzzPcl17Fu2AiQYNlTph2wPc7x++UNF jYw+9kMNS0jkYZtMXOKQcPattq8Ryfi4DVsQgYkJXDedKNJ8pBF5yPHS/nbovQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794631627; 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=nE86ZBKGS3/UMP0SF88YVLxB0sj8yg9+7zTjc9kxXLY=; b=ftqa7rXw3rPjDb0LWoeTj828AL1Drh3c/RmQVOv2mapR+24JJ/HuVits9+to8GrzRyoGsK VV9ECWfv4U8jc94iWZHy0a6+I1q0i1SXOBY6X3UoXdBbBNzuX/hbf5FYhLw/Ea6HSBIwVR vNK4Lbk2XOYQZAVyEV8KV5o/AIRH7YIUW/ohUKoAp1xC4u9NpgENMrGDvN2eOmFepDoyUP hXPyom4pdDTsxW/YG9xDC0/und5Y1cUAQYSq9I+ntL9Acfymf8E9NP1tZ9gPWB5zRiQQ1i c8pRyEsxA1F2DmWX+r1Ovm6dLvkmmvsQUw757ZxCqQYsw9DOQ+0B0+ql14gzTw== 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 4jRM6g25rdz16cW for ; Sat, 14 Nov 2026 04:47:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 16bef by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 04:47:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wale Zhang From: Ryan Moeller Subject: git: afc7fc2abe80 - stable/15 - 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: rmoeller X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: afc7fc2abe807780e6f9cba96ab73105ebd2a07f Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 04:47:07 +0000 Message-Id: <6af7e7cb.16bef.571dd7e6@gitrepo.freebsd.org> The branch stable/15 has been updated by rmoeller: URL: https://cgit.FreeBSD.org/src/commit/?id=afc7fc2abe807780e6f9cba96ab73105ebd2a07f commit afc7fc2abe807780e6f9cba96ab73105ebd2a07f Author: Wale Zhang AuthorDate: 2026-11-05 04:31:09 +0000 Commit: Ryan Moeller CommitDate: 2026-11-14 04:46:09 +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: kevans (mentor) (cherry picked from commit 924b8c89c04e324649855b05986f686b58ca4cb9) --- 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 3e3cd9d64eac..e291fcf6def8 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. @@ -1504,7 +1502,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 ?