Lines Matching +full:os +full:- +full:data +full:- +full:offset
9 * or https://opensource.org/licenses/CDDL-1.0.
175 dmu_buf_hold_noread_by_dnode(dnode_t *dn, uint64_t offset, in dmu_buf_hold_noread_by_dnode() argument
181 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_buf_hold_noread_by_dnode()
182 blkid = dbuf_whichblock(dn, 0, offset); in dmu_buf_hold_noread_by_dnode()
184 rw_exit(&dn->dn_struct_rwlock); in dmu_buf_hold_noread_by_dnode()
191 *dbp = &db->db; in dmu_buf_hold_noread_by_dnode()
196 dmu_buf_hold_noread(objset_t *os, uint64_t object, uint64_t offset, in dmu_buf_hold_noread() argument
204 err = dnode_hold(os, object, FTAG, &dn); in dmu_buf_hold_noread()
207 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_buf_hold_noread()
208 blkid = dbuf_whichblock(dn, 0, offset); in dmu_buf_hold_noread()
210 rw_exit(&dn->dn_struct_rwlock); in dmu_buf_hold_noread()
218 *dbp = &db->db; in dmu_buf_hold_noread()
223 dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset, in dmu_buf_hold_by_dnode() argument
234 err = dmu_buf_hold_noread_by_dnode(dn, offset, tag, dbp); in dmu_buf_hold_by_dnode()
248 dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, in dmu_buf_hold() argument
259 err = dmu_buf_hold_noread(os, object, offset, tag, dbp); in dmu_buf_hold()
285 if (newsize < 0 || newsize > db_fake->db_size) in dmu_set_bonus()
291 if (dn->dn_bonus != db) { in dmu_set_bonus()
315 if (dn->dn_bonus != db) { in dmu_set_bonustype()
333 type = DB_DNODE(db)->dn_bonustype; in dmu_get_bonustype()
340 dmu_rm_spill(objset_t *os, uint64_t object, dmu_tx_t *tx) in dmu_rm_spill() argument
345 error = dnode_hold(os, object, FTAG, &dn); in dmu_rm_spill()
347 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); in dmu_rm_spill()
349 rw_exit(&dn->dn_struct_rwlock); in dmu_rm_spill()
371 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_bonus_hold_by_dnode()
372 if (dn->dn_bonus == NULL) { in dmu_bonus_hold_by_dnode()
373 if (!rw_tryupgrade(&dn->dn_struct_rwlock)) { in dmu_bonus_hold_by_dnode()
374 rw_exit(&dn->dn_struct_rwlock); in dmu_bonus_hold_by_dnode()
375 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); in dmu_bonus_hold_by_dnode()
377 if (dn->dn_bonus == NULL) in dmu_bonus_hold_by_dnode()
380 db = dn->dn_bonus; in dmu_bonus_hold_by_dnode()
383 if (zfs_refcount_add(&db->db_holds, tag) == 1) { in dmu_bonus_hold_by_dnode()
385 atomic_inc_32(&dn->dn_dbufs_count); in dmu_bonus_hold_by_dnode()
393 rw_exit(&dn->dn_struct_rwlock); in dmu_bonus_hold_by_dnode()
403 *dbp = &db->db; in dmu_bonus_hold_by_dnode()
408 dmu_bonus_hold(objset_t *os, uint64_t object, const void *tag, dmu_buf_t **dbp) in dmu_bonus_hold() argument
413 error = dnode_hold(os, object, FTAG, &dn); in dmu_bonus_hold()
440 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_spill_hold_by_dnode()
445 rw_exit(&dn->dn_struct_rwlock); in dmu_spill_hold_by_dnode()
453 *dbp = &db->db; in dmu_spill_hold_by_dnode()
471 if (spa_version(dn->dn_objset->os_spa) < SPA_VERSION_SA) { in dmu_spill_hold_existing()
474 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_spill_hold_existing()
476 if (!dn->dn_have_spill) { in dmu_spill_hold_existing()
483 rw_exit(&dn->dn_struct_rwlock); in dmu_spill_hold_existing()
509 * Note: longer-term, we should modify all of the dmu_buf_*() interfaces
510 * to take a held dnode rather than <os, object> -- the lookup is wasteful,
515 dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, in dmu_buf_hold_array_by_dnode() argument
531 * we can tell it about the multi-block read. dbuf_read() only knows in dmu_buf_hold_array_by_dnode()
540 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_buf_hold_array_by_dnode()
541 if (dn->dn_datablkshift) { in dmu_buf_hold_array_by_dnode()
542 int blkshift = dn->dn_datablkshift; in dmu_buf_hold_array_by_dnode()
543 nblks = (P2ROUNDUP(offset + length, 1ULL << blkshift) - in dmu_buf_hold_array_by_dnode()
544 P2ALIGN_TYPED(offset, 1ULL << blkshift, uint64_t)) in dmu_buf_hold_array_by_dnode()
547 if (offset + length > dn->dn_datablksz) { in dmu_buf_hold_array_by_dnode()
550 (longlong_t)dn->dn_objset-> in dmu_buf_hold_array_by_dnode()
551 os_dsl_dataset->ds_object, in dmu_buf_hold_array_by_dnode()
552 (longlong_t)dn->dn_object, dn->dn_datablksz, in dmu_buf_hold_array_by_dnode()
553 (longlong_t)offset, (longlong_t)length); in dmu_buf_hold_array_by_dnode()
554 rw_exit(&dn->dn_struct_rwlock); in dmu_buf_hold_array_by_dnode()
562 zio = zio_root(dn->dn_objset->os_spa, NULL, NULL, in dmu_buf_hold_array_by_dnode()
564 blkid = dbuf_whichblock(dn, 0, offset); in dmu_buf_hold_array_by_dnode()
571 zs = dmu_zfetch_prepare(&dn->dn_zfetch, blkid, nblks, read, in dmu_buf_hold_array_by_dnode()
578 dmu_zfetch_run(&dn->dn_zfetch, zs, missed, in dmu_buf_hold_array_by_dnode()
581 rw_exit(&dn->dn_struct_rwlock); in dmu_buf_hold_array_by_dnode()
589 * Initiate async demand data read. in dmu_buf_hold_array_by_dnode()
597 if (i == nblks - 1 && blkid + i < dn->dn_maxblkid && in dmu_buf_hold_array_by_dnode()
598 offset + length < db->db.db_offset + in dmu_buf_hold_array_by_dnode()
599 db->db.db_size) { in dmu_buf_hold_array_by_dnode()
600 if (offset <= db->db.db_offset) in dmu_buf_hold_array_by_dnode()
606 if (db->db_state != DB_CACHED) in dmu_buf_hold_array_by_dnode()
609 dbp[i] = &db->db; in dmu_buf_hold_array_by_dnode()
621 zfs_racct_write(dn->dn_objset->os_spa, length, nblks, flags); in dmu_buf_hold_array_by_dnode()
624 dmu_zfetch_run(&dn->dn_zfetch, zs, missed, B_TRUE); in dmu_buf_hold_array_by_dnode()
625 rw_exit(&dn->dn_struct_rwlock); in dmu_buf_hold_array_by_dnode()
638 mutex_enter(&db->db_mtx); in dmu_buf_hold_array_by_dnode()
639 while (db->db_state == DB_READ || in dmu_buf_hold_array_by_dnode()
640 db->db_state == DB_FILL) in dmu_buf_hold_array_by_dnode()
641 cv_wait(&db->db_changed, &db->db_mtx); in dmu_buf_hold_array_by_dnode()
642 if (db->db_state == DB_UNCACHED) in dmu_buf_hold_array_by_dnode()
644 mutex_exit(&db->db_mtx); in dmu_buf_hold_array_by_dnode()
658 dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset, in dmu_buf_hold_array() argument
665 err = dnode_hold(os, object, FTAG, &dn); in dmu_buf_hold_array()
669 err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag, in dmu_buf_hold_array()
678 dmu_buf_hold_array_by_bonus(dmu_buf_t *db_fake, uint64_t offset, in dmu_buf_hold_array_by_bonus() argument
686 err = dmu_buf_hold_array_by_dnode(DB_DNODE(db), offset, length, read, in dmu_buf_hold_array_by_bonus()
711 * Issue prefetch I/Os for the given blocks. If level is greater than 0, the
713 * the data starting at offset, and continuing to offset + len. If the range
724 dmu_prefetch(objset_t *os, uint64_t object, int64_t level, uint64_t offset, in dmu_prefetch() argument
730 dmu_prefetch_dnode(os, object, pri); in dmu_prefetch()
734 if (dnode_hold(os, object, FTAG, &dn) != 0) in dmu_prefetch()
737 dmu_prefetch_by_dnode(dn, level, offset, len, pri); in dmu_prefetch()
743 dmu_prefetch_by_dnode(dnode_t *dn, int64_t level, uint64_t offset, in dmu_prefetch_by_dnode() argument
753 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_prefetch_by_dnode()
754 if (dn->dn_datablkshift != 0) { in dmu_prefetch_by_dnode()
760 start = dbuf_whichblock(dn, level, offset); in dmu_prefetch_by_dnode()
761 end2 = dbuf_whichblock(dn, level, offset + len - 1) + 1; in dmu_prefetch_by_dnode()
762 uint8_t ibs = dn->dn_indblkshift; in dmu_prefetch_by_dnode()
763 uint8_t bs = (level == 0) ? dn->dn_datablkshift : ibs; in dmu_prefetch_by_dnode()
770 uint8_t ibps = ibs - SPA_BLKPTRSHIFT; in dmu_prefetch_by_dnode()
776 } while (end2 - start2 > limit); in dmu_prefetch_by_dnode()
780 end = start + (level == 0 && offset < dn->dn_datablksz); in dmu_prefetch_by_dnode()
787 rw_exit(&dn->dn_struct_rwlock); in dmu_prefetch_by_dnode()
804 mutex_enter(&dpa->dpa_lock); in dmu_prefetch_done()
805 ASSERT3U(dpa->dpa_pending_io, >, 0); in dmu_prefetch_done()
806 if (--dpa->dpa_pending_io == 0) in dmu_prefetch_done()
807 cv_broadcast(&dpa->dpa_cv); in dmu_prefetch_done()
808 mutex_exit(&dpa->dpa_lock); in dmu_prefetch_done()
812 dmu_prefetch_wait_by_dnode(dnode_t *dn, uint64_t offset, uint64_t len) in dmu_prefetch_wait_by_dnode() argument
819 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_prefetch_wait_by_dnode()
821 uint64_t start = dbuf_whichblock(dn, 0, offset); in dmu_prefetch_wait_by_dnode()
822 uint64_t end = dbuf_whichblock(dn, 0, offset + len - 1) + 1; in dmu_prefetch_wait_by_dnode()
823 dpa.dpa_pending_io = end - start; in dmu_prefetch_wait_by_dnode()
830 rw_exit(&dn->dn_struct_rwlock); in dmu_prefetch_wait_by_dnode()
845 * Issue prefetch I/Os for the given L0 block range and wait for the I/O
851 dmu_prefetch_wait(objset_t *os, uint64_t object, uint64_t offset, uint64_t size) in dmu_prefetch_wait() argument
856 err = dnode_hold(os, object, FTAG, &dn); in dmu_prefetch_wait()
864 if (dn->dn_indblkshift) { in dmu_prefetch_wait()
865 uint64_t nbps = bp_span_in_blocks(dn->dn_indblkshift, 1); in dmu_prefetch_wait()
866 chunksize = (nbps * 16) << dn->dn_datablkshift; in dmu_prefetch_wait()
868 chunksize = dn->dn_datablksz; in dmu_prefetch_wait()
874 dmu_prefetch_wait_by_dnode(dn, offset, mylen); in dmu_prefetch_wait()
876 offset += mylen; in dmu_prefetch_wait()
877 size -= mylen; in dmu_prefetch_wait()
891 * Issue prefetch I/Os for the given object's dnode.
894 dmu_prefetch_dnode(objset_t *os, uint64_t object, zio_priority_t pri) in dmu_prefetch_dnode() argument
899 dnode_t *dn = DMU_META_DNODE(os); in dmu_prefetch_dnode()
900 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_prefetch_dnode()
903 rw_exit(&dn->dn_struct_rwlock); in dmu_prefetch_dnode()
907 * Get the next "chunk" of file data to free. We traverse the file from
910 * data by simply searching the allocated level 1 indirects.
912 * On input, *start should be the first offset that does not need to be
913 * freed (e.g. "offset + length"). On return, *start will be the first
914 * offset that should be freed and l1blks is set to the number of level 1
921 uint64_t maxblks = DMU_MAX_ACCESS >> (dn->dn_indblkshift + 1); in get_next_chunk()
922 /* bytes of data covered by a level-1 indirect block */ in get_next_chunk()
923 uint64_t iblkrange = (uint64_t)dn->dn_datablksz * in get_next_chunk()
924 EPB(dn->dn_indblkshift, SPA_BLKPTRSHIFT); in get_next_chunk()
929 if (dn->dn_nlevels <= 1) { in get_next_chunk()
937 * L1 blocks in this range have data. If we can, we use this in get_next_chunk()
939 * at the object's actual data. in get_next_chunk()
942 (roundup(*start, iblkrange) - (minimum / iblkrange * iblkrange)) / in get_next_chunk()
956 * indirect block at or before the input offset. We must in get_next_chunk()
960 (*start)--; in get_next_chunk()
990 dmu_objset_zfs_unmounting(objset_t *os) in dmu_objset_zfs_unmounting() argument
993 if (dmu_objset_type(os) == DMU_OST_ZFS) in dmu_objset_zfs_unmounting()
994 return (zfs_get_vfs_flag_unmounted(os)); in dmu_objset_zfs_unmounting()
996 (void) os; in dmu_objset_zfs_unmounting()
1002 dmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset, in dmu_free_long_range_impl() argument
1008 dsl_pool_t *dp = dmu_objset_pool(os); in dmu_free_long_range_impl()
1013 object_size = (dn->dn_maxblkid + 1) * dn->dn_datablksz; in dmu_free_long_range_impl()
1014 if (offset >= object_size) in dmu_free_long_range_impl()
1023 if (length == DMU_OBJECT_END || offset + length > object_size) in dmu_free_long_range_impl()
1024 length = object_size - offset; in dmu_free_long_range_impl()
1031 if (dmu_objset_zfs_unmounting(dn->dn_objset)) in dmu_free_long_range_impl()
1034 chunk_end = chunk_begin = offset + length; in dmu_free_long_range_impl()
1037 err = get_next_chunk(dn, &chunk_begin, offset, &l1blks); in dmu_free_long_range_impl()
1040 ASSERT3U(chunk_begin, >=, offset); in dmu_free_long_range_impl()
1043 chunk_len = chunk_end - chunk_begin; in dmu_free_long_range_impl()
1045 tx = dmu_tx_create(os); in dmu_free_long_range_impl()
1046 dmu_tx_hold_free(tx, dn->dn_object, chunk_begin, chunk_len); in dmu_free_long_range_impl()
1061 mutex_enter(&dp->dp_lock); in dmu_free_long_range_impl()
1063 dp->dp_long_free_dirty_pertxg[txg & TXG_MASK]; in dmu_free_long_range_impl()
1064 mutex_exit(&dp->dp_lock); in dmu_free_long_range_impl()
1089 mutex_enter(&dp->dp_lock); in dmu_free_long_range_impl()
1090 dp->dp_long_free_dirty_pertxg[txg & TXG_MASK] += in dmu_free_long_range_impl()
1091 l1blks << dn->dn_indblkshift; in dmu_free_long_range_impl()
1092 mutex_exit(&dp->dp_lock); in dmu_free_long_range_impl()
1100 length -= chunk_len; in dmu_free_long_range_impl()
1106 dmu_free_long_range(objset_t *os, uint64_t object, in dmu_free_long_range() argument
1107 uint64_t offset, uint64_t length) in dmu_free_long_range() argument
1112 err = dnode_hold(os, object, FTAG, &dn); in dmu_free_long_range()
1115 err = dmu_free_long_range_impl(os, dn, offset, length); in dmu_free_long_range()
1123 if (err == 0 && offset == 0 && length == DMU_OBJECT_END) in dmu_free_long_range()
1124 dn->dn_maxblkid = 0; in dmu_free_long_range()
1131 dmu_free_long_object(objset_t *os, uint64_t object) in dmu_free_long_object() argument
1136 err = dmu_free_long_range(os, object, 0, DMU_OBJECT_END); in dmu_free_long_object()
1140 tx = dmu_tx_create(os); in dmu_free_long_object()
1146 err = dmu_object_free(os, object, tx); in dmu_free_long_object()
1156 dmu_free_range(objset_t *os, uint64_t object, uint64_t offset, in dmu_free_range() argument
1160 int err = dnode_hold(os, object, FTAG, &dn); in dmu_free_range()
1163 ASSERT(offset < UINT64_MAX); in dmu_free_range()
1164 ASSERT(size == DMU_OBJECT_END || size <= UINT64_MAX - offset); in dmu_free_range()
1165 dnode_free_range(dn, offset, size, tx); in dmu_free_range()
1171 dmu_read_impl(dnode_t *dn, uint64_t offset, uint64_t size, in dmu_read_impl() argument
1178 * Deal with odd block sizes, where there can't be data past the first in dmu_read_impl()
1182 if (dn->dn_maxblkid == 0) { in dmu_read_impl()
1183 uint64_t newsz = offset > dn->dn_datablksz ? 0 : in dmu_read_impl()
1184 MIN(size, dn->dn_datablksz - offset); in dmu_read_impl()
1185 memset((char *)buf + newsz, 0, size - newsz); in dmu_read_impl()
1194 zfs_dio_aligned(offset, size, PAGESIZE)) { in dmu_read_impl()
1195 abd_t *data = abd_get_from_buf(buf, size); in dmu_read_impl() local
1196 err = dmu_read_abd(dn, offset, size, data, flags); in dmu_read_impl()
1197 abd_free(data); in dmu_read_impl()
1206 * NB: we could do this block-at-a-time, but it's nice in dmu_read_impl()
1209 err = dmu_buf_hold_array_by_dnode(dn, offset, mylen, in dmu_read_impl()
1221 bufoff = offset - db->db_offset; in dmu_read_impl()
1222 tocpy = MIN(db->db_size - bufoff, size); in dmu_read_impl()
1224 ASSERT(db->db_data != NULL); in dmu_read_impl()
1225 (void) memcpy(buf, (char *)db->db_data + bufoff, tocpy); in dmu_read_impl()
1227 offset += tocpy; in dmu_read_impl()
1228 size -= tocpy; in dmu_read_impl()
1237 dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, in dmu_read() argument
1243 err = dnode_hold(os, object, FTAG, &dn); in dmu_read()
1247 err = dmu_read_impl(dn, offset, size, buf, flags); in dmu_read()
1253 dmu_read_by_dnode(dnode_t *dn, uint64_t offset, uint64_t size, void *buf, in dmu_read_by_dnode() argument
1256 return (dmu_read_impl(dn, offset, size, buf, flags)); in dmu_read_by_dnode()
1260 dmu_write_impl(dmu_buf_t **dbp, int numbufs, uint64_t offset, uint64_t size, in dmu_write_impl() argument
1272 bufoff = offset - db->db_offset; in dmu_write_impl()
1273 tocpy = MIN(db->db_size - bufoff, size); in dmu_write_impl()
1275 ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size); in dmu_write_impl()
1277 if (tocpy == db->db_size) in dmu_write_impl()
1282 ASSERT(db->db_data != NULL); in dmu_write_impl()
1283 (void) memcpy((char *)db->db_data + bufoff, buf, tocpy); in dmu_write_impl()
1285 if (tocpy == db->db_size) in dmu_write_impl()
1288 offset += tocpy; in dmu_write_impl()
1289 size -= tocpy; in dmu_write_impl()
1295 dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, in dmu_write() argument
1304 VERIFY0(dmu_buf_hold_array(os, object, offset, size, in dmu_write()
1306 dmu_write_impl(dbp, numbufs, offset, size, buf, tx); in dmu_write()
1315 dmu_write_by_dnode_flags(dnode_t *dn, uint64_t offset, uint64_t size, in dmu_write_by_dnode_flags() argument
1327 zfs_dio_aligned(offset, size, dn->dn_datablksz)) { in dmu_write_by_dnode_flags()
1328 abd_t *data = abd_get_from_buf((void *)buf, size); in dmu_write_by_dnode_flags() local
1329 error = dmu_write_abd(dn, offset, size, data, DMU_DIRECTIO, tx); in dmu_write_by_dnode_flags()
1330 abd_free(data); in dmu_write_by_dnode_flags()
1334 VERIFY0(dmu_buf_hold_array_by_dnode(dn, offset, size, in dmu_write_by_dnode_flags()
1336 dmu_write_impl(dbp, numbufs, offset, size, buf, tx); in dmu_write_by_dnode_flags()
1342 dmu_write_by_dnode(dnode_t *dn, uint64_t offset, uint64_t size, in dmu_write_by_dnode() argument
1345 return (dmu_write_by_dnode_flags(dn, offset, size, buf, tx, 0)); in dmu_write_by_dnode()
1349 dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, in dmu_prealloc() argument
1358 VERIFY(0 == dmu_buf_hold_array(os, object, offset, size, in dmu_prealloc()
1370 dmu_write_embedded(objset_t *os, uint64_t object, uint64_t offset, in dmu_write_embedded() argument
1371 void *data, uint8_t etype, uint8_t comp, int uncompressed_size, in dmu_write_embedded() argument
1378 VERIFY0(dmu_buf_hold_noread(os, object, offset, in dmu_write_embedded()
1382 data, (bp_embedded_type_t)etype, (enum zio_compress)comp, in dmu_write_embedded()
1389 dmu_redact(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, in dmu_redact() argument
1395 VERIFY0(dmu_buf_hold_array(os, object, offset, size, FALSE, FTAG, in dmu_redact()
1409 if (uio->uio_extflg & UIO_DIRECT) in dmu_read_uio_dnode()
1413 * NB: we could do this block-at-a-time, but it's nice in dmu_read_uio_dnode()
1428 bufoff = zfs_uio_offset(uio) - db->db_offset; in dmu_read_uio_dnode()
1429 tocpy = MIN(db->db_size - bufoff, size); in dmu_read_uio_dnode()
1431 ASSERT(db->db_data != NULL); in dmu_read_uio_dnode()
1432 err = zfs_uio_fault_move((char *)db->db_data + bufoff, tocpy, in dmu_read_uio_dnode()
1438 size -= tocpy; in dmu_read_uio_dnode()
1447 * From object zdb->db_object.
1473 * Starting at offset zfs_uio_offset(uio).
1476 dmu_read_uio(objset_t *os, uint64_t object, zfs_uio_t *uio, uint64_t size) in dmu_read_uio() argument
1484 err = dnode_hold(os, object, FTAG, &dn); in dmu_read_uio()
1510 if ((uio->uio_extflg & UIO_DIRECT) && in dmu_write_uio_dnode()
1511 (write_size >= dn->dn_datablksz)) { in dmu_write_uio_dnode()
1513 dn->dn_datablksz)) { in dmu_write_uio_dnode()
1515 } else if (write_size > dn->dn_datablksz && in dmu_write_uio_dnode()
1517 dn->dn_datablksz)) { in dmu_write_uio_dnode()
1519 dn->dn_datablksz * (write_size / dn->dn_datablksz); in dmu_write_uio_dnode()
1522 size -= write_size; in dmu_write_uio_dnode()
1529 P2PHASE(zfs_uio_offset(uio), dn->dn_datablksz); in dmu_write_uio_dnode()
1546 bufoff = off - db->db_offset; in dmu_write_uio_dnode()
1547 tocpy = MIN(db->db_size - bufoff, write_size); in dmu_write_uio_dnode()
1549 ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size); in dmu_write_uio_dnode()
1551 if (tocpy == db->db_size) in dmu_write_uio_dnode()
1556 ASSERT(db->db_data != NULL); in dmu_write_uio_dnode()
1557 err = zfs_uio_fault_move((char *)db->db_data + bufoff, in dmu_write_uio_dnode()
1560 if (tocpy == db->db_size && dmu_buf_fill_done(db, tx, err)) { in dmu_write_uio_dnode()
1562 zfs_uio_advance(uio, off - zfs_uio_offset(uio)); in dmu_write_uio_dnode()
1568 write_size -= tocpy; in dmu_write_uio_dnode()
1569 size -= tocpy; in dmu_write_uio_dnode()
1576 if ((uio->uio_extflg & UIO_DIRECT) && size > 0) { in dmu_write_uio_dnode()
1585 * To object zdb->db_object.
1586 * Starting at offset zfs_uio_offset(uio).
1612 * Starting at offset zfs_uio_offset(uio).
1615 dmu_write_uio(objset_t *os, uint64_t object, zfs_uio_t *uio, uint64_t size, in dmu_write_uio() argument
1624 err = dnode_hold(os, object, FTAG, &dn); in dmu_write_uio()
1667 dmu_object_cached_size(objset_t *os, uint64_t object, in dmu_object_cached_size() argument
1676 if (dnode_hold(os, object, FTAG, &dn) != 0) in dmu_object_cached_size()
1679 if (dn->dn_nlevels < 2) { in dmu_object_cached_size()
1697 uint_t nbps = bp_span_in_blocks(dn->dn_indblkshift, 1); in dmu_object_cached_size()
1698 uint64_t l1blks = 1 + (dn->dn_maxblkid / nbps); in dmu_object_cached_size()
1700 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_object_cached_size()
1729 dmu_cached_bps(dmu_objset_spa(os), db->db.db_data, in dmu_object_cached_size()
1738 rw_exit(&dn->dn_struct_rwlock); in dmu_object_cached_size()
1752 return (arc_loan_buf(db->db_objset->os_spa, B_FALSE, size)); in dmu_request_arcbuf()
1769 * data can not be read or overwritten until the transaction's txg has been
1771 * (temporarily) write-only, like "zfs receive".
1773 * A single block is written, starting at the specified offset in bytes. If
1778 dmu_lightweight_write_by_dnode(dnode_t *dn, uint64_t offset, abd_t *abd, in dmu_lightweight_write_by_dnode() argument
1782 dbuf_dirty_lightweight(dn, dbuf_whichblock(dn, 0, offset), tx); in dmu_lightweight_write_by_dnode()
1785 dr->dt.dll.dr_abd = abd; in dmu_lightweight_write_by_dnode()
1786 dr->dt.dll.dr_props = *zp; in dmu_lightweight_write_by_dnode()
1787 dr->dt.dll.dr_flags = flags; in dmu_lightweight_write_by_dnode()
1797 dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, arc_buf_t *buf, in dmu_assign_arcbuf_by_dnode() argument
1801 objset_t *os = dn->dn_objset; in dmu_assign_arcbuf_by_dnode() local
1802 uint64_t object = dn->dn_object; in dmu_assign_arcbuf_by_dnode()
1806 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_assign_arcbuf_by_dnode()
1807 blkid = dbuf_whichblock(dn, 0, offset); in dmu_assign_arcbuf_by_dnode()
1809 rw_exit(&dn->dn_struct_rwlock); in dmu_assign_arcbuf_by_dnode()
1814 * We can only assign if the offset is aligned and the arc buf is the in dmu_assign_arcbuf_by_dnode()
1817 if (offset == db->db.db_offset && blksz == db->db.db_size) { in dmu_assign_arcbuf_by_dnode()
1818 zfs_racct_write(os->os_spa, blksz, 1, 0); in dmu_assign_arcbuf_by_dnode()
1824 ASSERT(!(buf->b_flags & ARC_BUF_FLAG_COMPRESSED)); in dmu_assign_arcbuf_by_dnode()
1827 dmu_write(os, object, offset, blksz, buf->b_data, tx); in dmu_assign_arcbuf_by_dnode()
1835 dmu_assign_arcbuf_by_dbuf(dmu_buf_t *handle, uint64_t offset, arc_buf_t *buf, in dmu_assign_arcbuf_by_dbuf() argument
1842 err = dmu_assign_arcbuf_by_dnode(DB_DNODE(db), offset, buf, tx); in dmu_assign_arcbuf_by_dbuf()
1854 if (zio->io_error == 0) { in dmu_sync_ready()
1855 dbuf_dirty_record_t *dr = dsa->dsa_dr; in dmu_sync_ready()
1856 blkptr_t *bp = zio->io_bp; in dmu_sync_ready()
1861 db = &(dr->dr_dbuf->db); in dmu_sync_ready()
1863 db = dsa->dsa_zgd->zgd_db; in dmu_sync_ready()
1868 BP_SET_LSIZE(bp, db->db_size); in dmu_sync_ready()
1879 dmu_sync_ready(zio, NULL, zio->io_private); in dmu_sync_late_arrival_ready()
1887 dbuf_dirty_record_t *dr = dsa->dsa_dr; in dmu_sync_done()
1888 dmu_buf_impl_t *db = dr->dr_dbuf; in dmu_sync_done()
1889 zgd_t *zgd = dsa->dsa_zgd; in dmu_sync_done()
1895 if (zgd && zio->io_error == 0) { in dmu_sync_done()
1896 zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp); in dmu_sync_done()
1899 mutex_enter(&db->db_mtx); in dmu_sync_done()
1900 ASSERT(dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC); in dmu_sync_done()
1901 if (zio->io_error == 0) { in dmu_sync_done()
1902 ASSERT0(dr->dt.dl.dr_has_raw_params); in dmu_sync_done()
1903 dr->dt.dl.dr_nopwrite = !!(zio->io_flags & ZIO_FLAG_NOPWRITE); in dmu_sync_done()
1904 if (dr->dt.dl.dr_nopwrite) { in dmu_sync_done()
1905 blkptr_t *bp = zio->io_bp; in dmu_sync_done()
1906 blkptr_t *bp_orig = &zio->io_bp_orig; in dmu_sync_done()
1910 VERIFY(BP_EQUAL(bp, db->db_blkptr)); in dmu_sync_done()
1911 ASSERT(zio->io_prop.zp_compress != ZIO_COMPRESS_OFF); in dmu_sync_done()
1915 dr->dt.dl.dr_overridden_by = *zio->io_bp; in dmu_sync_done()
1916 dr->dt.dl.dr_override_state = DR_OVERRIDDEN; in dmu_sync_done()
1917 dr->dt.dl.dr_copies = zio->io_prop.zp_copies; in dmu_sync_done()
1921 * new-style holes maintain their lsize, type, level, in dmu_sync_done()
1929 if (BP_IS_HOLE(&dr->dt.dl.dr_overridden_by) && in dmu_sync_done()
1930 BP_GET_LOGICAL_BIRTH(&dr->dt.dl.dr_overridden_by) == 0) in dmu_sync_done()
1931 BP_ZERO(&dr->dt.dl.dr_overridden_by); in dmu_sync_done()
1933 dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN; in dmu_sync_done()
1936 cv_broadcast(&db->db_changed); in dmu_sync_done()
1937 mutex_exit(&db->db_mtx); in dmu_sync_done()
1939 if (dsa->dsa_done) in dmu_sync_done()
1940 dsa->dsa_done(dsa->dsa_zgd, zio->io_error); in dmu_sync_done()
1948 blkptr_t *bp = zio->io_bp; in dmu_sync_late_arrival_done()
1949 dmu_sync_arg_t *dsa = zio->io_private; in dmu_sync_late_arrival_done()
1950 zgd_t *zgd = dsa->dsa_zgd; in dmu_sync_late_arrival_done()
1952 if (zio->io_error == 0) { in dmu_sync_late_arrival_done()
1957 zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp); in dmu_sync_late_arrival_done()
1960 blkptr_t *bp_orig __maybe_unused = &zio->io_bp_orig; in dmu_sync_late_arrival_done()
1961 ASSERT(!(zio->io_flags & ZIO_FLAG_NOPWRITE)); in dmu_sync_late_arrival_done()
1963 ASSERT(BP_GET_LOGICAL_BIRTH(zio->io_bp) == zio->io_txg); in dmu_sync_late_arrival_done()
1964 ASSERT(zio->io_txg > spa_syncing_txg(zio->io_spa)); in dmu_sync_late_arrival_done()
1965 zio_free(zio->io_spa, zio->io_txg, zio->io_bp); in dmu_sync_late_arrival_done()
1969 dmu_tx_commit(dsa->dsa_tx); in dmu_sync_late_arrival_done()
1971 dsa->dsa_done(dsa->dsa_zgd, zio->io_error); in dmu_sync_late_arrival_done()
1973 abd_free(zio->io_abd); in dmu_sync_late_arrival_done()
1978 dmu_sync_late_arrival(zio_t *pio, objset_t *os, dmu_sync_cb_t *done, zgd_t *zgd, in dmu_sync_late_arrival() argument
1985 error = dbuf_read((dmu_buf_impl_t *)zgd->zgd_db, NULL, in dmu_sync_late_arrival()
1990 tx = dmu_tx_create(os); in dmu_sync_late_arrival()
1991 dmu_tx_hold_space(tx, zgd->zgd_db->db_size); in dmu_sync_late_arrival()
1993 * This transaction does not produce any dirty data or log blocks, so in dmu_sync_late_arrival()
2009 zil_lwb_add_txg(zgd->zgd_lwb, dmu_tx_get_txg(tx)); in dmu_sync_late_arrival()
2012 dsa->dsa_dr = NULL; in dmu_sync_late_arrival()
2013 dsa->dsa_done = done; in dmu_sync_late_arrival()
2014 dsa->dsa_zgd = zgd; in dmu_sync_late_arrival()
2015 dsa->dsa_tx = tx; in dmu_sync_late_arrival()
2023 * (this is similar to the non-late-arrival case where the dbuf is in dmu_sync_late_arrival()
2028 * (typically) be changed, the data has not yet been persisted to this in dmu_sync_late_arrival()
2032 * possible to always nopwrite, because the data that was written in in dmu_sync_late_arrival()
2033 * this txg is the same data that we are trying to write. However we in dmu_sync_late_arrival()
2038 zp->zp_nopwrite = B_FALSE; in dmu_sync_late_arrival()
2040 zio_nowait(zio_write(pio, os->os_spa, dmu_tx_get_txg(tx), zgd->zgd_bp, in dmu_sync_late_arrival()
2041 abd_get_from_buf(zgd->zgd_db->db_data, zgd->zgd_db->db_size), in dmu_sync_late_arrival()
2042 zgd->zgd_db->db_size, zgd->zgd_db->db_size, zp, in dmu_sync_late_arrival()
2052 * data isn't changing while dmu_sync() is writing it.
2077 dmu_buf_impl_t *db = (dmu_buf_impl_t *)zgd->zgd_db; in dmu_sync()
2078 objset_t *os = db->db_objset; in dmu_sync() local
2079 dsl_dataset_t *ds = os->os_dsl_dataset; in dmu_sync()
2088 SET_BOOKMARK(&zb, ds->ds_object, in dmu_sync()
2089 db->db.db_object, db->db_level, db->db_blkid); in dmu_sync()
2092 dmu_write_policy(os, DB_DNODE(db), db->db_level, WP_DMU_SYNC, &zp); in dmu_sync()
2098 if (txg > spa_freeze_txg(os->os_spa)) in dmu_sync()
2099 return (dmu_sync_late_arrival(pio, os, done, zgd, &zp, &zb)); in dmu_sync()
2107 mutex_enter(&db->db_mtx); in dmu_sync()
2109 if (txg <= spa_last_synced_txg(os->os_spa)) { in dmu_sync()
2113 mutex_exit(&db->db_mtx); in dmu_sync()
2117 if (txg <= spa_syncing_txg(os->os_spa)) { in dmu_sync()
2122 mutex_exit(&db->db_mtx); in dmu_sync()
2123 return (dmu_sync_late_arrival(pio, os, done, zgd, &zp, &zb)); in dmu_sync()
2133 mutex_exit(&db->db_mtx); in dmu_sync()
2137 dr_next = list_next(&db->db_dirty_records, dr); in dmu_sync()
2138 ASSERT(dr_next == NULL || dr_next->dr_txg < txg); in dmu_sync()
2140 if (db->db_blkptr != NULL) { in dmu_sync()
2144 * data that's already on disk. We can only nopwrite if we in dmu_sync()
2152 *zgd->zgd_bp = *db->db_blkptr; in dmu_sync()
2156 * Assume the on-disk data is X, the current syncing data (in in dmu_sync()
2157 * txg - 1) is Y, and the current in-memory data is Z (currently in dmu_sync()
2163 * be incorrect - we would override with X, which could have in dmu_sync()
2166 * (Note that this is not a concern when we are nop-writing from in dmu_sync()
2172 * being dirty (dr_next is non-NULL), or by being freed in dmu_sync()
2175 * to the on-disk BP. in dmu_sync()
2181 if (dnode_block_freed(DB_DNODE(db), db->db_blkid)) in dmu_sync()
2186 ASSERT(dr->dr_txg == txg); in dmu_sync()
2187 if (dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC || in dmu_sync()
2188 dr->dt.dl.dr_override_state == DR_OVERRIDDEN) { in dmu_sync()
2194 mutex_exit(&db->db_mtx); in dmu_sync()
2198 ASSERT0(dr->dt.dl.dr_has_raw_params); in dmu_sync()
2199 ASSERT(dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN); in dmu_sync()
2200 dr->dt.dl.dr_override_state = DR_IN_DMU_SYNC; in dmu_sync()
2201 mutex_exit(&db->db_mtx); in dmu_sync()
2204 dsa->dsa_dr = dr; in dmu_sync()
2205 dsa->dsa_done = done; in dmu_sync()
2206 dsa->dsa_zgd = zgd; in dmu_sync()
2207 dsa->dsa_tx = NULL; in dmu_sync()
2209 zio_nowait(arc_write(pio, os->os_spa, txg, zgd->zgd_bp, in dmu_sync()
2210 dr->dt.dl.dr_data, !DBUF_IS_CACHEABLE(db), in dmu_sync()
2219 dmu_object_set_nlevels(objset_t *os, uint64_t object, int nlevels, dmu_tx_t *tx) in dmu_object_set_nlevels() argument
2224 err = dnode_hold(os, object, FTAG, &dn); in dmu_object_set_nlevels()
2233 dmu_object_set_blocksize(objset_t *os, uint64_t object, uint64_t size, int ibs, in dmu_object_set_blocksize() argument
2239 err = dnode_hold(os, object, FTAG, &dn); in dmu_object_set_blocksize()
2248 dmu_object_set_maxblkid(objset_t *os, uint64_t object, uint64_t maxblkid, in dmu_object_set_maxblkid() argument
2254 err = dnode_hold(os, object, FTAG, &dn); in dmu_object_set_maxblkid()
2257 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); in dmu_object_set_maxblkid()
2259 rw_exit(&dn->dn_struct_rwlock); in dmu_object_set_maxblkid()
2265 dmu_object_set_checksum(objset_t *os, uint64_t object, uint8_t checksum, in dmu_object_set_checksum() argument
2277 VERIFY0(dnode_hold(os, object, FTAG, &dn)); in dmu_object_set_checksum()
2279 dn->dn_checksum = checksum; in dmu_object_set_checksum()
2285 dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, in dmu_object_set_compress() argument
2297 VERIFY0(dnode_hold(os, object, FTAG, &dn)); in dmu_object_set_compress()
2298 dn->dn_compress = compress; in dmu_object_set_compress()
2310 dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp) in dmu_write_policy() argument
2312 dmu_object_type_t type = dn ? dn->dn_type : DMU_OT_OBJSET; in dmu_write_policy()
2315 enum zio_checksum checksum = os->os_checksum; in dmu_write_policy()
2316 enum zio_compress compress = os->os_compress; in dmu_write_policy()
2317 uint8_t complevel = os->os_complevel; in dmu_write_policy()
2318 enum zio_checksum dedup_checksum = os->os_dedup_checksum; in dmu_write_policy()
2321 boolean_t dedup_verify = os->os_dedup_verify; in dmu_write_policy()
2323 int copies = os->os_copies; in dmu_write_policy()
2327 * types of data: in dmu_write_policy()
2329 * 2. preallocated blocks (i.e. level-0 blocks of a dump device) in dmu_write_policy()
2334 * XXX -- we should design a compression algorithm in dmu_write_policy()
2337 compress = zio_compress_select(os->os_spa, in dmu_write_policy()
2341 * Metadata always gets checksummed. If the data in dmu_write_policy()
2342 * checksum is multi-bit correctable, and it's not a in dmu_write_policy()
2343 * ZBT-style checksum, then it's suitable for metadata in dmu_write_policy()
2353 switch (os->os_redundant_metadata) { in dmu_write_policy()
2381 dn ? dn->dn_storage_type : DMU_OT_NONE; in dmu_write_policy()
2404 compress = zio_compress_select(os->os_spa, dn->dn_compress, in dmu_write_policy()
2406 complevel = zio_complevel_select(os->os_spa, compress, in dmu_write_policy()
2410 zio_checksum_select(dn->dn_checksum, checksum) : in dmu_write_policy()
2444 * not subject to nopwrite since writing the same data will still in dmu_write_policy()
2449 if (os->os_encrypted && (wp & WP_NOFILL) == 0) { in dmu_write_policy()
2453 copies = MIN(copies, SPA_DVAS_PER_BP - 1); in dmu_write_policy()
2465 zp->zp_compress = compress; in dmu_write_policy()
2466 zp->zp_complevel = complevel; in dmu_write_policy()
2467 zp->zp_checksum = checksum; in dmu_write_policy()
2468 zp->zp_type = (wp & WP_SPILL) ? dn->dn_bonustype : type; in dmu_write_policy()
2469 zp->zp_level = level; in dmu_write_policy()
2470 zp->zp_copies = MIN(copies, spa_max_replication(os->os_spa)); in dmu_write_policy()
2471 zp->zp_dedup = dedup; in dmu_write_policy()
2472 zp->zp_dedup_verify = dedup && dedup_verify; in dmu_write_policy()
2473 zp->zp_nopwrite = nopwrite; in dmu_write_policy()
2474 zp->zp_encrypt = encrypt; in dmu_write_policy()
2475 zp->zp_byteorder = ZFS_HOST_BYTEORDER; in dmu_write_policy()
2476 zp->zp_direct_write = (wp & WP_DIRECT_WR) ? B_TRUE : B_FALSE; in dmu_write_policy()
2477 memset(zp->zp_salt, 0, ZIO_DATA_SALT_LEN); in dmu_write_policy()
2478 memset(zp->zp_iv, 0, ZIO_DATA_IV_LEN); in dmu_write_policy()
2479 memset(zp->zp_mac, 0, ZIO_DATA_MAC_LEN); in dmu_write_policy()
2480 zp->zp_zpl_smallblk = DMU_OT_IS_FILE(zp->zp_type) ? in dmu_write_policy()
2481 os->os_zpl_special_smallblock : 0; in dmu_write_policy()
2482 zp->zp_storage_type = dn ? dn->dn_storage_type : DMU_OT_NONE; in dmu_write_policy()
2484 ASSERT3U(zp->zp_compress, !=, ZIO_COMPRESS_INHERIT); in dmu_write_policy()
2488 * Reports the location of data and holes in an object. In order to
2489 * accurately report holes all dirty data must be synced to disk. This
2491 * As a compromise, only provide hole data when the dnode is clean. When
2496 dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off) in dmu_offset_next() argument
2502 err = dnode_hold(os, object, FTAG, &dn); in dmu_offset_next()
2506 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_offset_next()
2514 * Provided a RL_READER rangelock spanning 0-UINT64_MAX is in dmu_offset_next()
2520 rw_exit(&dn->dn_struct_rwlock); in dmu_offset_next()
2526 txg_wait_synced(dmu_objset_pool(os), 0); in dmu_offset_next()
2537 rw_exit(&dn->dn_struct_rwlock); in dmu_offset_next()
2544 dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset, uint64_t length, in dmu_read_l0_bps() argument
2552 error = dmu_buf_hold_array(os, object, offset, length, FALSE, FTAG, in dmu_read_l0_bps()
2567 mutex_enter(&db->db_mtx); in dmu_read_l0_bps()
2569 if (!list_is_empty(&db->db_dirty_records)) { in dmu_read_l0_bps()
2572 dr = list_head(&db->db_dirty_records); in dmu_read_l0_bps()
2573 if (dr->dt.dl.dr_brtwrite) { in dmu_read_l0_bps()
2579 bp = &dr->dt.dl.dr_overridden_by; in dmu_read_l0_bps()
2585 mutex_exit(&db->db_mtx); in dmu_read_l0_bps()
2590 bp = db->db_blkptr; in dmu_read_l0_bps()
2593 mutex_exit(&db->db_mtx); in dmu_read_l0_bps()
2606 * Make sure we clone only data blocks. in dmu_read_l0_bps()
2619 if (BP_GET_BIRTH(bp) > spa_freeze_txg(os->os_spa)) { in dmu_read_l0_bps()
2623 if (BP_GET_BIRTH(bp) > spa_last_synced_txg(os->os_spa)) { in dmu_read_l0_bps()
2639 dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset, uint64_t length, in dmu_brt_clone() argument
2650 spa = os->os_spa; in dmu_brt_clone()
2652 VERIFY0(dmu_buf_hold_array(os, object, offset, length, FALSE, FTAG, in dmu_brt_clone()
2658 * sizes. If they don't, that's a no-go, as we are not able to shrink in dmu_brt_clone()
2666 ASSERT3U(db->db.db_object, !=, DMU_META_DNODE_OBJECT); in dmu_brt_clone()
2667 ASSERT0(db->db_level); in dmu_brt_clone()
2668 ASSERT(db->db_blkid != DMU_BONUS_BLKID); in dmu_brt_clone()
2669 ASSERT(db->db_blkid != DMU_SPILL_BLKID); in dmu_brt_clone()
2671 if (!BP_IS_HOLE(bp) && BP_GET_LSIZE(bp) != dbuf->db_size) { in dmu_brt_clone()
2684 mutex_enter(&db->db_mtx); in dmu_brt_clone()
2686 dr = list_head(&db->db_dirty_records); in dmu_brt_clone()
2688 ASSERT3U(dr->dr_txg, ==, tx->tx_txg); in dmu_brt_clone()
2689 dl = &dr->dt.dl; in dmu_brt_clone()
2690 ASSERT0(dl->dr_has_raw_params); in dmu_brt_clone()
2691 dl->dr_overridden_by = *bp; in dmu_brt_clone()
2694 BP_SET_BIRTH(&dl->dr_overridden_by, dr->dr_txg, in dmu_brt_clone()
2697 BP_SET_LOGICAL_BIRTH(&dl->dr_overridden_by, in dmu_brt_clone()
2698 dr->dr_txg); in dmu_brt_clone()
2701 dl->dr_brtwrite = B_TRUE; in dmu_brt_clone()
2702 dl->dr_override_state = DR_OVERRIDDEN; in dmu_brt_clone()
2704 mutex_exit(&db->db_mtx); in dmu_brt_clone()
2707 * When data in embedded into BP there is no need to create in dmu_brt_clone()
2708 * BRT entry as there is no data block. Just copy the BP as in dmu_brt_clone()
2709 * it contains the data. in dmu_brt_clone()
2724 dnode_phys_t *dnp = dn->dn_phys; in __dmu_object_info_from_dnode()
2726 doi->doi_data_block_size = dn->dn_datablksz; in __dmu_object_info_from_dnode()
2727 doi->doi_metadata_block_size = dn->dn_indblkshift ? in __dmu_object_info_from_dnode()
2728 1ULL << dn->dn_indblkshift : 0; in __dmu_object_info_from_dnode()
2729 doi->doi_type = dn->dn_type; in __dmu_object_info_from_dnode()
2730 doi->doi_bonus_type = dn->dn_bonustype; in __dmu_object_info_from_dnode()
2731 doi->doi_bonus_size = dn->dn_bonuslen; in __dmu_object_info_from_dnode()
2732 doi->doi_dnodesize = dn->dn_num_slots << DNODE_SHIFT; in __dmu_object_info_from_dnode()
2733 doi->doi_indirection = dn->dn_nlevels; in __dmu_object_info_from_dnode()
2734 doi->doi_checksum = dn->dn_checksum; in __dmu_object_info_from_dnode()
2735 doi->doi_compress = dn->dn_compress; in __dmu_object_info_from_dnode()
2736 doi->doi_nblkptr = dn->dn_nblkptr; in __dmu_object_info_from_dnode()
2737 doi->doi_physical_blocks_512 = (DN_USED_BYTES(dnp) + 256) >> 9; in __dmu_object_info_from_dnode()
2738 doi->doi_max_offset = (dn->dn_maxblkid + 1) * dn->dn_datablksz; in __dmu_object_info_from_dnode()
2739 doi->doi_fill_count = 0; in __dmu_object_info_from_dnode()
2740 for (int i = 0; i < dnp->dn_nblkptr; i++) in __dmu_object_info_from_dnode()
2741 doi->doi_fill_count += BP_GET_FILL(&dnp->dn_blkptr[i]); in __dmu_object_info_from_dnode()
2747 rw_enter(&dn->dn_struct_rwlock, RW_READER); in dmu_object_info_from_dnode()
2748 mutex_enter(&dn->dn_mtx); in dmu_object_info_from_dnode()
2752 mutex_exit(&dn->dn_mtx); in dmu_object_info_from_dnode()
2753 rw_exit(&dn->dn_struct_rwlock); in dmu_object_info_from_dnode()
2761 dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi) in dmu_object_info() argument
2764 int err = dnode_hold(os, object, FTAG, &dn); in dmu_object_info()
2802 *blksize = dn->dn_datablksz; in dmu_object_size_from_db()
2804 *nblk512 = ((DN_USED_BYTES(dn->dn_phys) + SPA_MINBLOCKSIZE/2) >> in dmu_object_size_from_db()
2805 SPA_MINBLOCKSHIFT) + dn->dn_num_slots; in dmu_object_size_from_db()
2815 *dnsize = DB_DNODE(db)->dn_num_slots << DNODE_SHIFT; in dmu_object_dnsize_from_db()