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

Function vdev_uberblock_load

freebsd/contrib/openzfs/module/zfs/vdev_label.c:1511–1555  ·  view source on GitHub ↗

* Reads the 'best' uberblock from disk along with its associated * configuration. First, we read the uberblock array of each label of each * vdev, keeping track of the uberblock with the highest txg in each array. * Then, we read the configuration from the same vdev as the best uberblock. */

Source from the content-addressed store, hash-verified

1509 * Then, we read the configuration from the same vdev as the best uberblock.
1510 */
1511void
1512vdev_uberblock_load(vdev_t *rvd, uberblock_t *ub, nvlist_t **config)
1513{
1514 zio_t *zio;
1515 spa_t *spa = rvd->vdev_spa;
1516 struct ubl_cbdata cb;
1517 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
1518 ZIO_FLAG_SPECULATIVE | ZIO_FLAG_TRYHARD;
1519
1520 ASSERT(ub);
1521 ASSERT(config);
1522
1523 bzero(ub, sizeof (uberblock_t));
1524 *config = NULL;
1525
1526 cb.ubl_ubbest = ub;
1527 cb.ubl_vd = NULL;
1528
1529 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
1530 zio = zio_root(spa, NULL, &cb, flags);
1531 vdev_uberblock_load_impl(zio, rvd, flags, &cb);
1532 (void) zio_wait(zio);
1533
1534 /*
1535 * It's possible that the best uberblock was discovered on a label
1536 * that has a configuration which was written in a future txg.
1537 * Search all labels on this vdev to find the configuration that
1538 * matches the txg for our uberblock.
1539 */
1540 if (cb.ubl_vd != NULL) {
1541 vdev_dbgmsg(cb.ubl_vd, "best uberblock found for spa %s. "
1542 "txg %llu", spa->spa_name, (u_longlong_t)ub->ub_txg);
1543
1544 *config = vdev_label_read_config(cb.ubl_vd, ub->ub_txg);
1545 if (*config == NULL && spa->spa_extreme_rewind) {
1546 vdev_dbgmsg(cb.ubl_vd, "failed to read label config. "
1547 "Trying again without txg restrictions.");
1548 *config = vdev_label_read_config(cb.ubl_vd, UINT64_MAX);
1549 }
1550 if (*config == NULL) {
1551 vdev_dbgmsg(cb.ubl_vd, "failed to read label config");
1552 }
1553 }
1554 spa_config_exit(spa, SCL_ALL, FTAG);
1555}
1556
1557/*
1558 * For use when a leaf vdev is expanded.

Callers 2

spa_activity_checkFunction · 0.85
spa_ld_select_uberblockFunction · 0.85

Calls 8

bzeroFunction · 0.85
spa_config_enterFunction · 0.85
zio_rootFunction · 0.85
vdev_uberblock_load_implFunction · 0.85
zio_waitFunction · 0.85
vdev_dbgmsgFunction · 0.85
vdev_label_read_configFunction · 0.85
spa_config_exitFunction · 0.85

Tested by

no test coverage detected