* Mark a top-level vdev's config as dirty, placing it on the dirty list * so that it will be written out next time the vdev configuration is synced. * If the root vdev is specified (vdev_top == NULL), dirty all top-level vdevs. */
| 4566 | * If the root vdev is specified (vdev_top == NULL), dirty all top-level vdevs. |
| 4567 | */ |
| 4568 | void |
| 4569 | vdev_config_dirty(vdev_t *vd) |
| 4570 | { |
| 4571 | spa_t *spa = vd->vdev_spa; |
| 4572 | vdev_t *rvd = spa->spa_root_vdev; |
| 4573 | int c; |
| 4574 | |
| 4575 | ASSERT(spa_writeable(spa)); |
| 4576 | |
| 4577 | /* |
| 4578 | * If this is an aux vdev (as with l2cache and spare devices), then we |
| 4579 | * update the vdev config manually and set the sync flag. |
| 4580 | */ |
| 4581 | if (vd->vdev_aux != NULL) { |
| 4582 | spa_aux_vdev_t *sav = vd->vdev_aux; |
| 4583 | nvlist_t **aux; |
| 4584 | uint_t naux; |
| 4585 | |
| 4586 | for (c = 0; c < sav->sav_count; c++) { |
| 4587 | if (sav->sav_vdevs[c] == vd) |
| 4588 | break; |
| 4589 | } |
| 4590 | |
| 4591 | if (c == sav->sav_count) { |
| 4592 | /* |
| 4593 | * We're being removed. There's nothing more to do. |
| 4594 | */ |
| 4595 | ASSERT(sav->sav_sync == B_TRUE); |
| 4596 | return; |
| 4597 | } |
| 4598 | |
| 4599 | sav->sav_sync = B_TRUE; |
| 4600 | |
| 4601 | if (nvlist_lookup_nvlist_array(sav->sav_config, |
| 4602 | ZPOOL_CONFIG_L2CACHE, &aux, &naux) != 0) { |
| 4603 | VERIFY(nvlist_lookup_nvlist_array(sav->sav_config, |
| 4604 | ZPOOL_CONFIG_SPARES, &aux, &naux) == 0); |
| 4605 | } |
| 4606 | |
| 4607 | ASSERT(c < naux); |
| 4608 | |
| 4609 | /* |
| 4610 | * Setting the nvlist in the middle if the array is a little |
| 4611 | * sketchy, but it will work. |
| 4612 | */ |
| 4613 | nvlist_free(aux[c]); |
| 4614 | aux[c] = vdev_config_generate(spa, vd, B_TRUE, 0); |
| 4615 | |
| 4616 | return; |
| 4617 | } |
| 4618 | |
| 4619 | /* |
| 4620 | * The dirty list is protected by the SCL_CONFIG lock. The caller |
| 4621 | * must either hold SCL_CONFIG as writer, or must be the sync thread |
| 4622 | * (which holds SCL_CONFIG as reader). There's only one sync thread, |
| 4623 | * so this is sufficient to ensure mutual exclusion. |
| 4624 | */ |
| 4625 | ASSERT(spa_config_held(spa, SCL_CONFIG, RW_WRITER) || |
no test coverage detected