X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fspa_misc.c;h=5ec8e688e7898bca588bb9524f120cd573267766;hb=0b4d1b5853791e1e447d74f0b229800d65b53071;hp=440a6addb4d5e6b370f2d36679f7d54a98c9a3c5;hpb=9ae529ec5dbdc828ff8326beae58062971d74b2e;p=zfs.git diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 440a6ad..5ec8e68 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -1334,16 +1334,29 @@ spa_name(spa_t *spa) uint64_t spa_guid(spa_t *spa) { + dsl_pool_t *dp = spa_get_dsl(spa); + uint64_t guid; + /* * If we fail to parse the config during spa_load(), we can go through * the error path (which posts an ereport) and end up here with no root * vdev. We stash the original pool guid in 'spa_config_guid' to handle * this case. */ - if (spa->spa_root_vdev != NULL) + if (spa->spa_root_vdev == NULL) + return (spa->spa_config_guid); + + guid = spa->spa_last_synced_guid != 0 ? + spa->spa_last_synced_guid : spa->spa_root_vdev->vdev_guid; + + /* + * Return the most recently synced out guid unless we're + * in syncing context. + */ + if (dp && dsl_pool_sync_context(dp)) return (spa->spa_root_vdev->vdev_guid); else - return (spa->spa_config_guid); + return (guid); } uint64_t