BRT: Fix holes cloning.

- When reading L0 block pointers handle buffers without ones and
without dirty records as a holes.  Those appear when dnode size
was increased, but the end was never written, so there are no new
indirection levels to store the pointers.  It makes no sense to
return EAGAIN here, since sync won't create new indirection levels
until there will be actual writes.
 - When cloning blocks set destination hole logical birth time
to the current TXG.  Otherwise if we are cloning over existing
data, newly created holes may not be properly replicated later.
Use BP_SET_BIRTH() when possible to not replicate its logic.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15994
Closes #16007
This commit is contained in:
Alexander Motin 2024-03-18 14:19:53 -04:00 committed by Brian Behlendorf
parent 3e91a9c525
commit 2ea370a4e3
1 changed files with 13 additions and 13 deletions

View File

@ -2265,11 +2265,13 @@ dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
if (bp == NULL) { if (bp == NULL) {
/* /*
* The block was created in this transaction group, * The file size was increased, but the block was never
* so it has no BP yet. * written, otherwise we would either have the block
* pointer or the dirty record and would not get here.
* It is effectively a hole, so report it as such.
*/ */
error = SET_ERROR(EAGAIN); BP_ZERO(&bps[i]);
goto out; continue;
} }
/* /*
* Make sure we clone only data blocks. * Make sure we clone only data blocks.
@ -2361,18 +2363,16 @@ dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
ASSERT3U(dr->dr_txg, ==, tx->tx_txg); ASSERT3U(dr->dr_txg, ==, tx->tx_txg);
dl = &dr->dt.dl; dl = &dr->dt.dl;
dl->dr_overridden_by = *bp; dl->dr_overridden_by = *bp;
dl->dr_brtwrite = B_TRUE; if (!BP_IS_HOLE(bp) || bp->blk_birth != 0) {
dl->dr_override_state = DR_OVERRIDDEN;
if (BP_IS_HOLE(bp)) {
dl->dr_overridden_by.blk_birth = 0;
dl->dr_overridden_by.blk_phys_birth = 0;
} else {
dl->dr_overridden_by.blk_birth = dr->dr_txg;
if (!BP_IS_EMBEDDED(bp)) { if (!BP_IS_EMBEDDED(bp)) {
dl->dr_overridden_by.blk_phys_birth = BP_SET_BIRTH(&dl->dr_overridden_by, dr->dr_txg,
BP_PHYSICAL_BIRTH(bp); BP_PHYSICAL_BIRTH(bp));
} else {
dl->dr_overridden_by.blk_birth = dr->dr_txg;
} }
} }
dl->dr_brtwrite = B_TRUE;
dl->dr_override_state = DR_OVERRIDDEN;
mutex_exit(&db->db_mtx); mutex_exit(&db->db_mtx);