From nobody Tue Nov 17 17:07:58 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 4jTWQ74BWwz71SNK for ; Tue, 17 Nov 2026 17:07:59 +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 4jTWQ66gMhz4MYl for ; Tue, 17 Nov 2026 17:07:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935279; 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=yH/aARUUQPz2MTUPDHD8CD6vIrax7G068Y6wTQ/+7Xk=; b=y4Zr0koHQOKhr7f/jtggsLv62eX9Zia0M1+0VS983b+LfboDle6lk1/9PgiiekAlt1x9ic tEHNuQxBIep4pUiYsPV4fefxDdI8Vk0ma7qL4Ni9LU0wrbw2xqTUV5aoHBFB81h8m0bAfV 2u69eZkR3bb0L03aSUOeoj2qIizSbJRbAIuLUoyWjdbDLVX0UFCI0WeRuoEFdpUWsT3kAd G2LU4KpHku+0i/h6CxZMFSLZ2O3fv62T4E9eE4HDBnCibbHP5CUwp8xPzMRawy49NFR2+J Q1OS2MUl6RNX/w0csGdmI2tACqVu10YHCDMKHecgF7lQ/5ylFAWBglGO9JvQBg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935279; b=ly2/gu+iwJt9jSiLIdspSBqVllPuTASVbkfWuWo5mDkGuI30MFKsuw/648TaTLRHDeybi6 J6+UDIzONsLhnCoiiojBraiNO0tR9m0Q/3yandjouAsVzWL8Kyn+UWCIz2beuDzYYN2Fek ZMufZIvpslLW26crAF2ywGD+l1e3GVNqFrPSR/7T/elb8lVPYhX1j2Cx4msUaUW3DUwzNJ 2lhQt0cb9pIDN1APZ5J25b7k+9o8C5Yp3OD2UuSgN9MSNgijbG1sidyst5ZFXyzP/Ij0qR WEagrgh7ETRwzlI6E9olZJw9arGv2R0zbVg2Zib758HWCQMdWzKyUmb2zWqfjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935279; 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=yH/aARUUQPz2MTUPDHD8CD6vIrax7G068Y6wTQ/+7Xk=; b=TbcTTZUV/iwCE8p5xfaInr80HtvjJ8/At43XOFf2l9jyTk/f362rgGEn4lGoqxMSlMFqK0 s/q9i/R9UoiI0QL9Ha4Dd/2xCrNgm/bfy6vQqTvqxqlbujHmxhDg+HGy1lfx3xO9NLLw6f tdnrqFKPTbaH/GjtHGeC7jUwVHywTC1QNr5lIrQDnfsHdHiVRDbOK79wGSHX8ZLEOlJ1QR 8tQGJYJMf6itEcH2I/2y7aJBHUAG8f9ZKX0CMLDEvgLVAegkAQDQ3oMp6aGu7NQ0/UkC1k pj2xFzN/su42W1ACpTqq/u0VtaJYdLf1bg8ljoZAvUA9LJXJKs5aQ9kUxp3UAw== 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 4jTWQ66LLczrWC for ; Tue, 17 Nov 2026 17:07:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1efdc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:07:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Cyrille C. <18537428+CrochetFeve0251@users.noreply.github.com> From: Mark Johnston Subject: git: f52122f7687b - releng/15.1 - dbuf: restore BP_IS_HOLE() recheck after dnode_block_freed() 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: f52122f7687b1ca90d7f7e20d506000dc5456322 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:07:58 +0000 Message-Id: <6afc89ee.1efdc.46e839c2@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f52122f7687b1ca90d7f7e20d506000dc5456322 commit f52122f7687b1ca90d7f7e20d506000dc5456322 Author: Cyrille C. <18537428+CrochetFeve0251@users.noreply.github.com> AuthorDate: 2026-10-06 23:11:09 +0000 Commit: Mark Johnston CommitDate: 2026-11-15 17:57:38 +0000 dbuf: restore BP_IS_HOLE() recheck after dnode_block_freed() Commit 79cf54582 ("Fix reads for blocks freed after being cloned") reworked the level-0 check in dbuf_read_hole() and dropped the BP_IS_HOLE() recheck that followed dnode_block_freed(), together with the comment explaining it. That recheck was not about overrides: it closes a race with dnode_sync(). dnode_sync_free_ranges() drops dn_mtx, clears the bps through dnode_sync_free_range_impl() -> free_blocks(), then retakes dn_mtx and removes the range from dn_free_ranges. For blkptrs held in the dnode (dn_nlevels == 1), free_blocks() writes the bp without the parent's db_rwlock, so holding that lock in dbuf_read() does not serialize against it. A reader that saw a non-hole bp, then waited on dn_mtx in dnode_block_freed() until the range was removed, gets "not freed" while the bp it is about to copy is already a hole (with HOLE_BIRTH, lsize and birth preserved). dbuf_read_impl() then hands that hole to arc_read(): no child I/O is issued, checksum verification fails with EINVAL, and without ZIO_FLAG_CANFAIL the pool is suspended. Restore the recheck for the non-override path. The override path (block clone / Direct I/O) checks the overriding bp, which free_blocks() does not touch, so it is left as is. Reproduced on 2.3.9 with a test-only delay widening the window between the first BP_IS_HOLE() and dnode_block_freed(): reads of punched single-block files return EINVAL with the same ereport as in #19185. With this change, the same test returns no error. This change, its analysis and its description were prepared with the help of an AI assistant (Claude), then reviewed and tested by the submitter. Reviewed-by: Brian Behlendorf Signed-off-by: Cyrille C. Co-authored-by: Claude Opus 5.5 Fixes: a6f557c2cb58 ("Fix reads for blocks freed after being cloned") Closes #19185 Closes #19234 Approved by: so Security: FreeBSD-EN-26:32.zfs Approved by: kevans (mentor) (cherry picked from commit f1f96f5e7b01c791add67b27e8014e3986d10513) (cherry picked from commit 78ca640f79c585ea737c03a0c427bfe53582fd30) --- sys/contrib/openzfs/module/zfs/dbuf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index 2417f7577f73..aeb697eb1645 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1485,6 +1485,13 @@ dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) * find frees from TXGs before the override, which should not make * the block appear freed. Instead, check only free ranges from * TXGs after the override. + * + * Otherwise, recheck BP_IS_HOLE() after dnode_block_freed(): + * dnode_sync_free_ranges() clears the bp before it removes the + * free range, and free_blocks() does not take the parent's + * db_rwlock for blkptrs held in the dnode. If we wait for dn_mtx + * while that happens, block_freed says "no" but bp is now a hole, + * which must not be handed to arc_read(). */ if (!is_hole && db->db_level == 0) { dbuf_dirty_record_t *dr = list_head(&db->db_dirty_records); @@ -1493,7 +1500,8 @@ dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) is_hole = dnode_block_freed_after(dn, db->db_blkid, dr->dr_txg); } else { - is_hole = dnode_block_freed(dn, db->db_blkid); + is_hole = dnode_block_freed(dn, db->db_blkid) || + BP_IS_HOLE(bp); } }