Lines Matching defs:dn
43 typedef void (*dmu_tx_hold_func_t)(dmu_tx_t *tx, struct dnode *dn,
105 dnode_t *dn = NULL;
109 err = dnode_hold(os, object, tx, &dn);
116 mutex_enter(&dn->dn_mtx);
118 * dn->dn_assigned_txg == tx->tx_txg doesn't pose a
122 ASSERT(dn->dn_assigned_txg == 0);
123 dn->dn_assigned_txg = tx->tx_txg;
124 (void) refcount_add(&dn->dn_tx_holds, tx);
125 mutex_exit(&dn->dn_mtx);
131 txh->txh_dnode = dn;
162 dmu_tx_check_ioerr(zio_t *zio, dnode_t *dn, int level, uint64_t blkid)
167 rw_enter(&dn->dn_struct_rwlock, RW_READER);
168 db = dbuf_hold_level(dn, level, blkid, FTAG);
169 rw_exit(&dn->dn_struct_rwlock);
178 dmu_tx_count_twig(dmu_tx_hold_t *txh, dnode_t *dn, dmu_buf_impl_t *db,
181 objset_t *os = dn->dn_objset;
183 int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
188 if (level >= dn->dn_nlevels || history[level] == blkid)
193 space = (level == 0) ? dn->dn_datablksz : (1ULL << dn->dn_indblkshift);
195 if (db == NULL || db == dn->dn_dbuf) {
199 ASSERT(DB_DNODE(db) == dn);
223 dmu_tx_count_twig(txh, dn, parent, level + 1,
231 dnode_t *dn = txh->txh_dnode;
244 if (dn) {
246 int nlvls = dn->dn_nlevels;
253 if (dn->dn_maxblkid == 0) {
254 delta = dn->dn_datablksz;
255 start = (off < dn->dn_datablksz) ? 0 : 1;
256 end = (off+len <= dn->dn_datablksz) ? 0 : 1;
257 if (start == 0 && (off > 0 || len < dn->dn_datablksz)) {
258 err = dmu_tx_check_ioerr(NULL, dn, 0, 0);
264 zio_t *zio = zio_root(dn->dn_objset->os_spa,
268 start = off >> dn->dn_datablkshift;
269 if (P2PHASE(off, dn->dn_datablksz) ||
270 len < dn->dn_datablksz) {
271 err = dmu_tx_check_ioerr(zio, dn, 0, start);
277 end = (off+len-1) >> dn->dn_datablkshift;
278 if (end != start && end <= dn->dn_maxblkid &&
279 P2PHASE(off+len, dn->dn_datablksz)) {
280 err = dmu_tx_check_ioerr(zio, dn, 0, end);
287 int shft = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
289 err = dmu_tx_check_ioerr(zio, dn, 1, i);
298 delta = P2NPHASE(off, dn->dn_datablksz);
301 min_ibs = max_ibs = dn->dn_indblkshift;
302 if (dn->dn_maxblkid > 0) {
307 ASSERT(dn->dn_datablkshift != 0);
308 min_bs = max_bs = dn->dn_datablkshift;
315 min_bs = highbit64(dn->dn_datablksz - 1);
316 max_bs = MAX(max_bs, highbit64(dn->dn_datablksz - 1));
323 if (start <= dn->dn_maxblkid) {
327 while (start <= dn->dn_maxblkid) {
330 rw_enter(&dn->dn_struct_rwlock, RW_READER);
331 err = dbuf_hold_impl(dn, 0, start,
333 rw_exit(&dn->dn_struct_rwlock);
340 dmu_tx_count_twig(txh, dn, db, 0, start, B_FALSE,
361 delta = dn->dn_datablksz;
412 dnode_t *dn = txh->txh_dnode;
417 if (dn && dn->dn_dbuf->db_blkptr &&
418 dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
419 dn->dn_dbuf->db_blkptr, dn->dn_dbuf->db_blkptr->blk_birth)) {
425 if (dn && dn->dn_dbuf->db_blkptr) {
455 dnode_t *dn = txh->txh_dnode;
456 dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset;
461 if (dn->dn_nlevels == 0)
470 rw_enter(&dn->dn_struct_rwlock, RW_READER);
471 epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
472 if (dn->dn_maxblkid == 0) {
473 if (off == 0 && len >= dn->dn_datablksz) {
477 rw_exit(&dn->dn_struct_rwlock);
481 blkid = off >> dn->dn_datablkshift;
482 nblks = (len + dn->dn_datablksz - 1) >> dn->dn_datablkshift;
484 if (blkid > dn->dn_maxblkid) {
485 rw_exit(&dn->dn_struct_rwlock);
488 if (blkid + nblks > dn->dn_maxblkid)
489 nblks = dn->dn_maxblkid - blkid + 1;
493 if (dn->dn_nlevels == 1) {
496 blkptr_t *bp = dn->dn_phys->dn_blkptr;
497 ASSERT3U(blkid + i, <, dn->dn_nblkptr);
517 ibyte = blkid << dn->dn_datablkshift;
518 err = dnode_next_offset(dn,
520 new_blkid = ibyte >> dn->dn_datablkshift;
543 err = dbuf_hold_impl(dn, 1, blkid >> epbs,
585 rw_exit(&dn->dn_struct_rwlock);
600 int maxlevel = 2 + (DN_MAX_OFFSET_SHIFT - dn->dn_datablkshift) /
601 (dn->dn_indblkshift - SPA_BLKPTRSHIFT);
605 MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift,
614 skipped << dn->dn_indblkshift, FTAG);
617 skipped << dn->dn_indblkshift, FTAG);
656 dnode_t *dn;
666 dn = txh->txh_dnode;
669 if (off >= (dn->dn_maxblkid+1) * dn->dn_datablksz)
672 len = (dn->dn_maxblkid+1) * dn->dn_datablksz - off;
683 if (dn->dn_datablkshift == 0) {
684 if (off != 0 || len < dn->dn_datablksz)
685 dmu_tx_count_write(txh, 0, dn->dn_datablksz);
688 if (!IS_P2ALIGNED(off, 1 << dn->dn_datablkshift))
691 if (!IS_P2ALIGNED(off + len, 1 << dn->dn_datablkshift))
698 if (dn->dn_nlevels > 1) {
699 int shift = dn->dn_datablkshift + dn->dn_indblkshift -
704 ASSERT(dn->dn_indblkshift != 0);
711 if (dn->dn_datablkshift == 0)
718 err = dnode_next_offset(dn, 0, &ibyte, 2, 1, 0);
727 err = dmu_tx_check_ioerr(zio, dn, 1, i);
747 dnode_t *dn;
756 dn = txh->txh_dnode;
760 if (dn == NULL) {
770 ASSERT3P(DMU_OT_BYTESWAP(dn->dn_type), ==, DMU_BSWAP_ZAP);
772 if (dn->dn_maxblkid == 0 && !add) {
779 err = dmu_tx_check_ioerr(NULL, dn, 0, 0);
789 bp = &dn->dn_phys->dn_blkptr[0];
790 if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
805 if (dn->dn_maxblkid > 0 && name) {
810 err = zap_lookup_by_dnode(dn, name, 8, 0, NULL);
817 err = zap_count_write_by_dnode(dn, name, add,
831 int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
833 dsl_dataset_phys(dn->dn_objset->os_dsl_dataset);
834 for (int lvl = 1; lvl < dn->dn_nlevels; lvl++) {
835 uint64_t num_indirects = 1 + (dn->dn_maxblkid >> (epbs * lvl));
836 uint64_t spc = MIN(3, num_indirects) << dn->dn_indblkshift;
904 dnode_t *dn;
907 dn = DB_DNODE(db);
909 ASSERT(tx->tx_objset == NULL || dn->dn_objset == tx->tx_objset);
910 ASSERT3U(dn->dn_object, ==, db->db.db_object);
925 ASSERT(dn == NULL || dn->dn_assigned_txg == tx->tx_txg);
926 if (txh->txh_dnode == dn && txh->txh_type != THT_NEWOBJECT)
928 if (txh->txh_dnode == NULL || txh->txh_dnode == dn) {
929 int datablkshift = dn->dn_datablkshift ?
930 dn->dn_datablkshift : SPA_MAXBLOCKSHIFT;
931 int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
1203 dnode_t *dn = txh->txh_dnode;
1204 if (dn != NULL) {
1205 mutex_enter(&dn->dn_mtx);
1206 if (dn->dn_assigned_txg == tx->tx_txg - 1) {
1207 mutex_exit(&dn->dn_mtx);
1211 if (dn->dn_assigned_txg == 0)
1212 dn->dn_assigned_txg = tx->tx_txg;
1213 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
1214 (void) refcount_add(&dn->dn_tx_holds, tx);
1215 mutex_exit(&dn->dn_mtx);
1284 dnode_t *dn = txh->txh_dnode;
1286 if (dn == NULL)
1288 mutex_enter(&dn->dn_mtx);
1289 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
1291 if (refcount_remove(&dn->dn_tx_holds, tx) == 0) {
1292 dn->dn_assigned_txg = 0;
1293 cv_broadcast(&dn->dn_notxholds);
1295 mutex_exit(&dn->dn_mtx);
1396 dnode_t *dn = tx->tx_needassign_txh->txh_dnode;
1398 mutex_enter(&dn->dn_mtx);
1399 while (dn->dn_assigned_txg == tx->tx_lasttried_txg - 1)
1400 cv_wait(&dn->dn_notxholds, &dn->dn_mtx);
1401 mutex_exit(&dn->dn_mtx);
1431 dnode_t *dn = txh->txh_dnode;
1447 if (dn != NULL)
1448 dnode_rele(dn, tx);
1473 dnode_t *dn = txh->txh_dnode;
1475 if (dn == NULL)
1478 mutex_enter(&dn->dn_mtx);
1479 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
1481 if (refcount_remove(&dn->dn_tx_holds, tx) == 0) {
1482 dn->dn_assigned_txg = 0;
1483 cv_broadcast(&dn->dn_notxholds);
1485 mutex_exit(&dn->dn_mtx);
1600 dnode_t *dn;
1606 dn = txh->txh_dnode;
1608 if (dn == NULL)
1612 if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) {
1618 bp = &dn->dn_phys->dn_spill;
1619 if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
1704 dnode_t *dn;
1707 dn = DB_DNODE(db);
1708 if (dn->dn_have_spill) {