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

Function vdev_probe

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

* Determine whether this device is accessible. * * Read and write to several known locations: the pad regions of each * vdev label but the first, which we leave alone in case it contains * a VTOC. */

Source from the content-addressed store, hash-verified

1543 * a VTOC.
1544 */
1545zio_t *
1546vdev_probe(vdev_t *vd, zio_t *zio)
1547{
1548 spa_t *spa = vd->vdev_spa;
1549 vdev_probe_stats_t *vps = NULL;
1550 zio_t *pio;
1551
1552 ASSERT(vd->vdev_ops->vdev_op_leaf);
1553
1554 /*
1555 * Don't probe the probe.
1556 */
1557 if (zio && (zio->io_flags & ZIO_FLAG_PROBE))
1558 return (NULL);
1559
1560 /*
1561 * To prevent 'probe storms' when a device fails, we create
1562 * just one probe i/o at a time. All zios that want to probe
1563 * this vdev will become parents of the probe io.
1564 */
1565 mutex_enter(&vd->vdev_probe_lock);
1566
1567 if ((pio = vd->vdev_probe_zio) == NULL) {
1568 vps = kmem_zalloc(sizeof (*vps), KM_SLEEP);
1569
1570 vps->vps_flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_PROBE |
1571 ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_AGGREGATE |
1572 ZIO_FLAG_TRYHARD;
1573
1574 if (spa_config_held(spa, SCL_ZIO, RW_WRITER)) {
1575 /*
1576 * vdev_cant_read and vdev_cant_write can only
1577 * transition from TRUE to FALSE when we have the
1578 * SCL_ZIO lock as writer; otherwise they can only
1579 * transition from FALSE to TRUE. This ensures that
1580 * any zio looking at these values can assume that
1581 * failures persist for the life of the I/O. That's
1582 * important because when a device has intermittent
1583 * connectivity problems, we want to ensure that
1584 * they're ascribed to the device (ENXIO) and not
1585 * the zio (EIO).
1586 *
1587 * Since we hold SCL_ZIO as writer here, clear both
1588 * values so the probe can reevaluate from first
1589 * principles.
1590 */
1591 vps->vps_flags |= ZIO_FLAG_CONFIG_WRITER;
1592 vd->vdev_cant_read = B_FALSE;
1593 vd->vdev_cant_write = B_FALSE;
1594 }
1595
1596 vd->vdev_probe_zio = pio = zio_null(NULL, spa, vd,
1597 vdev_probe_done, vps,
1598 vps->vps_flags | ZIO_FLAG_DONT_PROPAGATE);
1599
1600 /*
1601 * We can't change the vdev state in this context, so we
1602 * kick off an async task to do it on our behalf.

Callers 2

vdev_openFunction · 0.70
zio_vdev_io_doneFunction · 0.70

Calls 10

mutex_enterFunction · 0.85
spa_config_heldFunction · 0.85
zio_nullFunction · 0.85
spa_async_requestFunction · 0.85
zio_add_childFunction · 0.85
mutex_exitFunction · 0.85
zio_nowaitFunction · 0.85
zio_read_physFunction · 0.85
vdev_label_offsetFunction · 0.85
abd_alloc_for_ioFunction · 0.50

Tested by

no test coverage detected