From nobody Sat Nov 14 04:47:06 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 4jRM6f4xfgz70gFx for ; Sat, 14 Nov 2026 04:47:06 +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 4jRM6f3Thfz3HNY for ; Sat, 14 Nov 2026 04:47:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794631626; 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=w1ShKTK/Wd+dmat5XmFLOhLzp9Ep1rPwZ573QySOp0k=; b=woKj5pdABg3P3fG8dFgLf3fz/5dvgNmXhRbn9uplcsPH8jRtwuChXEWsS7zLHSERJ7k1/B YXOlIfn1ajDxd8Q4iXuJnXhLtTJIKnjNhHcm9BN1TPwGsDSQGqAt5awhEkRA78xvM1rKol IEZwwywcx+9kkvO6oc0qQXJILVKIloMwyCfsz5QV5eL9BK2EyIT9SHM6iDKj4sUSIFfCHz 3Nz43qyHz4XCvDSYlwPjL+SGRBEroovnljUW3ypCizCGoABqkhV7YNH7wwh18qGL4dw8jN CXLCOOTFKrWNhJ7elIAybM7zlaZLpirhg3OUG0UITdFFTx3BHorbXX43hR7znQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794631626; b=J1iJgxFOrM1VIy3C8YawnKgsB6fksacaks0vEKzSoNu4g0ni8umQt2okUna5Y7muX9O0bp wsa69J17Yyx+8e52pKNzNC+RultUbcJHLzJ4IMxobD4MGl3kgswXz9KsBL2rnt3L9Yz7jn cN6hoO3W5QXEBA8Tbe4h516pxeh6OwyTPZpJbt8smXIxm5AKC+EXpC9w9id/YOGpCJwJZn hEPWBYYfg5DuCSqtWyxAXRH4uut04oaPn0dqF4yIeg3vT8sLSTbMfiGItA1c/jc2PUo6eM X2j+JhEm7W3rV9X58r356AOD4QGIkNS61YT0eeWTFykxZMHUQcgtBgNCSjZh0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794631626; 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=w1ShKTK/Wd+dmat5XmFLOhLzp9Ep1rPwZ573QySOp0k=; b=VddMK8vgiFlvgkbVq98QDlW0G6V/GR/CsWd7DHYm+iWCz8pyPTfbPWbTdlGYKlS4Zkz2hv ULwTuyvrTWU8c6waWFNaqJP2OyepCV+STrVUZGRgNQCBc6W4MStIAIghSCf5joE13z81xY rZ7ONZ3wvfA5Ub/rwWXy/g5CiWlg1IMYlm/9wKPkiLfdxxxVpuejKnA1qr+PrWdBdqfIZi hBPf9U15NKikw7HcZ6ryZHXyvj0P0FBoIFOt3JpjdUVvixAkdJRyG4aDinfaEmp7F5pvre ULYbZs03rmJp0icRdX2+HCL8Fbov/TtE2EoW8koOmnZ/NwDpxZMlE6v9RsmL1g== 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 4jRM6f1gfLz16ZP for ; Sat, 14 Nov 2026 04:47:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 161fc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 04:47:06 +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: Ryan Moeller Subject: git: 78ca640f79c5 - stable/15 - 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: rmoeller X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 78ca640f79c585ea737c03a0c427bfe53582fd30 Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 04:47:06 +0000 Message-Id: <6af7e7ca.161fc.5c4f9606@gitrepo.freebsd.org> The branch stable/15 has been updated by rmoeller: URL: https://cgit.FreeBSD.org/src/commit/?id=78ca640f79c585ea737c03a0c427bfe53582fd30 commit 78ca640f79c585ea737c03a0c427bfe53582fd30 Author: Cyrille C. <18537428+CrochetFeve0251@users.noreply.github.com> AuthorDate: 2026-10-06 23:11:09 +0000 Commit: Ryan Moeller CommitDate: 2026-11-14 04:45:48 +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: kevans (mentor) (cherry picked from commit f1f96f5e7b01c791add67b27e8014e3986d10513) --- 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 9e899e3ea334..3e3cd9d64eac 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1484,6 +1484,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); @@ -1492,7 +1499,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); } }