1786 * Call when we think we're going to write/free space in open context.
1787 * Be conservative (ie. OK to write less than this or free more than
1788 * this, but don't write more or free less).
1789 */
1790 void
1791 dnode_willuse_space(dnode_t *dn, int64_t space, dmu_tx_t *tx)
1792 {
1793 objset_t *os = dn->dn_objset;
1794 dsl_dataset_t *ds = os->os_dsl_dataset;
1795
1796 if (space > 0)
1797 space = spa_get_asize(os->os_spa, space);
1798
1799 if (ds)
1800 dsl_dir_willuse_space(ds->ds_dir, space, tx);
1801
1802 dmu_tx_willuse_space(tx, space);
1803 }
1804
1805 /*
1806 * This function scans a block at the indicated "level" looking for
1807 * a hole or data (depending on 'flags'). If level > 0, then we are
1808 * scanning an indirect block looking at its pointers. If level == 0,
1809 * then we are looking at a block of dnodes. If we don't find what we
1810 * are looking for in the block, we return ESRCH. Otherwise, return
1811 * with *offset pointing to the beginning (if searching forwards) or
1812 * end (if searching backwards) of the range covered by the block
1813 * pointer we matched on (or dnode).
1814 *
1815 * The basic search algorithm used below by dnode_next_offset() is to
1816 * use this function to search up the block tree (widen the search) until
1817 * we find something (i.e., we don't return ESRCH) and then search back
1818 * down the tree (narrow the search) until we reach our original search
1819 * level.
1820 */
1821 static int
1822 dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
1823 int lvl, uint64_t blkfill, uint64_t txg)
1824 {
1825 dmu_buf_impl_t *db = NULL;
1826 void *data = NULL;
1827 uint64_t epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
1828 uint64_t epb = 1ULL << epbs;
1829 uint64_t minfill, maxfill;
1830 boolean_t hole;
1831 int i, inc, error, span;
1832
1833 dprintf("probing object %llu offset %llx level %d of %u\n",
|
1786 * Call when we think we're going to write/free space in open context.
1787 * Be conservative (ie. OK to write less than this or free more than
1788 * this, but don't write more or free less).
1789 */
1790 void
1791 dnode_willuse_space(dnode_t *dn, int64_t space, dmu_tx_t *tx)
1792 {
1793 objset_t *os = dn->dn_objset;
1794 dsl_dataset_t *ds = os->os_dsl_dataset;
1795
1796 if (space > 0)
1797 space = spa_get_asize(os->os_spa, space);
1798
1799 if (ds)
1800 dsl_dir_willuse_space(ds->ds_dir, space, tx);
1801
1802 dmu_tx_willuse_space(tx, space);
1803 }
1804
1805 /*
1806 * Scans a block at the indicated "level" looking for a hole or data,
1807 * depending on 'flags'.
1808 *
1809 * If level > 0, then we are scanning an indirect block looking at its
1810 * pointers. If level == 0, then we are looking at a block of dnodes.
1811 *
1812 * If we don't find what we are looking for in the block, we return ESRCH.
1813 * Otherwise, return with *offset pointing to the beginning (if searching
1814 * forwards) or end (if searching backwards) of the range covered by the
1815 * block pointer we matched on (or dnode).
1816 *
1817 * The basic search algorithm used below by dnode_next_offset() is to
1818 * use this function to search up the block tree (widen the search) until
1819 * we find something (i.e., we don't return ESRCH) and then search back
1820 * down the tree (narrow the search) until we reach our original search
1821 * level.
1822 */
1823 static int
1824 dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
1825 int lvl, uint64_t blkfill, uint64_t txg)
1826 {
1827 dmu_buf_impl_t *db = NULL;
1828 void *data = NULL;
1829 uint64_t epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
1830 uint64_t epb = 1ULL << epbs;
1831 uint64_t minfill, maxfill;
1832 boolean_t hole;
1833 int i, inc, error, span;
1834
1835 dprintf("probing object %llu offset %llx level %d of %u\n",
|