Deleted Added
sdiff udiff text old ( 332525 ) new ( 332530 )
full compact
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 157 unchanged lines hidden (view full) ---

166 * When a vdev is added, it will be divided into approximately (but no
167 * more than) this number of metaslabs.
168 */
169int metaslabs_per_vdev = 200;
170SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, metaslabs_per_vdev, CTLFLAG_RDTUN,
171 &metaslabs_per_vdev, 0,
172 "When a vdev is added, how many metaslabs the vdev should be divided into");
173
174/*
175 * Given a vdev type, return the appropriate ops vector.
176 */
177static vdev_ops_t *
178vdev_getops(const char *type)
179{
180 vdev_ops_t *ops, **opspp;
181

--- 843 unchanged lines hidden (view full) ---

1025 * vdev_ms_array may be 0 if we are creating the "fake"
1026 * metaslabs for an indirect vdev for zdb's leak detection.
1027 * See zdb_leak_init().
1028 */
1029 if (txg == 0 && vd->vdev_ms_array != 0) {
1030 error = dmu_read(mos, vd->vdev_ms_array,
1031 m * sizeof (uint64_t), sizeof (uint64_t), &object,
1032 DMU_READ_PREFETCH);
1033 if (error)
1034 return (error);
1035 }
1036
1037 error = metaslab_init(vd->vdev_mg, m, object, txg,
1038 &(vd->vdev_ms[m]));
1039 if (error)
1040 return (error);
1041 }
1042
1043 if (txg == 0)
1044 spa_config_enter(spa, SCL_ALLOC, FTAG, RW_WRITER);
1045
1046 /*
1047 * If the vdev is being removed we don't activate
1048 * the metaslabs since we want to ensure that no new

--- 65 unchanged lines hidden (view full) ---

1114 vd->vdev_cant_read |= !vps->vps_readable;
1115 vd->vdev_cant_write |= !vps->vps_writeable;
1116
1117 if (vdev_readable(vd) &&
1118 (vdev_writeable(vd) || !spa_writeable(spa))) {
1119 zio->io_error = 0;
1120 } else {
1121 ASSERT(zio->io_error != 0);
1122 zfs_dbgmsg("failed probe on vdev %llu",
1123 (longlong_t)vd->vdev_id);
1124 zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
1125 spa, vd, NULL, 0, 0);
1126 zio->io_error = SET_ERROR(ENXIO);
1127 }
1128
1129 mutex_enter(&vd->vdev_probe_lock);
1130 ASSERT(vd->vdev_probe_zio == zio);
1131 vd->vdev_probe_zio = NULL;

--- 439 unchanged lines hidden (view full) ---

1571 uint64_t aux_guid = 0;
1572 nvlist_t *nvl;
1573 uint64_t txg = spa_last_synced_txg(spa) != 0 ?
1574 spa_last_synced_txg(spa) : -1ULL;
1575
1576 if ((label = vdev_label_read_config(vd, txg)) == NULL) {
1577 vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
1578 VDEV_AUX_BAD_LABEL);
1579 return (0);
1580 }
1581
1582 /*
1583 * Determine if this vdev has been split off into another
1584 * pool. If so, then refuse to open it.
1585 */
1586 if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_SPLIT_GUID,
1587 &aux_guid) == 0 && aux_guid == spa_guid(spa)) {
1588 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
1589 VDEV_AUX_SPLIT_POOL);
1590 nvlist_free(label);
1591 return (0);
1592 }
1593
1594 if (strict && (nvlist_lookup_uint64(label,
1595 ZPOOL_CONFIG_POOL_GUID, &guid) != 0 ||
1596 guid != spa_guid(spa))) {
1597 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
1598 VDEV_AUX_CORRUPT_DATA);
1599 nvlist_free(label);
1600 return (0);
1601 }
1602
1603 if (nvlist_lookup_nvlist(label, ZPOOL_CONFIG_VDEV_TREE, &nvl)
1604 != 0 || nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_ORIG_GUID,
1605 &aux_guid) != 0)
1606 aux_guid = 0;
1607

--- 13 unchanged lines hidden (view full) ---

1621 &guid) != 0 ||
1622 nvlist_lookup_uint64(label, ZPOOL_CONFIG_TOP_GUID,
1623 &top_guid) != 0 ||
1624 ((vd->vdev_guid != guid && vd->vdev_guid != aux_guid) &&
1625 (vd->vdev_guid != top_guid || vd != vd->vdev_top))) {
1626 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
1627 VDEV_AUX_CORRUPT_DATA);
1628 nvlist_free(label);
1629 return (0);
1630 }
1631
1632 if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_STATE,
1633 &state) != 0) {
1634 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
1635 VDEV_AUX_CORRUPT_DATA);
1636 nvlist_free(label);
1637 return (0);
1638 }
1639
1640 nvlist_free(label);
1641
1642 /*
1643 * If this is a verbatim import, no need to check the
1644 * state of the pool.
1645 */
1646 if (!(spa->spa_import_flags & ZFS_IMPORT_VERBATIM) &&
1647 spa_load_state(spa) == SPA_LOAD_OPEN &&
1648 state != POOL_STATE_ACTIVE)
1649 return (SET_ERROR(EBADF));
1650
1651 /*
1652 * If we were able to open and validate a vdev that was
1653 * previously marked permanently unavailable, clear that state
1654 * now.
1655 */
1656 if (vd->vdev_not_present)
1657 vd->vdev_not_present = 0;

--- 631 unchanged lines hidden (view full) ---

2289
2290 range_tree_destroy(rtsync);
2291
2292 /*
2293 * If the object for the space map has changed then dirty
2294 * the top level so that we update the config.
2295 */
2296 if (object != space_map_object(vd->vdev_dtl_sm)) {
2297 zfs_dbgmsg("txg %llu, spa %s, DTL old object %llu, "
2298 "new object %llu", txg, spa_name(spa), object,
2299 space_map_object(vd->vdev_dtl_sm));
2300 vdev_config_dirty(vd->vdev_top);
2301 }
2302
2303 dmu_tx_commit(tx);
2304
2305 mutex_enter(&vd->vdev_dtl_lock);
2306 space_map_update(vd->vdev_dtl_sm);
2307 mutex_exit(&vd->vdev_dtl_lock);

--- 91 unchanged lines hidden (view full) ---

2399
2400 /*
2401 * If this is a top-level vdev, initialize its metaslabs.
2402 */
2403 if (vd == vd->vdev_top && vdev_is_concrete(vd)) {
2404 if (vd->vdev_ashift == 0 || vd->vdev_asize == 0) {
2405 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2406 VDEV_AUX_CORRUPT_DATA);
2407 return (SET_ERROR(ENXIO));
2408 } else if ((error = vdev_metaslab_init(vd, 0)) != 0) {
2409 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2410 VDEV_AUX_CORRUPT_DATA);
2411 return (error);
2412 }
2413 }
2414
2415 /*
2416 * If this is a leaf vdev, load its DTL.
2417 */
2418 if (vd->vdev_ops->vdev_op_leaf && (error = vdev_dtl_load(vd)) != 0) {
2419 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2420 VDEV_AUX_CORRUPT_DATA);
2421 return (error);
2422 }
2423
2424 uint64_t obsolete_sm_object = vdev_obsolete_sm_object(vd);
2425 if (obsolete_sm_object != 0) {
2426 objset_t *mos = vd->vdev_spa->spa_meta_objset;
2427 ASSERT(vd->vdev_asize != 0);
2428 ASSERT(vd->vdev_obsolete_sm == NULL);
2429
2430 if ((error = space_map_open(&vd->vdev_obsolete_sm, mos,
2431 obsolete_sm_object, 0, vd->vdev_asize, 0))) {
2432 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2433 VDEV_AUX_CORRUPT_DATA);
2434 return (error);
2435 }
2436 space_map_update(vd->vdev_obsolete_sm);
2437 }
2438
2439 return (0);
2440}
2441

--- 1358 unchanged lines hidden (view full) ---

3800 /*
3801 * Look at the head of all the pending queues,
3802 * if any I/O has been outstanding for longer than
3803 * the spa_deadman_synctime we panic the system.
3804 */
3805 fio = avl_first(&vq->vq_active_tree);
3806 delta = gethrtime() - fio->io_timestamp;
3807 if (delta > spa_deadman_synctime(spa)) {
3808 zfs_dbgmsg("SLOW IO: zio timestamp %lluns, "
3809 "delta %lluns, last io %lluns",
3810 fio->io_timestamp, delta,
3811 vq->vq_io_complete_ts);
3812 fm_panic("I/O to pool '%s' appears to be "
3813 "hung on vdev guid %llu at '%s'.",
3814 spa_name(spa),
3815 (long long unsigned int) vd->vdev_guid,
3816 vd->vdev_path);
3817 }
3818 }
3819 mutex_exit(&vq->vq_lock);
3820 }
3821}