Lines Matching defs:bpo

98 	bpobj_t bpo;
104 VERIFY3U(0, ==, bpobj_open(&bpo, os, obj));
106 mutex_enter(&bpo.bpo_lock);
108 if (!bpo.bpo_havesubobj || bpo.bpo_phys->bpo_subobjs == 0)
111 VERIFY3U(0, ==, dmu_object_info(os, bpo.bpo_phys->bpo_subobjs, &doi));
114 for (i = bpo.bpo_phys->bpo_num_subobjs - 1; i >= 0; i--) {
125 bpo.bpo_phys->bpo_subobjs, offset, FTAG, &dbuf, 0));
138 VERIFY3U(0, ==, dmu_object_free(os, bpo.bpo_phys->bpo_subobjs, tx));
141 mutex_exit(&bpo.bpo_lock);
142 bpobj_close(&bpo);
148 bpobj_open(bpobj_t *bpo, objset_t *os, uint64_t object)
157 bzero(bpo, sizeof (*bpo));
158 mutex_init(&bpo->bpo_lock, NULL, MUTEX_DEFAULT, NULL);
160 ASSERT(bpo->bpo_dbuf == NULL);
161 ASSERT(bpo->bpo_phys == NULL);
166 err = dmu_bonus_hold(os, object, bpo, &bpo->bpo_dbuf);
170 bpo->bpo_os = os;
171 bpo->bpo_object = object;
172 bpo->bpo_epb = doi.doi_data_block_size >> SPA_BLKPTRSHIFT;
173 bpo->bpo_havecomp = (doi.doi_bonus_size > BPOBJ_SIZE_V0);
174 bpo->bpo_havesubobj = (doi.doi_bonus_size > BPOBJ_SIZE_V1);
175 bpo->bpo_phys = bpo->bpo_dbuf->db_data;
180 bpobj_is_open(const bpobj_t *bpo)
182 return (bpo->bpo_object != 0);
186 bpobj_close(bpobj_t *bpo)
189 if (bpo->bpo_object == 0)
192 dmu_buf_rele(bpo->bpo_dbuf, bpo);
193 if (bpo->bpo_cached_dbuf != NULL)
194 dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
195 bpo->bpo_dbuf = NULL;
196 bpo->bpo_phys = NULL;
197 bpo->bpo_cached_dbuf = NULL;
198 bpo->bpo_object = 0;
200 mutex_destroy(&bpo->bpo_lock);
204 bpobj_is_empty(bpobj_t *bpo)
206 return (bpo->bpo_phys->bpo_num_blkptrs == 0 &&
207 (!bpo->bpo_havesubobj || bpo->bpo_phys->bpo_num_subobjs == 0));
211 bpobj_iterate_impl(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx,
220 ASSERT(bpobj_is_open(bpo));
221 mutex_enter(&bpo->bpo_lock);
224 dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
226 for (i = bpo->bpo_phys->bpo_num_blkptrs - 1; i >= 0; i--) {
232 blkoff = P2PHASE(i, bpo->bpo_epb);
237 err = dmu_buf_hold(bpo->bpo_os, bpo->bpo_object, offset,
252 bpo->bpo_phys->bpo_bytes -=
253 bp_get_dsize_sync(dmu_objset_spa(bpo->bpo_os), bp);
254 ASSERT3S(bpo->bpo_phys->bpo_bytes, >=, 0);
255 if (bpo->bpo_havecomp) {
256 bpo->bpo_phys->bpo_comp -= BP_GET_PSIZE(bp);
257 bpo->bpo_phys->bpo_uncomp -= BP_GET_UCSIZE(bp);
259 bpo->bpo_phys->bpo_num_blkptrs--;
260 ASSERT3S(bpo->bpo_phys->bpo_num_blkptrs, >=, 0);
268 VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os, bpo->bpo_object,
271 if (err || !bpo->bpo_havesubobj || bpo->bpo_phys->bpo_subobjs == 0)
274 ASSERT(bpo->bpo_havecomp);
275 err = dmu_object_info(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs, &doi);
277 mutex_exit(&bpo->bpo_lock);
283 for (i = bpo->bpo_phys->bpo_num_subobjs - 1; i >= 0; i--) {
296 err = dmu_buf_hold(bpo->bpo_os,
297 bpo->bpo_phys->bpo_subobjs, offset, FTAG, &dbuf, 0);
306 err = bpobj_open(&sublist, bpo->bpo_os, objarray[blkoff]);
321 bpo->bpo_phys->bpo_bytes -= used_before - used_after;
322 ASSERT3S(bpo->bpo_phys->bpo_bytes, >=, 0);
323 bpo->bpo_phys->bpo_comp -= comp_before - comp_after;
324 bpo->bpo_phys->bpo_uncomp -=
332 err = dmu_object_free(bpo->bpo_os,
336 bpo->bpo_phys->bpo_num_subobjs--;
337 ASSERT3S(bpo->bpo_phys->bpo_num_subobjs, >=, 0);
345 VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os,
346 bpo->bpo_phys->bpo_subobjs,
352 if (bpobj_is_empty(bpo)) {
353 ASSERT0(bpo->bpo_phys->bpo_bytes);
354 ASSERT0(bpo->bpo_phys->bpo_comp);
355 ASSERT0(bpo->bpo_phys->bpo_uncomp);
358 mutex_exit(&bpo->bpo_lock);
367 bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx)
369 return (bpobj_iterate_impl(bpo, func, arg, tx, B_TRUE));
376 bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx)
378 return (bpobj_iterate_impl(bpo, func, arg, tx, B_FALSE));
382 bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
387 ASSERT(bpobj_is_open(bpo));
389 ASSERT(bpo->bpo_havesubobj);
390 ASSERT(bpo->bpo_havecomp);
391 ASSERT(bpo->bpo_object != dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj);
393 if (subobj == dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj) {
394 bpobj_decr_empty(bpo->bpo_os, tx);
398 VERIFY3U(0, ==, bpobj_open(&subbpo, bpo->bpo_os, subobj));
404 bpobj_free(bpo->bpo_os, subobj, tx);
408 mutex_enter(&bpo->bpo_lock);
409 dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
410 if (bpo->bpo_phys->bpo_subobjs == 0) {
411 bpo->bpo_phys->bpo_subobjs = dmu_object_alloc(bpo->bpo_os,
417 ASSERT0(dmu_object_info(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs, &doi));
420 dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
421 bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
423 bpo->bpo_phys->bpo_num_subobjs++;
427 * subobjs to bpo's subobj list directly. This reduces
434 VERIFY3U(0, ==, dmu_object_info(bpo->bpo_os, subsubobjs, &doi));
439 VERIFY3U(0, ==, dmu_buf_hold(bpo->bpo_os, subsubobjs,
447 dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
448 bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
451 bpo->bpo_phys->bpo_num_subobjs += numsubsub;
455 VERIFY3U(0, ==, dmu_object_free(bpo->bpo_os,
459 bpo->bpo_phys->bpo_bytes += used;
460 bpo->bpo_phys->bpo_comp += comp;
461 bpo->bpo_phys->bpo_uncomp += uncomp;
462 mutex_exit(&bpo->bpo_lock);
468 bpobj_enqueue(bpobj_t *bpo, const blkptr_t *bp, dmu_tx_t *tx)
475 ASSERT(bpobj_is_open(bpo));
477 ASSERT(bpo->bpo_object != dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj);
502 mutex_enter(&bpo->bpo_lock);
504 offset = bpo->bpo_phys->bpo_num_blkptrs * sizeof (stored_bp);
505 blkoff = P2PHASE(bpo->bpo_phys->bpo_num_blkptrs, bpo->bpo_epb);
507 if (bpo->bpo_cached_dbuf == NULL ||
508 offset < bpo->bpo_cached_dbuf->db_offset ||
509 offset >= bpo->bpo_cached_dbuf->db_offset +
510 bpo->bpo_cached_dbuf->db_size) {
511 if (bpo->bpo_cached_dbuf)
512 dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
513 VERIFY3U(0, ==, dmu_buf_hold(bpo->bpo_os, bpo->bpo_object,
514 offset, bpo, &bpo->bpo_cached_dbuf, 0));
517 dmu_buf_will_dirty(bpo->bpo_cached_dbuf, tx);
518 bparray = bpo->bpo_cached_dbuf->db_data;
521 dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
522 bpo->bpo_phys->bpo_num_blkptrs++;
523 bpo->bpo_phys->bpo_bytes +=
524 bp_get_dsize_sync(dmu_objset_spa(bpo->bpo_os), bp);
525 if (bpo->bpo_havecomp) {
526 bpo->bpo_phys->bpo_comp += BP_GET_PSIZE(bp);
527 bpo->bpo_phys->bpo_uncomp += BP_GET_UCSIZE(bp);
529 mutex_exit(&bpo->bpo_lock);
559 bpobj_space(bpobj_t *bpo, uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
561 ASSERT(bpobj_is_open(bpo));
562 mutex_enter(&bpo->bpo_lock);
564 *usedp = bpo->bpo_phys->bpo_bytes;
565 if (bpo->bpo_havecomp) {
566 *compp = bpo->bpo_phys->bpo_comp;
567 *uncompp = bpo->bpo_phys->bpo_uncomp;
568 mutex_exit(&bpo->bpo_lock);
571 mutex_exit(&bpo->bpo_lock);
572 return (bpobj_space_range(bpo, 0, UINT64_MAX,
582 bpobj_space_range(bpobj_t *bpo, uint64_t mintxg, uint64_t maxtxg,
588 ASSERT(bpobj_is_open(bpo));
594 if (mintxg < TXG_INITIAL && maxtxg == UINT64_MAX && bpo->bpo_havecomp)
595 return (bpobj_space(bpo, usedp, compp, uncompp));
597 sra.spa = dmu_objset_spa(bpo->bpo_os);
601 err = bpobj_iterate_nofree(bpo, space_range_cb, &sra, NULL);