From nobody Sat Nov 14 17:26:27 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 4jRgyr30J2z6y1GP for ; Sat, 14 Nov 2026 17:26:28 +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 4jRgyr0GD1z4nmP for ; Sat, 14 Nov 2026 17:26:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677188; 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=CHcvKu1kKjVSSqPVMb5219u8eS4fMORF/l0CsVPnQSc=; b=bkDEke6WFNgHExiPS+n7PmxOoNlaOgExXsM4OBxalNRrprv4Fb4/cuxPke0S8hlcd6Xsw+ p+n/AWcGDaspmNac23bf/eYd02zomIgw0e1dgncN1xYhfIfwpFbd4qLni+pACiQ8HcWWZO TozEs5QgOvqvaHnNcCyO50q1M10SWaiRvEzyAud+ijBtxMGhldDeekyDvOKwwP9jICadtZ LegdhWD7dn4hpXiGvjlVdvUB6lQA4k/PsmobYfZNqd+6gcRYj0qMcDkiUmCWvwHa2CbCPd fLFXqpHENYLJ212Pnxy1BUBdmkizGxqD1MnwpQKuVdELQGaxs3nunV4hP3MCjQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794677188; b=SiSG6+HAMsoIdqiRHbkr20/IqlVHMxpt98lO6Qqdfc7lW1Gkv+o8utTFFnlbdnLv9J+xAk MGS4kr3B6CxXaoBG7tfPLIPR2Gxub4bUTSOdQK5K/KhCPnM44Q58/Dn689/OO3pkgekOds nrPgwuHnl6QKy1DAbKtaxP1A1qeyHEKCdO5IwhckobCBTa0jcpNO9EcWlbH/cNG3rx65Yl xdL6oEG4/hHKdv2kjNddnajEW0H8cVWRvAog4zhvlpMHuWL49yilpAE+I730f5LEGjw5iE UVJsz/LEDEUOzFlGWA3QI0cJd8uOmuI1AQfze5cadn7QnmgCmypGQ/JFY7riIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677188; 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=CHcvKu1kKjVSSqPVMb5219u8eS4fMORF/l0CsVPnQSc=; b=jvrAG3K8B/j+u4iHqtbw0Rd6ncKvHw+v0vmeuDygsU42c58MmT7yEqB1b258pT5PB+z32t nf32cKUDx4DO8Z9gyzdrnEYjZoEqV1kV2PObmaoPC/A7i3cqTeKPLhtsiBAWbS5PnPMODw qe5+xfgzBK2lA7tUba+xDBRc/015JUXciwokYFGLvAuUJYHe9nUwylkc8OHmDNBllRBW4D 9Y6e6gloxYj5N0yu/RHaskSHAGSSLA5Eg36dm6kTW2QyIks+Z960+8TWlY5FYDMZNyVbhc c8PBEMSMNb1nBAKx1lDJJ1ACWq85ibl0vdVLbKXNbUYCbJQssH2/4klicr4+rw== 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 4jRgyq6S7dzVCt for ; Sat, 14 Nov 2026 17:26:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d67c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 17:26:27 +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: Colin Percival Subject: git: 4b06b647733c - releng/15.2 - 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.2 X-Git-Reftype: branch X-Git-Commit: 4b06b647733c315fd233022587012283b81376fc Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 17:26:27 +0000 Message-Id: <6af899c3.1d67c.73203270@gitrepo.freebsd.org> The branch releng/15.2 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=4b06b647733c315fd233022587012283b81376fc commit 4b06b647733c315fd233022587012283b81376fc Author: Cyrille C. <18537428+CrochetFeve0251@users.noreply.github.com> AuthorDate: 2026-10-06 23:11:09 +0000 Commit: Colin Percival CommitDate: 2026-11-14 17:26:00 +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: re (cperciva) 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 1bf22b2639b2..e291fcf6def8 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1482,6 +1482,13 @@ dbuf_is_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); @@ -1490,7 +1497,8 @@ dbuf_is_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); } }