mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Race condition between spa async threads and export
In the past we've seen multiple race conditions that have to do with open-context threads async threads and concurrent calls to spa_export()/spa_destroy() (including the one referenced in issue #9015). This patch ensures that only one thread can execute the main body of spa_export_common() at a time, with subsequent threads returning with a new error code created just for this situation, eliminating this way any race condition bugs introduced by concurrent calls to this function. Reviewed by: Matt Ahrens <matt@delphix.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com> Closes #9015 Closes #9044
This commit is contained in:
committed by
Brian Behlendorf
parent
1c44a5c97f
commit
43a8536260
+17
-1
@@ -2719,8 +2719,24 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
|
||||
VERIFY3U(EEXIST, ==,
|
||||
spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL));
|
||||
nvlist_free(nvroot);
|
||||
|
||||
/*
|
||||
* We open a reference to the spa and then we try to export it
|
||||
* expecting one of the following errors:
|
||||
*
|
||||
* EBUSY
|
||||
* Because of the reference we just opened.
|
||||
*
|
||||
* ZFS_ERR_EXPORT_IN_PROGRESS
|
||||
* For the case that there is another ztest thread doing
|
||||
* an export concurrently.
|
||||
*/
|
||||
VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
|
||||
VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool));
|
||||
int error = spa_destroy(zo->zo_pool);
|
||||
if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) {
|
||||
fatal(0, "spa_destroy(%s) returned unexpected value %d",
|
||||
spa->spa_name, error);
|
||||
}
|
||||
spa_close(spa, FTAG);
|
||||
|
||||
(void) pthread_rwlock_unlock(&ztest_name_lock);
|
||||
|
||||
Reference in New Issue
Block a user