Deleted Added
sdiff udiff text old ( 254112 ) new ( 254591 )
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

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

47
48SYSCTL_DECL(_vfs_zfs);
49SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV");
50
51/*
52 * Virtual device management.
53 */
54
55static vdev_ops_t *vdev_ops_table[] = {
56 &vdev_root_ops,
57 &vdev_raidz_ops,
58 &vdev_mirror_ops,
59 &vdev_replacing_ops,
60 &vdev_spare_ops,
61#ifdef _KERNEL
62 &vdev_geom_ops,

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

741 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
742
743 mvd = vdev_alloc_common(spa, cvd->vdev_id, 0, ops);
744
745 mvd->vdev_asize = cvd->vdev_asize;
746 mvd->vdev_min_asize = cvd->vdev_min_asize;
747 mvd->vdev_max_asize = cvd->vdev_max_asize;
748 mvd->vdev_ashift = cvd->vdev_ashift;
749 mvd->vdev_state = cvd->vdev_state;
750 mvd->vdev_crtxg = cvd->vdev_crtxg;
751
752 vdev_remove_child(pvd, cvd);
753 vdev_add_child(pvd, mvd);
754 cvd->vdev_id = mvd->vdev_children;
755 vdev_add_child(mvd, cvd);
756 vdev_top_update(cvd->vdev_top, cvd->vdev_top);

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

772
773 ASSERT(spa_config_held(cvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL);
774
775 ASSERT(mvd->vdev_children == 1);
776 ASSERT(mvd->vdev_ops == &vdev_mirror_ops ||
777 mvd->vdev_ops == &vdev_replacing_ops ||
778 mvd->vdev_ops == &vdev_spare_ops);
779 cvd->vdev_ashift = mvd->vdev_ashift;
780
781 vdev_remove_child(mvd, cvd);
782 vdev_remove_child(pvd, mvd);
783
784 /*
785 * If cvd will replace mvd as a top-level vdev, preserve mvd's guid.
786 * Otherwise, we could have detached an offline device, and when we
787 * go to import the pool we'll think we have two top-level vdevs,

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

1115int
1116vdev_open(vdev_t *vd)
1117{
1118 spa_t *spa = vd->vdev_spa;
1119 int error;
1120 uint64_t osize = 0;
1121 uint64_t max_osize = 0;
1122 uint64_t asize, max_asize, psize;
1123 uint64_t ashift = 0;
1124
1125 ASSERT(vd->vdev_open_thread == curthread ||
1126 spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL);
1127 ASSERT(vd->vdev_state == VDEV_STATE_CLOSED ||
1128 vd->vdev_state == VDEV_STATE_CANT_OPEN ||
1129 vd->vdev_state == VDEV_STATE_OFFLINE);
1130
1131 vd->vdev_stat.vs_aux = VDEV_AUX_NONE;

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

1145 vd->vdev_label_aux);
1146 return (SET_ERROR(ENXIO));
1147 } else if (vd->vdev_offline) {
1148 ASSERT(vd->vdev_children == 0);
1149 vdev_set_state(vd, B_TRUE, VDEV_STATE_OFFLINE, VDEV_AUX_NONE);
1150 return (SET_ERROR(ENXIO));
1151 }
1152
1153 error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize, &ashift);
1154
1155 /*
1156 * Reset the vdev_reopening flag so that we actually close
1157 * the vdev on error.
1158 */
1159 vd->vdev_reopening = B_FALSE;
1160 if (zio_injection_enabled && error == 0)
1161 error = zio_handle_device_injection(vd, NULL, ENXIO);

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

1243 * Make sure the allocatable size hasn't shrunk.
1244 */
1245 if (asize < vd->vdev_min_asize) {
1246 vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
1247 VDEV_AUX_BAD_LABEL);
1248 return (SET_ERROR(EINVAL));
1249 }
1250
1251 if (vd->vdev_asize == 0) {
1252 /*
1253 * This is the first-ever open, so use the computed values.
1254 * For testing purposes, a higher ashift can be requested.
1255 */
1256 vd->vdev_asize = asize;
1257 vd->vdev_max_asize = max_asize;
1258 vd->vdev_ashift = MAX(ashift, vd->vdev_ashift);
1259 } else {
1260 /*
1261 * Detect if the alignment requirement has increased.
1262 * We don't want to make the pool unavailable, just
1263 * issue a warning instead.
1264 */
1265 if (ashift > vd->vdev_top->vdev_ashift &&
1266 vd->vdev_ops->vdev_op_leaf) {
1267 cmn_err(CE_WARN,
1268 "Disk, '%s', has a block alignment that is "
1269 "larger than the pool's alignment\n",
1270 vd->vdev_path);
1271 }
1272 vd->vdev_max_asize = max_asize;
1273 }
1274
1275 /*
1276 * If all children are healthy and the asize has increased,
1277 * then we've experienced dynamic LUN growth. If automatic
1278 * expansion is enabled then use the additional space.

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

1572{
1573 /*
1574 * Aim for roughly 200 metaslabs per vdev.
1575 */
1576 vd->vdev_ms_shift = highbit(vd->vdev_asize / 200);
1577 vd->vdev_ms_shift = MAX(vd->vdev_ms_shift, SPA_MAXBLOCKSHIFT);
1578}
1579
1580void
1581vdev_dirty(vdev_t *vd, int flags, void *arg, uint64_t txg)
1582{
1583 ASSERT(vd == vd->vdev_top);
1584 ASSERT(!vd->vdev_ishole);
1585 ASSERT(ISP2(flags));
1586 ASSERT(spa_writeable(vd->vdev_spa));
1587
1588 if (flags & VDD_METASLAB)

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

2590 mutex_enter(&vd->vdev_stat_lock);
2591 bcopy(&vd->vdev_stat, vs, sizeof (*vs));
2592 vs->vs_timestamp = gethrtime() - vs->vs_timestamp;
2593 vs->vs_state = vd->vdev_state;
2594 vs->vs_rsize = vdev_get_min_asize(vd);
2595 if (vd->vdev_ops->vdev_op_leaf)
2596 vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
2597 vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize;
2598 mutex_exit(&vd->vdev_stat_lock);
2599
2600 /*
2601 * If we're getting stats on the root vdev, aggregate the I/O counts
2602 * over all top-level vdevs (i.e. the direct children of the root).
2603 */
2604 if (vd == rvd) {
2605 for (int c = 0; c < rvd->vdev_children; c++) {

--- 714 unchanged lines hidden ---