fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
06e0070d70ba2ee95f5aa2645423eb2cf1546788Mark Shellenbaum * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
e77d42eaa49fe55bfae1e0e0065c6e99affc001bMatthew Ahrens * Copyright 2014 HybridCluster. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_alloc(objset_t *os, dmu_object_type_t ot, int blocksize,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson (DMU_META_DNODE(os)->dn_indblkshift - SPA_BLKPTRSHIFT);
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * Each time we polish off a L1 bp worth of dnodes (2^12
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * objects), move to another L1 bp that's still reasonably
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * sparse (at most 1/4 full). Look from the beginning at most
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * once per txg, but after that keep looking from here.
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * os_scan_dnodes is set during txg sync if enough objects
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * have been freed since the previous rescan to justify
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * backfilling again. If we can't find a suitable block, just
af346df58864e8fe897b1ff1a3a4c12f9294391bNed Bass * keep going from here.
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * Note that dmu_traverse depends on the behavior that we use
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * multiple blocks of the dnode object before going back to
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * reuse objects. Any change to this algorithm should preserve
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * that property or find another solution to the issues
286ef71398fb54b1d5007d6f45aa4320a9e0ede2Paul Dagnelie * described in traverse_visitbp.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * XXX We should check for an i/o error here and return
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * up to our caller. Actually we should pre-read it in
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * dmu_tx_assign(), but there is currently no mechanism
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * to do so.
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens (void) dnode_hold_impl(os, object, DNODE_MUST_BE_FREE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dnode_allocate(dn, ot, blocksize, 0, bonustype, bonuslen, tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_claim(objset_t *os, uint64_t object, dmu_object_type_t ot,
fa9e4066f08beec538e775443c5be79dd423fcabahrens int blocksize, dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock if (object == DMU_META_DNODE_OBJECT && !dmu_tx_private_ok(tx))
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens err = dnode_hold_impl(os, object, DNODE_MUST_BE_FREE, FTAG, &dn);
fa9e4066f08beec538e775443c5be79dd423fcabahrens dnode_allocate(dn, ot, blocksize, 0, bonustype, bonuslen, tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_reclaim(objset_t *os, uint64_t object, dmu_object_type_t ot,
e77d42eaa49fe55bfae1e0e0065c6e99affc001bMatthew Ahrens int blocksize, dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens err = dnode_hold_impl(os, object, DNODE_MUST_BE_ALLOCATED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dnode_reallocate(dn, ot, blocksize, bonustype, bonuslen, tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_free(objset_t *os, uint64_t object, dmu_tx_t *tx)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ASSERT(object != DMU_META_DNODE_OBJECT || dmu_tx_private_ok(tx));
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens err = dnode_hold_impl(os, object, DNODE_MUST_BE_ALLOCATED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * Return (in *objectp) the next object which is allocated (or a hole)
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * after *object, taking into account only objects that may have been modified
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * after the specified txg.
6754306ec9a89fd28806908d10c76141e8fbba3fahrensdmu_object_next(objset_t *os, uint64_t *objectp, boolean_t hole, uint64_t txg)
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee (hole ? DNODE_FIND_HOLE : 0), &offset, 0, DNODES_PER_BLOCK, txg);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * Turn this object from old_type into DMU_OTN_ZAP_METADATA, and bump the
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * refcount on SPA_FEATURE_EXTENSIBLE_DATASET.
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * Only for use from syncing context, on MOS objects.
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensdmu_object_zapify(objset_t *mos, uint64_t object, dmu_object_type_t old_type,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens dn->dn_next_type[tx->tx_txg & TXG_MASK] = dn->dn_type =