Skip to content

Fix FDT rollback to not overwrite unnecessary fields #17205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/sys/ddt.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ extern void ddt_bp_create(enum zio_checksum checksum, const ddt_key_t *ddk,

extern void ddt_phys_extend(ddt_univ_phys_t *ddp, ddt_phys_variant_t v,
const blkptr_t *bp);
extern void ddt_phys_unextend(ddt_univ_phys_t *cur, ddt_univ_phys_t *orig,
ddt_phys_variant_t v);
extern void ddt_phys_copy(ddt_univ_phys_t *dst, const ddt_univ_phys_t *src,
ddt_phys_variant_t v);
extern void ddt_phys_clear(ddt_univ_phys_t *ddp, ddt_phys_variant_t v);
Expand Down
21 changes: 21 additions & 0 deletions module/zfs/ddt.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,27 @@ ddt_phys_extend(ddt_univ_phys_t *ddp, ddt_phys_variant_t v, const blkptr_t *bp)
}
}

void
ddt_phys_unextend(ddt_univ_phys_t *cur, ddt_univ_phys_t *orig,
ddt_phys_variant_t v)
{
ASSERT3U(v, <, DDT_PHYS_NONE);
dva_t *cur_dvas = (v == DDT_PHYS_FLAT) ?
cur->ddp_flat.ddp_dva : cur->ddp_trad[v].ddp_dva;
dva_t *orig_dvas = (v == DDT_PHYS_FLAT) ?
orig->ddp_flat.ddp_dva : orig->ddp_trad[v].ddp_dva;

for (int d = 0; d < SPA_DVAS_PER_BP; d++)
cur_dvas[d] = orig_dvas[d];

if (ddt_phys_birth(orig, v) == 0) {
if (v == DDT_PHYS_FLAT)
cur->ddp_flat.ddp_phys_birth = 0;
else
cur->ddp_trad[v].ddp_phys_birth = 0;
}
}

void
ddt_phys_copy(ddt_univ_phys_t *dst, const ddt_univ_phys_t *src,
ddt_phys_variant_t v)
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3607,7 +3607,7 @@ zio_ddt_child_write_done(zio_t *zio)
* chain. We need to revert the entry back to what it was at
* the last time it was successfully extended.
*/
ddt_phys_copy(ddp, orig, v);
ddt_phys_unextend(ddp, orig, v);
ddt_phys_clear(orig, v);

ddt_exit(ddt);
Expand Down
Loading