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

Function vdev_open

freebsd/contrib/openzfs/module/zfs/vdev.c:1774–2038  ·  view source on GitHub ↗

* Prepare a virtual device for access. */

Source from the content-addressed store, hash-verified

1772 * Prepare a virtual device for access.
1773 */
1774int
1775vdev_open(vdev_t *vd)
1776{
1777 spa_t *spa = vd->vdev_spa;
1778 int error;
1779 uint64_t osize = 0;
1780 uint64_t max_osize = 0;
1781 uint64_t asize, max_asize, psize;
1782 uint64_t logical_ashift = 0;
1783 uint64_t physical_ashift = 0;
1784
1785 ASSERT(vd->vdev_open_thread == curthread ||
1786 spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL);
1787 ASSERT(vd->vdev_state == VDEV_STATE_CLOSED ||
1788 vd->vdev_state == VDEV_STATE_CANT_OPEN ||
1789 vd->vdev_state == VDEV_STATE_OFFLINE);
1790
1791 vd->vdev_stat.vs_aux = VDEV_AUX_NONE;
1792 vd->vdev_cant_read = B_FALSE;
1793 vd->vdev_cant_write = B_FALSE;
1794 vd->vdev_min_asize = vdev_get_min_asize(vd);
1795
1796 /*
1797 * If this vdev is not removed, check its fault status. If it's
1798 * faulted, bail out of the open.
1799 */
1800 if (!vd->vdev_removed && vd->vdev_faulted) {
1801 ASSERT(vd->vdev_children == 0);
1802 ASSERT(vd->vdev_label_aux == VDEV_AUX_ERR_EXCEEDED ||
1803 vd->vdev_label_aux == VDEV_AUX_EXTERNAL);
1804 vdev_set_state(vd, B_TRUE, VDEV_STATE_FAULTED,
1805 vd->vdev_label_aux);
1806 return (SET_ERROR(ENXIO));
1807 } else if (vd->vdev_offline) {
1808 ASSERT(vd->vdev_children == 0);
1809 vdev_set_state(vd, B_TRUE, VDEV_STATE_OFFLINE, VDEV_AUX_NONE);
1810 return (SET_ERROR(ENXIO));
1811 }
1812
1813 error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize,
1814 &logical_ashift, &physical_ashift);
1815 /*
1816 * Physical volume size should never be larger than its max size, unless
1817 * the disk has shrunk while we were reading it or the device is buggy
1818 * or damaged: either way it's not safe for use, bail out of the open.
1819 */
1820 if (osize > max_osize) {
1821 vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
1822 VDEV_AUX_OPEN_FAILED);
1823 return (SET_ERROR(ENXIO));
1824 }
1825
1826 /*
1827 * Reset the vdev_reopening flag so that we actually close
1828 * the vdev on error.
1829 */
1830 vd->vdev_reopening = B_FALSE;
1831 if (zio_injection_enabled && error == 0)

Callers 8

vdev_open_childFunction · 0.85
vdev_open_children_implFunction · 0.85
vdev_reopenFunction · 0.85
vdev_createFunction · 0.85
spa_load_sparesFunction · 0.85
spa_load_l2cacheFunction · 0.85
spa_ld_open_vdevsFunction · 0.85
spa_validate_aux_devsFunction · 0.85

Calls 11

spa_config_heldFunction · 0.85
vdev_get_min_asizeFunction · 0.85
vdev_set_stateFunction · 0.85
vdev_ashift_optimizeFunction · 0.85
zfs_ereport_postFunction · 0.85
vdev_set_min_asizeFunction · 0.85
zio_waitFunction · 0.85
vdev_get_min_allocFunction · 0.85
dsl_scan_assess_vdevFunction · 0.85
vdev_probeFunction · 0.70

Tested by

no test coverage detected