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

Function zdb_blkptr_cb

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

Source from the content-addressed store, hash-verified

5238}
5239
5240static int
5241zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
5242 const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg)
5243{
5244 zdb_cb_t *zcb = arg;
5245 dmu_object_type_t type;
5246 boolean_t is_metadata;
5247
5248 if (zb->zb_level == ZB_DNODE_LEVEL)
5249 return (0);
5250
5251 if (dump_opt['b'] >= 5 && bp->blk_birth > 0) {
5252 char blkbuf[BP_SPRINTF_LEN];
5253 snprintf_blkptr(blkbuf, sizeof (blkbuf), bp);
5254 (void) printf("objset %llu object %llu "
5255 "level %lld offset 0x%llx %s\n",
5256 (u_longlong_t)zb->zb_objset,
5257 (u_longlong_t)zb->zb_object,
5258 (longlong_t)zb->zb_level,
5259 (u_longlong_t)blkid2offset(dnp, bp, zb),
5260 blkbuf);
5261 }
5262
5263 if (BP_IS_HOLE(bp) || BP_IS_REDACTED(bp))
5264 return (0);
5265
5266 type = BP_GET_TYPE(bp);
5267
5268 zdb_count_block(zcb, zilog, bp,
5269 (type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);
5270
5271 is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));
5272
5273 if (!BP_IS_EMBEDDED(bp) &&
5274 (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata))) {
5275 size_t size = BP_GET_PSIZE(bp);
5276 abd_t *abd = abd_alloc(size, B_FALSE);
5277 int flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_SCRUB | ZIO_FLAG_RAW;
5278
5279 /* If it's an intent log block, failure is expected. */
5280 if (zb->zb_level == ZB_ZIL_LEVEL)
5281 flags |= ZIO_FLAG_SPECULATIVE;
5282
5283 mutex_enter(&spa->spa_scrub_lock);
5284 while (spa->spa_load_verify_bytes > max_inflight_bytes)
5285 cv_wait(&spa->spa_scrub_io_cv, &spa->spa_scrub_lock);
5286 spa->spa_load_verify_bytes += size;
5287 mutex_exit(&spa->spa_scrub_lock);
5288
5289 zio_nowait(zio_read(NULL, spa, bp, abd, size,
5290 zdb_blkptr_done, zcb, ZIO_PRIORITY_ASYNC_READ, flags, zb));
5291 }
5292
5293 zcb->zcb_readfails = 0;
5294
5295 /* only call gethrtime() every 100 blocks */
5296 static int iters;
5297 if (++iters > 100)

Callers

nothing calls this directly

Calls 12

snprintf_blkptrFunction · 0.85
blkid2offsetFunction · 0.85
zdb_count_blockFunction · 0.85
abd_allocFunction · 0.85
mutex_enterFunction · 0.85
cv_waitFunction · 0.85
mutex_exitFunction · 0.85
zio_nowaitFunction · 0.85
zio_readFunction · 0.85
zfs_nicebytesFunction · 0.85
printfFunction · 0.50
gethrtimeFunction · 0.50

Tested by

no test coverage detected