MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zio_ddt_write

Function zio_ddt_write

freebsd/contrib/openzfs/module/zfs/zio.c:3271–3344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3269}
3270
3271static zio_t *
3272zio_ddt_write(zio_t *zio)
3273{
3274 spa_t *spa = zio->io_spa;
3275 blkptr_t *bp = zio->io_bp;
3276 uint64_t txg = zio->io_txg;
3277 zio_prop_t *zp = &zio->io_prop;
3278 int p = zp->zp_copies;
3279 zio_t *cio = NULL;
3280 ddt_t *ddt = ddt_select(spa, bp);
3281 ddt_entry_t *dde;
3282 ddt_phys_t *ddp;
3283
3284 ASSERT(BP_GET_DEDUP(bp));
3285 ASSERT(BP_GET_CHECKSUM(bp) == zp->zp_checksum);
3286 ASSERT(BP_IS_HOLE(bp) || zio->io_bp_override);
3287 ASSERT(!(zio->io_bp_override && (zio->io_flags & ZIO_FLAG_RAW)));
3288
3289 ddt_enter(ddt);
3290 dde = ddt_lookup(ddt, bp, B_TRUE);
3291 ddp = &dde->dde_phys[p];
3292
3293 if (zp->zp_dedup_verify && zio_ddt_collision(zio, ddt, dde)) {
3294 /*
3295 * If we're using a weak checksum, upgrade to a strong checksum
3296 * and try again. If we're already using a strong checksum,
3297 * we can't resolve it, so just convert to an ordinary write.
3298 * (And automatically e-mail a paper to Nature?)
3299 */
3300 if (!(zio_checksum_table[zp->zp_checksum].ci_flags &
3301 ZCHECKSUM_FLAG_DEDUP)) {
3302 zp->zp_checksum = spa_dedup_checksum(spa);
3303 zio_pop_transforms(zio);
3304 zio->io_stage = ZIO_STAGE_OPEN;
3305 BP_ZERO(bp);
3306 } else {
3307 zp->zp_dedup = B_FALSE;
3308 BP_SET_DEDUP(bp, B_FALSE);
3309 }
3310 ASSERT(!BP_GET_DEDUP(bp));
3311 zio->io_pipeline = ZIO_WRITE_PIPELINE;
3312 ddt_exit(ddt);
3313 return (zio);
3314 }
3315
3316 if (ddp->ddp_phys_birth != 0 || dde->dde_lead_zio[p] != NULL) {
3317 if (ddp->ddp_phys_birth != 0)
3318 ddt_bp_fill(ddp, bp, txg);
3319 if (dde->dde_lead_zio[p] != NULL)
3320 zio_add_child(zio, dde->dde_lead_zio[p]);
3321 else
3322 ddt_phys_addref(ddp);
3323 } else if (zio->io_bp_override) {
3324 ASSERT(bp->blk_birth == txg);
3325 ASSERT(BP_EQUAL(bp, zio->io_bp_override));
3326 ddt_phys_fill(ddp, bp);
3327 ddt_phys_addref(ddp);
3328 } else {

Callers

nothing calls this directly

Calls 14

ddt_selectFunction · 0.85
ddt_enterFunction · 0.85
ddt_lookupFunction · 0.85
zio_ddt_collisionFunction · 0.85
spa_dedup_checksumFunction · 0.85
zio_pop_transformsFunction · 0.85
ddt_exitFunction · 0.85
ddt_bp_fillFunction · 0.85
zio_add_childFunction · 0.85
ddt_phys_addrefFunction · 0.85
ddt_phys_fillFunction · 0.85
zio_writeFunction · 0.85

Tested by

no test coverage detected