🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.fs
Article #95

[Bug 301442] [zfs] 15.1 corrupts pools with a legacy dedup table: please merge OpenZFS e7f2c9fb87ca to stable/15 and issue an er...

#95
From: bugzilla-noreply
Date: Thu, 03 Dec 2026 21:57
108 lines
7601 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301442

--- Comment #12 from commit-hook@FreeBSD.org ---
A commit in branch releng/15.2 references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=c80cc23305f027c32ebca6edb724eb6ef367adbd

commit c80cc23305f027c32ebca6edb724eb6ef367adbd
Author:     Kamil Monicz <kamil@monicz.dev>
AuthorDate: 2026-07-16 22:38:16 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-12-03 21:55:40 +0000

    ddt: select traditional phys by block identity, not BP DVA count

    The write path stores a traditional DDT entry in the phys slot chosen
    by the zp_copies value the block was written with, but the free-path
    lookup validation (ddt_entry_lookup_is_valid()) selected the slot to
    compare by the BP's physical DVA count, and ddt_addref() bumped the
    refcount of that same wrongly-selected slot.

    The two indexes diverge whenever a deduplicated block's BP carries
    more DVAs than its copies value, which is exactly what ganging does:
    a gang header is stored in more copies than the data it gangs, so
    copies=1 blocks get a two-DVA gang header BP (unconditionally
    through 2.3.3, and under the default redundant_metadata=all since
    a46ce73ca8 made it configurable in 2.3.4 and 9250403ba6 in 2.4.0),
    and from 2.3.4 that default also gives unencrypted copies=2 blocks a
    three-DVA header BP. Encryption does not avoid the mismatch at
    copies=1: the header BP still carries two counted DVAs (the salt/IV
    DVA is separate). For such a block the validation checked
    the wrong slot, concluded the entry had been pruned, and
    zio_ddt_free() fell back to a plain physical free: the shared gang
    header extents were freed once per DDT-referenced delete with no
    refcount decrement.

    Consequences per triggering delete: remaining references point at
    freed header sectors and fail with gang_header checksum errors once
    the space is reused; the second and later deletes commit overlapping
    FREE records to the spacemaps ("zfs: rt=...: adding segment ...
    overlapping with existing one" panics at import or runtime), or free
    unrelated live allocations if the extents were reused in between;
    the gang members are never traversed and leak once the last
    reference is deleted; and the entry itself becomes immortal, so
    future identical writes dedup against freed storage.

    Fix the validation to match a phys by block identity (DVA[0] and
    physical birth) via ddt_phys_select(), which is what the decref path
    already uses; this also implements the existing "XXX ... maybe can
    combine" comment. Fix ddt_addref() the same way in the same commit:
    its identical mis-indexing is currently masked only by the verified
    lookup failing first, so fixing the lookup alone would unmask a
    refcount increment on the wrong slot. The verified lookup guarantees
    a matching phys exists, and the VERIFY keeps DDT_PHYS_NONE from
    reaching ddt_phys_addref(), which would index out of bounds on
    release builds. Incidentally this also repairs frees of legacy
    DDT_PHYS_DITTO blocks (the old code could never select slot 0).

    Since traditional tables are never pruned (pruning only walks flat
    tables), a free-time lookup miss on one should not happen on a
    consistent pool: leave a zfs_dbgmsg trace when it happens instead of
    silently bypassing the refcount.

    The free-path regression dates to d4d79451cb ("Add DDT prune
    command"), first released in 2.3.0; before that the free path
    selected the phys by DVA identity. The ddt_addref() half predates it
    and is present in 2.2.x via block cloning. Note the code fix cannot
    repair damage already committed by the bug: leaked members, spacemap
    double frees, stale entries, and clones whose references landed in
    the BRT because ddt_addref() failed all persist on disk.

    Add a ZTS test that forces ganging on a legacy-DDT pool, takes three
    references to the same gang blocks (write, dedup copy, block clone),
    verifies the refcount of the copies=1 phys after every step, and
    checks the final state with zdb -bcc. It takes the clone reference
    with FICLONE, so it is registered Linux-only alongside the other
    FICLONE tests.

    Approved by:    re (cperciva)
    Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
    Signed-off-by: Kamil Monicz <kamil@monicz.dev>
    Closes #18819

    PR:             301442
    Approved by:    kevans (mentor)
    (cherry picked from commit e7f2c9fb87cae840c85199b2c5633765c5a23e44)
    (cherry picked from commit dc7b06df571d318493b99ab44c0124594fb47ff2)

 sys/contrib/openzfs/include/sys/ddt.h              |   9 +-
 sys/contrib/openzfs/module/zfs/ddt.c               |  65 ++++----
 sys/contrib/openzfs/module/zfs/zio.c               |  28 +++-
 sys/contrib/openzfs/tests/runfiles/linux.run       |   4 +
 .../openzfs/tests/zfs-tests/tests/Makefile.am      |   1 +
 .../dedup/dedup_legacy_gang.ksh (new +x)           | 177 +++++++++++++++++++++
 6 files changed, 239 insertions(+), 45 deletions(-)

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-301442-3630-bc3KThcz14@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
References: <bug-301442-3630@https.bugs.freebsd.org/bugzilla/>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.fs
Subject: [Bug 301442] [zfs] 15.1 corrupts pools with a legacy dedup table:
 please merge OpenZFS e7f2c9fb87ca to stable/15 and issue an errata notice
Date: Thu, 03 Dec 2026 21:57:04 +0000
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-301442-3630-bc3KThcz14@https.bugs.freebsd.org/bugzilla/>
References: <bug-301442-3630@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="6852"; mail-complaints-to="news-admin@muc.de"
X-Original-To: fs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1796335025;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=Q5DOwhAo69OzgVzPTD5I40e7ysGnxjnWwKE52NxU6B8=;
	b=ezI7G1WZP6EJV/apvEJC5ykKvF+yUhoVLnWjc2jauyHtWJa1+cCe2NbrcWF/RdfEWT7SBw
	2HNs5QZ6HQScx0/rJaSo6BR5MBpg3tGqDq7ypp6yiSrkW1kNfXytMydCL5rI+whq8alQ2R
	LxAp60iAmrXDtdIQfVDDGtIj4dt3gwT4NAjfnvIQWSQNaIFZZoGsxcc50jb5GWVpXuJflh
	0muAqf4V8RtZ6jmKY6bLfLuiwvUtj2gctClJjYvYjpKnzT/7aFx+rmS4RfBp0PbYz3oRvF
	GfIjTCivGgfmc6BxecA3hxcWlKzZWU+PWOH52zIZ4+stSCrDAdSuP2LdNJSgPg==
X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@freebsd.org using -f
In-Reply-To: <bug-301442-3630@https.bugs.freebsd.org/bugzilla/>
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes