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

Function zdb_count_block

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

Source from the content-addressed store, hash-verified

5055}
5056
5057static void
5058zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp,
5059 dmu_object_type_t type)
5060{
5061 uint64_t refcnt = 0;
5062 int i;
5063
5064 ASSERT(type < ZDB_OT_TOTAL);
5065
5066 if (zilog && zil_bp_tree_add(zilog, bp) != 0)
5067 return;
5068
5069 spa_config_enter(zcb->zcb_spa, SCL_CONFIG, FTAG, RW_READER);
5070
5071 for (i = 0; i < 4; i++) {
5072 int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL;
5073 int t = (i & 1) ? type : ZDB_OT_TOTAL;
5074 int equal;
5075 zdb_blkstats_t *zb = &zcb->zcb_type[l][t];
5076
5077 zb->zb_asize += BP_GET_ASIZE(bp);
5078 zb->zb_lsize += BP_GET_LSIZE(bp);
5079 zb->zb_psize += BP_GET_PSIZE(bp);
5080 zb->zb_count++;
5081
5082 /*
5083 * The histogram is only big enough to record blocks up to
5084 * SPA_OLD_MAXBLOCKSIZE; larger blocks go into the last,
5085 * "other", bucket.
5086 */
5087 unsigned idx = BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT;
5088 idx = MIN(idx, SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1);
5089 zb->zb_psize_histogram[idx]++;
5090
5091 zb->zb_gangs += BP_COUNT_GANG(bp);
5092
5093 switch (BP_GET_NDVAS(bp)) {
5094 case 2:
5095 if (DVA_GET_VDEV(&bp->blk_dva[0]) ==
5096 DVA_GET_VDEV(&bp->blk_dva[1])) {
5097 zb->zb_ditto_samevdev++;
5098
5099 if (same_metaslab(zcb->zcb_spa,
5100 DVA_GET_VDEV(&bp->blk_dva[0]),
5101 DVA_GET_OFFSET(&bp->blk_dva[0]),
5102 DVA_GET_OFFSET(&bp->blk_dva[1])))
5103 zb->zb_ditto_same_ms++;
5104 }
5105 break;
5106 case 3:
5107 equal = (DVA_GET_VDEV(&bp->blk_dva[0]) ==
5108 DVA_GET_VDEV(&bp->blk_dva[1])) +
5109 (DVA_GET_VDEV(&bp->blk_dva[0]) ==
5110 DVA_GET_VDEV(&bp->blk_dva[2])) +
5111 (DVA_GET_VDEV(&bp->blk_dva[1]) ==
5112 DVA_GET_VDEV(&bp->blk_dva[2]));
5113 if (equal != 0) {
5114 zb->zb_ditto_samevdev++;

Callers 3

zdb_blkptr_cbFunction · 0.85
zdb_ddt_leak_initFunction · 0.85
count_block_cbFunction · 0.85

Calls 15

zil_bp_tree_addFunction · 0.85
spa_config_enterFunction · 0.85
same_metaslabFunction · 0.85
spa_config_exitFunction · 0.85
ddt_selectFunction · 0.85
ddt_enterFunction · 0.85
ddt_lookupFunction · 0.85
ddt_phys_selectFunction · 0.85
ddt_phys_decrefFunction · 0.85
ddt_phys_total_refcntFunction · 0.85
ddt_removeFunction · 0.85
ddt_exitFunction · 0.85

Tested by

no test coverage detected