MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zdb_leak_init

Function zdb_leak_init

freebsd/contrib/openzfs/cmd/zdb/zdb.c:5867–5934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5865}
5866
5867static void
5868zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
5869{
5870 zcb->zcb_spa = spa;
5871
5872 if (dump_opt['L'])
5873 return;
5874
5875 dsl_pool_t *dp = spa->spa_dsl_pool;
5876 vdev_t *rvd = spa->spa_root_vdev;
5877
5878 /*
5879 * We are going to be changing the meaning of the metaslab's
5880 * ms_allocatable. Ensure that the allocator doesn't try to
5881 * use the tree.
5882 */
5883 spa->spa_normal_class->mc_ops = &zdb_metaslab_ops;
5884 spa->spa_log_class->mc_ops = &zdb_metaslab_ops;
5885
5886 zcb->zcb_vd_obsolete_counts =
5887 umem_zalloc(rvd->vdev_children * sizeof (uint32_t *),
5888 UMEM_NOFAIL);
5889
5890 /*
5891 * For leak detection, we overload the ms_allocatable trees
5892 * to contain allocated segments instead of free segments.
5893 * As a result, we can't use the normal metaslab_load/unload
5894 * interfaces.
5895 */
5896 zdb_leak_init_prepare_indirect_vdevs(spa, zcb);
5897 load_concrete_ms_allocatable_trees(spa, SM_ALLOC);
5898
5899 /*
5900 * On load_concrete_ms_allocatable_trees() we loaded all the
5901 * allocated entries from the ms_sm to the ms_allocatable for
5902 * each metaslab. If the pool has a checkpoint or is in the
5903 * middle of discarding a checkpoint, some of these blocks
5904 * may have been freed but their ms_sm may not have been
5905 * updated because they are referenced by the checkpoint. In
5906 * order to avoid false-positives during leak-detection, we
5907 * go through the vdev's checkpoint space map and exclude all
5908 * its entries from their relevant ms_allocatable.
5909 *
5910 * We also aggregate the space held by the checkpoint and add
5911 * it to zcb_checkpoint_size.
5912 *
5913 * Note that at this point we are also verifying that all the
5914 * entries on the checkpoint_sm are marked as allocated in
5915 * the ms_sm of their relevant metaslab.
5916 * [see comment in checkpoint_sm_exclude_entry_cb()]
5917 */
5918 zdb_leak_init_exclude_checkpoint(spa, zcb);
5919 ASSERT3U(zcb->zcb_checkpoint_size, ==, spa_get_checkpoint_space(spa));
5920
5921 /* for cleaner progress output */
5922 (void) fprintf(stderr, "\n");
5923
5924 if (bpobj_is_open(&dp->dp_obsolete_bpobj)) {

Callers 1

dump_block_statsFunction · 0.85

Calls 11

umem_zallocFunction · 0.85
spa_get_checkpoint_spaceFunction · 0.85
bpobj_is_openFunction · 0.85
spa_feature_is_enabledFunction · 0.85
bpobj_iterate_nofreeFunction · 0.85
spa_config_enterFunction · 0.85
zdb_ddt_leak_initFunction · 0.85
spa_config_exitFunction · 0.85

Tested by

no test coverage detected