mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
OpenZFS 9681 - ztest failure in spa_history_log_internal due to spa_rename()
Authored by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Prakash Surya <prakash.surya@delphix.com> Reviewed by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com> Reviewed by: George Melikov <mail@gmelikov.ru> Reviewed by: Tom Caputi <tcaputi@datto.com> Approved by: Robert Mustacchi <rm@joyent.com> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/9681 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/6aee0ad7 Closes #8041
This commit is contained in:
committed by
Brian Behlendorf
parent
80a91e7469
commit
d637db98e1
@@ -358,7 +358,6 @@ ztest_func_t ztest_fault_inject;
|
||||
ztest_func_t ztest_ddt_repair;
|
||||
ztest_func_t ztest_dmu_snapshot_hold;
|
||||
ztest_func_t ztest_mmp_enable_disable;
|
||||
ztest_func_t ztest_spa_rename;
|
||||
ztest_func_t ztest_scrub;
|
||||
ztest_func_t ztest_dsl_dataset_promote_busy;
|
||||
ztest_func_t ztest_vdev_attach_detach;
|
||||
@@ -414,7 +413,6 @@ ztest_info_t ztest_info[] = {
|
||||
ZTI_INIT(ztest_dmu_snapshot_hold, 1, &zopt_sometimes),
|
||||
ZTI_INIT(ztest_mmp_enable_disable, 1, &zopt_sometimes),
|
||||
ZTI_INIT(ztest_reguid, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_spa_rename, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_scrub, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_spa_upgrade, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_dsl_dataset_promote_busy, 1, &zopt_rarely),
|
||||
@@ -6122,62 +6120,6 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id)
|
||||
VERIFY3U(load, ==, spa_load_guid(spa));
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename the pool to a different name and then rename it back.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
ztest_spa_rename(ztest_ds_t *zd, uint64_t id)
|
||||
{
|
||||
char *oldname, *newname;
|
||||
spa_t *spa;
|
||||
|
||||
if (ztest_opts.zo_mmp_test)
|
||||
return;
|
||||
|
||||
(void) pthread_rwlock_wrlock(&ztest_name_lock);
|
||||
|
||||
oldname = ztest_opts.zo_pool;
|
||||
newname = umem_alloc(strlen(oldname) + 5, UMEM_NOFAIL);
|
||||
(void) strcpy(newname, oldname);
|
||||
(void) strcat(newname, "_tmp");
|
||||
|
||||
/*
|
||||
* Do the rename
|
||||
*/
|
||||
VERIFY3U(0, ==, spa_rename(oldname, newname));
|
||||
|
||||
/*
|
||||
* Try to open it under the old name, which shouldn't exist
|
||||
*/
|
||||
VERIFY3U(ENOENT, ==, spa_open(oldname, &spa, FTAG));
|
||||
|
||||
/*
|
||||
* Open it under the new name and make sure it's still the same spa_t.
|
||||
*/
|
||||
VERIFY3U(0, ==, spa_open(newname, &spa, FTAG));
|
||||
|
||||
ASSERT(spa == ztest_spa);
|
||||
spa_close(spa, FTAG);
|
||||
|
||||
/*
|
||||
* Rename it back to the original
|
||||
*/
|
||||
VERIFY3U(0, ==, spa_rename(newname, oldname));
|
||||
|
||||
/*
|
||||
* Make sure it can still be opened
|
||||
*/
|
||||
VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG));
|
||||
|
||||
ASSERT(spa == ztest_spa);
|
||||
spa_close(spa, FTAG);
|
||||
|
||||
umem_free(newname, strlen(newname) + 1);
|
||||
|
||||
(void) pthread_rwlock_unlock(&ztest_name_lock);
|
||||
}
|
||||
|
||||
void
|
||||
ztest_fletcher(ztest_ds_t *zd, uint64_t id)
|
||||
{
|
||||
@@ -7399,7 +7341,6 @@ main(int argc, char **argv)
|
||||
ztest_shared_callstate_t *zc;
|
||||
char timebuf[100];
|
||||
char numbuf[NN_NUMBUF_SZ];
|
||||
spa_t *spa;
|
||||
char *cmd;
|
||||
boolean_t hasalt;
|
||||
int f;
|
||||
@@ -7601,24 +7542,6 @@ main(int argc, char **argv)
|
||||
(void) printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possible that we killed a child during a rename test,
|
||||
* in which case we'll have a 'ztest_tmp' pool lying around
|
||||
* instead of 'ztest'. Do a blind rename in case this happened.
|
||||
*/
|
||||
kernel_init(FREAD);
|
||||
if (spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0) {
|
||||
spa_close(spa, FTAG);
|
||||
} else {
|
||||
char tmpname[ZFS_MAX_DATASET_NAME_LEN];
|
||||
kernel_fini();
|
||||
kernel_init(FREAD | FWRITE);
|
||||
(void) snprintf(tmpname, sizeof (tmpname), "%s_tmp",
|
||||
ztest_opts.zo_pool);
|
||||
(void) spa_rename(tmpname, ztest_opts.zo_pool);
|
||||
}
|
||||
kernel_fini();
|
||||
|
||||
if (!ztest_opts.zo_mmp_test)
|
||||
ztest_run_zdb(ztest_opts.zo_pool);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user