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

Function vdev_label_sync

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

* Write all even or odd labels to all leaves of the specified vdev. */

Source from the content-addressed store, hash-verified

1751 * Write all even or odd labels to all leaves of the specified vdev.
1752 */
1753static void
1754vdev_label_sync(zio_t *zio, uint64_t *good_writes,
1755 vdev_t *vd, int l, uint64_t txg, int flags)
1756{
1757 nvlist_t *label;
1758 vdev_phys_t *vp;
1759 abd_t *vp_abd;
1760 char *buf;
1761 size_t buflen;
1762
1763 for (int c = 0; c < vd->vdev_children; c++) {
1764 vdev_label_sync(zio, good_writes,
1765 vd->vdev_child[c], l, txg, flags);
1766 }
1767
1768 if (!vd->vdev_ops->vdev_op_leaf)
1769 return;
1770
1771 if (!vdev_writeable(vd))
1772 return;
1773
1774 /*
1775 * The top-level config never needs to be written to a distributed
1776 * spare. When read vdev_dspare_label_read_config() will generate
1777 * the config for the vdev_label_read_config().
1778 */
1779 if (vd->vdev_ops == &vdev_draid_spare_ops)
1780 return;
1781
1782 /*
1783 * Generate a label describing the top-level config to which we belong.
1784 */
1785 label = spa_config_generate(vd->vdev_spa, vd, txg, B_FALSE);
1786
1787 vp_abd = abd_alloc_linear(sizeof (vdev_phys_t), B_TRUE);
1788 abd_zero(vp_abd, sizeof (vdev_phys_t));
1789 vp = abd_to_buf(vp_abd);
1790
1791 buf = vp->vp_nvlist;
1792 buflen = sizeof (vp->vp_nvlist);
1793
1794 if (!nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_SLEEP)) {
1795 for (; l < VDEV_LABELS; l += 2) {
1796 vdev_label_write(zio, vd, l, vp_abd,
1797 offsetof(vdev_label_t, vl_vdev_phys),
1798 sizeof (vdev_phys_t),
1799 vdev_label_sync_done, good_writes,
1800 flags | ZIO_FLAG_DONT_PROPAGATE);
1801 }
1802 }
1803
1804 abd_free(vp_abd);
1805 nvlist_free(label);
1806}
1807
1808static int
1809vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags)

Callers 1

vdev_label_sync_listFunction · 0.85

Calls 9

vdev_writeableFunction · 0.85
spa_config_generateFunction · 0.85
abd_alloc_linearFunction · 0.85
abd_zeroFunction · 0.85
abd_to_bufFunction · 0.85
vdev_label_writeFunction · 0.85
abd_freeFunction · 0.85
nvlist_packFunction · 0.50
nvlist_freeFunction · 0.50

Tested by

no test coverage detected