mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
zpool: Provide GUID to zpool-reguid(8) with -g (#16239)
This commit extends the zpool-reguid(8) command with a -g flag, which allows the user to specify the GUID to set. This change also adds some general tests for zpool-reguid(8). Sponsored-by: Wasabi Technology, Inc. Sponsored-by: Klara, Inc. Signed-off-by: Mateusz Piotrowski <0mp@FreeBSD.org> Reviewed-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
committed by
GitHub
parent
2420ee6e12
commit
6be8bf5552
+22
-3
@@ -1040,16 +1040,34 @@ spa_change_guid_sync(void *arg, dmu_tx_t *tx)
|
||||
* online when we do this, or else any vdevs that weren't present
|
||||
* would be orphaned from our pool. We are also going to issue a
|
||||
* sysevent to update any watchers.
|
||||
*
|
||||
* The GUID of the pool will be changed to the value pointed to by guidp.
|
||||
* The GUID may not be set to the reserverd value of 0.
|
||||
* The new GUID will be generated if guidp is NULL.
|
||||
*/
|
||||
int
|
||||
spa_change_guid(spa_t *spa)
|
||||
spa_change_guid(spa_t *spa, const uint64_t *guidp)
|
||||
{
|
||||
int error;
|
||||
uint64_t guid;
|
||||
int error;
|
||||
|
||||
mutex_enter(&spa->spa_vdev_top_lock);
|
||||
mutex_enter(&spa_namespace_lock);
|
||||
guid = spa_generate_guid(NULL);
|
||||
|
||||
if (guidp != NULL) {
|
||||
guid = *guidp;
|
||||
if (guid == 0) {
|
||||
error = SET_ERROR(EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (spa_guid_exists(guid, 0)) {
|
||||
error = SET_ERROR(EEXIST);
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
guid = spa_generate_guid(NULL);
|
||||
}
|
||||
|
||||
error = dsl_sync_task(spa->spa_name, spa_change_guid_check,
|
||||
spa_change_guid_sync, &guid, 5, ZFS_SPACE_CHECK_RESERVED);
|
||||
@@ -1068,6 +1086,7 @@ spa_change_guid(spa_t *spa)
|
||||
spa_event_notify(spa, NULL, NULL, ESC_ZFS_POOL_REGUID);
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_exit(&spa_namespace_lock);
|
||||
mutex_exit(&spa->spa_vdev_top_lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user