spa_misc: add an API for spa_namespace_lock

This is useful as debugging support, as it lets namespace lock
operations be traced directly. It will also be useful for future work to
reduce the use of spa_namespace_lock, traditionally a source of
difficult deadlocks.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17906
This commit is contained in:
Rob Norris
2025-11-11 09:23:39 +11:00
committed by Brian Behlendorf
parent e305c7d596
commit ac0bc4cc00
21 changed files with 260 additions and 204 deletions
+4 -4
View File
@@ -161,7 +161,7 @@ spa_write_cachefile(spa_t *target, boolean_t removing, boolean_t postsysevent,
boolean_t ccw_failure;
int error = 0;
ASSERT(MUTEX_HELD(&spa_namespace_lock));
ASSERT(spa_namespace_held());
if (!(spa_mode_global & SPA_MODE_WRITE))
return;
@@ -287,7 +287,7 @@ spa_all_configs(uint64_t *generation, nvlist_t **pools)
if (*generation == spa_config_generation)
return (SET_ERROR(EEXIST));
int error = mutex_enter_interruptible(&spa_namespace_lock);
int error = spa_namespace_enter_interruptible(FTAG);
if (error)
return (SET_ERROR(EINTR));
@@ -302,7 +302,7 @@ spa_all_configs(uint64_t *generation, nvlist_t **pools)
}
}
*generation = spa_config_generation;
mutex_exit(&spa_namespace_lock);
spa_namespace_exit(FTAG);
return (0);
}
@@ -483,7 +483,7 @@ spa_config_update(spa_t *spa, int what)
uint64_t txg;
int c;
ASSERT(MUTEX_HELD(&spa_namespace_lock));
ASSERT(spa_namespace_held());
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
txg = spa_last_synced_txg(spa) + 1;