/* * Return (in *dsizep) the amount of space on the deadlist which is: * mintxg < blk_birth <= maxtxg */ int bplist_space_birthrange(bplist_t *bpl, uint64_t mintxg, uint64_t maxtxg, uint64_t *dsizep) { uint64_t size = 0; uint64_t itor = 0; blkptr_t bp; int err; /* * As an optimization, if they want the whole txg range, just * get bpl_bytes rather than iterating over the bps. */ if (mintxg < TXG_INITIAL && maxtxg == UINT64_MAX) { mutex_enter(&bpl->bpl_lock); err = bplist_hold(bpl); if (err == 0) *dsizep = bpl->bpl_phys->bpl_bytes; mutex_exit(&bpl->bpl_lock); return (err); } while ((err = bplist_iterate(bpl, &itor, &bp)) == 0) { if (bp.blk_birth > mintxg && bp.blk_birth <= maxtxg) { size += bp_get_dsize(dmu_objset_spa(bpl->bpl_mos), &bp); } } if (err == ENOENT) err = 0; *dsizep = size; return (err); }
int bplist_space(bplist_t *bpl, uint64_t *usedp, uint64_t *compp, uint64_t *uncompp) { uint64_t itor = 0, comp = 0, uncomp = 0; int err; blkptr_t bp; mutex_enter(&bpl->bpl_lock); err = bplist_hold(bpl); if (err) { mutex_exit(&bpl->bpl_lock); return (err); } *usedp = bpl->bpl_phys->bpl_bytes; if (bpl->bpl_havecomp) { *compp = bpl->bpl_phys->bpl_comp; *uncompp = bpl->bpl_phys->bpl_uncomp; } mutex_exit(&bpl->bpl_lock); if (!bpl->bpl_havecomp) { while ((err = bplist_iterate(bpl, &itor, &bp)) == 0) { comp += BP_GET_PSIZE(&bp); uncomp += BP_GET_UCSIZE(&bp); } if (err == ENOENT) err = 0; *compp = comp; *uncompp = uncomp; } return (err); }