zvol: Fix suspend lock leaks

In several functions, we use a flag variable to track whether
zv_suspend_lock is held.  This flag was not getting reset in a
particular case where we need to retry the underlying operation,
resulting in a lock leak.  Make sure to update the flag where necessary.

Signed-off-by: Mark Johnston <markj@FreeBSD.org>
This commit is contained in:
Mark Johnston 2024-06-15 10:24:51 -04:00
parent 326040b285
commit f90eb245fd
2 changed files with 3 additions and 0 deletions

View File

@ -292,6 +292,7 @@ retry:
if (!mutex_tryenter(&spa_namespace_lock)) { if (!mutex_tryenter(&spa_namespace_lock)) {
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
drop_suspend = B_FALSE;
kern_yield(PRI_USER); kern_yield(PRI_USER);
goto retry; goto retry;
} else { } else {
@ -983,6 +984,7 @@ retry:
if (!mutex_tryenter(&spa_namespace_lock)) { if (!mutex_tryenter(&spa_namespace_lock)) {
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
drop_suspend = B_FALSE;
kern_yield(PRI_USER); kern_yield(PRI_USER);
goto retry; goto retry;
} else { } else {

View File

@ -791,6 +791,7 @@ retry:
if (!mutex_tryenter(&spa_namespace_lock)) { if (!mutex_tryenter(&spa_namespace_lock)) {
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
drop_suspend = B_FALSE;
#ifdef HAVE_BLKDEV_GET_ERESTARTSYS #ifdef HAVE_BLKDEV_GET_ERESTARTSYS
schedule(); schedule();