579 case VDEV_LABEL_REPLACE:
580 return (!spa_has_spare(spa, device_guid) ||
581 spare_pool != 0ULL);
582
583 case VDEV_LABEL_SPARE:
584 return (spa_has_spare(spa, device_guid));
585 }
586 }
587
588 /*
589 * Check to see if this is an l2cache device.
590 */
591 if (spa_l2cache_exists(device_guid, NULL))
592 return (B_TRUE);
593
594 /*
595 * We can't rely on a pool's state if it's been imported
596 * read-only. Instead we look to see if the pools is marked
597 * read-only in the namespace and set the state to active.
598 */
599 if ((spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
600 spa_mode(spa) == FREAD)
601 state = POOL_STATE_ACTIVE;
602
603 /*
604 * If the device is marked ACTIVE, then this device is in use by another
605 * pool on the system.
606 */
607 return (state == POOL_STATE_ACTIVE);
608 }
609
610 /*
611 * Initialize a vdev label. We check to make sure each leaf device is not in
612 * use, and writable. We put down an initial label which we will later
613 * overwrite with a complete label. Note that it's important to do this
614 * sequentially, not in parallel, so that we catch cases of multiple use of the
615 * same leaf vdev in the vdev we're creating -- e.g. mirroring a disk with
616 * itself.
617 */
618 int
619 vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
|
579 case VDEV_LABEL_REPLACE:
580 return (!spa_has_spare(spa, device_guid) ||
581 spare_pool != 0ULL);
582
583 case VDEV_LABEL_SPARE:
584 return (spa_has_spare(spa, device_guid));
585 }
586 }
587
588 /*
589 * Check to see if this is an l2cache device.
590 */
591 if (spa_l2cache_exists(device_guid, NULL))
592 return (B_TRUE);
593
594 /*
595 * We can't rely on a pool's state if it's been imported
596 * read-only. Instead we look to see if the pools is marked
597 * read-only in the namespace and set the state to active.
598 */
599 if (state != POOL_STATE_SPARE && state != POOL_STATE_L2CACHE &&
600 (spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
601 spa_mode(spa) == FREAD)
602 state = POOL_STATE_ACTIVE;
603
604 /*
605 * If the device is marked ACTIVE, then this device is in use by another
606 * pool on the system.
607 */
608 return (state == POOL_STATE_ACTIVE);
609 }
610
611 /*
612 * Initialize a vdev label. We check to make sure each leaf device is not in
613 * use, and writable. We put down an initial label which we will later
614 * overwrite with a complete label. Note that it's important to do this
615 * sequentially, not in parallel, so that we catch cases of multiple use of the
616 * same leaf vdev in the vdev we're creating -- e.g. mirroring a disk with
617 * itself.
618 */
619 int
620 vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
|