MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ztest_spa_import_export

Function ztest_spa_import_export

freebsd/contrib/openzfs/cmd/ztest/ztest.c:6659–6742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6657}
6658
6659static void
6660ztest_spa_import_export(char *oldname, char *newname)
6661{
6662 nvlist_t *config, *newconfig;
6663 uint64_t pool_guid;
6664 spa_t *spa;
6665 int error;
6666
6667 if (ztest_opts.zo_verbose >= 4) {
6668 (void) printf("import/export: old = %s, new = %s\n",
6669 oldname, newname);
6670 }
6671
6672 /*
6673 * Clean up from previous runs.
6674 */
6675 (void) spa_destroy(newname);
6676
6677 /*
6678 * Get the pool's configuration and guid.
6679 */
6680 VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG));
6681
6682 /*
6683 * Kick off a scrub to tickle scrub/export races.
6684 */
6685 if (ztest_random(2) == 0)
6686 (void) spa_scan(spa, POOL_SCAN_SCRUB);
6687
6688 pool_guid = spa_guid(spa);
6689 spa_close(spa, FTAG);
6690
6691 ztest_walk_pool_directory("pools before export");
6692
6693 /*
6694 * Export it.
6695 */
6696 VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE));
6697
6698 ztest_walk_pool_directory("pools after export");
6699
6700 /*
6701 * Try to import it.
6702 */
6703 newconfig = spa_tryimport(config);
6704 ASSERT(newconfig != NULL);
6705 nvlist_free(newconfig);
6706
6707 /*
6708 * Import it under the new name.
6709 */
6710 error = spa_import(newname, config, NULL, 0);
6711 if (error != 0) {
6712 dump_nvlist(config, 0);
6713 fatal(B_FALSE, "couldn't import pool %s as %s: error %u",
6714 oldname, newname, error);
6715 }
6716

Callers 1

ztest_runFunction · 0.85

Calls 14

spa_destroyFunction · 0.85
spa_openFunction · 0.85
ztest_randomFunction · 0.85
spa_scanFunction · 0.85
spa_guidFunction · 0.85
spa_closeFunction · 0.85
spa_exportFunction · 0.85
spa_tryimportFunction · 0.85
spa_importFunction · 0.85
dump_nvlistFunction · 0.85
fatalFunction · 0.70

Tested by

no test coverage detected