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

Function vdev_copy_uberblocks

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

Source from the content-addressed store, hash-verified

1566 */
1567
1568static void
1569vdev_copy_uberblocks(vdev_t *vd)
1570{
1571 abd_t *ub_abd;
1572 zio_t *write_zio;
1573 int locks = (SCL_L2ARC | SCL_ZIO);
1574 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
1575 ZIO_FLAG_SPECULATIVE;
1576
1577 ASSERT(spa_config_held(vd->vdev_spa, SCL_STATE, RW_READER) ==
1578 SCL_STATE);
1579 ASSERT(vd->vdev_ops->vdev_op_leaf);
1580
1581 /*
1582 * No uberblocks are stored on distributed spares, they may be
1583 * safely skipped when expanding a leaf vdev.
1584 */
1585 if (vd->vdev_ops == &vdev_draid_spare_ops)
1586 return;
1587
1588 spa_config_enter(vd->vdev_spa, locks, FTAG, RW_READER);
1589
1590 ub_abd = abd_alloc_linear(VDEV_UBERBLOCK_SIZE(vd), B_TRUE);
1591
1592 write_zio = zio_root(vd->vdev_spa, NULL, NULL, flags);
1593 for (int n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) {
1594 const int src_label = 0;
1595 zio_t *zio;
1596
1597 zio = zio_root(vd->vdev_spa, NULL, NULL, flags);
1598 vdev_label_read(zio, vd, src_label, ub_abd,
1599 VDEV_UBERBLOCK_OFFSET(vd, n), VDEV_UBERBLOCK_SIZE(vd),
1600 NULL, NULL, flags);
1601
1602 if (zio_wait(zio) || uberblock_verify(abd_to_buf(ub_abd)))
1603 abd_zero(ub_abd, VDEV_UBERBLOCK_SIZE(vd));
1604
1605 for (int l = 2; l < VDEV_LABELS; l++)
1606 vdev_label_write(write_zio, vd, l, ub_abd,
1607 VDEV_UBERBLOCK_OFFSET(vd, n),
1608 VDEV_UBERBLOCK_SIZE(vd), NULL, NULL,
1609 flags | ZIO_FLAG_DONT_PROPAGATE);
1610 }
1611 (void) zio_wait(write_zio);
1612
1613 spa_config_exit(vd->vdev_spa, locks, FTAG);
1614
1615 abd_free(ub_abd);
1616}
1617
1618/*
1619 * On success, increment root zio's count of good writes.

Callers 1

vdev_uberblock_syncFunction · 0.85

Calls 12

spa_config_heldFunction · 0.85
spa_config_enterFunction · 0.85
abd_alloc_linearFunction · 0.85
zio_rootFunction · 0.85
vdev_label_readFunction · 0.85
zio_waitFunction · 0.85
uberblock_verifyFunction · 0.85
abd_to_bufFunction · 0.85
abd_zeroFunction · 0.85
vdev_label_writeFunction · 0.85
spa_config_exitFunction · 0.85
abd_freeFunction · 0.85

Tested by

no test coverage detected