* Write the uberblock to all labels of all leaves of the specified vdev. */
| 1632 | * Write the uberblock to all labels of all leaves of the specified vdev. |
| 1633 | */ |
| 1634 | static void |
| 1635 | vdev_uberblock_sync(zio_t *zio, uint64_t *good_writes, |
| 1636 | uberblock_t *ub, vdev_t *vd, int flags) |
| 1637 | { |
| 1638 | for (uint64_t c = 0; c < vd->vdev_children; c++) { |
| 1639 | vdev_uberblock_sync(zio, good_writes, |
| 1640 | ub, vd->vdev_child[c], flags); |
| 1641 | } |
| 1642 | |
| 1643 | if (!vd->vdev_ops->vdev_op_leaf) |
| 1644 | return; |
| 1645 | |
| 1646 | if (!vdev_writeable(vd)) |
| 1647 | return; |
| 1648 | |
| 1649 | /* |
| 1650 | * There's no need to write uberblocks to a distributed spare, they |
| 1651 | * are already stored on all the leaves of the parent dRAID. For |
| 1652 | * this same reason vdev_uberblock_load_impl() skips distributed |
| 1653 | * spares when reading uberblocks. |
| 1654 | */ |
| 1655 | if (vd->vdev_ops == &vdev_draid_spare_ops) |
| 1656 | return; |
| 1657 | |
| 1658 | /* If the vdev was expanded, need to copy uberblock rings. */ |
| 1659 | if (vd->vdev_state == VDEV_STATE_HEALTHY && |
| 1660 | vd->vdev_copy_uberblocks == B_TRUE) { |
| 1661 | vdev_copy_uberblocks(vd); |
| 1662 | vd->vdev_copy_uberblocks = B_FALSE; |
| 1663 | } |
| 1664 | |
| 1665 | int m = spa_multihost(vd->vdev_spa) ? MMP_BLOCKS_PER_LABEL : 0; |
| 1666 | int n = ub->ub_txg % (VDEV_UBERBLOCK_COUNT(vd) - m); |
| 1667 | |
| 1668 | /* Copy the uberblock_t into the ABD */ |
| 1669 | abd_t *ub_abd = abd_alloc_for_io(VDEV_UBERBLOCK_SIZE(vd), B_TRUE); |
| 1670 | abd_zero(ub_abd, VDEV_UBERBLOCK_SIZE(vd)); |
| 1671 | abd_copy_from_buf(ub_abd, ub, sizeof (uberblock_t)); |
| 1672 | |
| 1673 | for (int l = 0; l < VDEV_LABELS; l++) |
| 1674 | vdev_label_write(zio, vd, l, ub_abd, |
| 1675 | VDEV_UBERBLOCK_OFFSET(vd, n), VDEV_UBERBLOCK_SIZE(vd), |
| 1676 | vdev_uberblock_sync_done, good_writes, |
| 1677 | flags | ZIO_FLAG_DONT_PROPAGATE); |
| 1678 | |
| 1679 | abd_free(ub_abd); |
| 1680 | } |
| 1681 | |
| 1682 | /* Sync the uberblocks to all vdevs in svd[] */ |
| 1683 | static int |
no test coverage detected