From 4367312760612cb755acfc218ffeda8eb35ce509 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 10 Jul 2024 16:27:44 -0500 Subject: [PATCH] zvol: Fix suspend lock leaks (#16270) 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 Reviewed-by: Allan Jude Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Reviewed-by: Tony Hutter --- module/os/freebsd/zfs/zvol_os.c | 2 ++ module/os/linux/zfs/zvol_os.c | 1 + 2 files changed, 3 insertions(+) diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 712ff1b837..38e9debbe8 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -292,6 +292,7 @@ retry: if (!mutex_tryenter(&spa_namespace_lock)) { mutex_exit(&zv->zv_state_lock); rw_exit(&zv->zv_suspend_lock); + drop_suspend = B_FALSE; kern_yield(PRI_USER); goto retry; } else { @@ -983,6 +984,7 @@ retry: if (!mutex_tryenter(&spa_namespace_lock)) { mutex_exit(&zv->zv_state_lock); rw_exit(&zv->zv_suspend_lock); + drop_suspend = B_FALSE; kern_yield(PRI_USER); goto retry; } else { diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index acb42c3b4a..1d5d54b80e 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -791,6 +791,7 @@ retry: if (!mutex_tryenter(&spa_namespace_lock)) { mutex_exit(&zv->zv_state_lock); rw_exit(&zv->zv_suspend_lock); + drop_suspend = B_FALSE; #ifdef HAVE_BLKDEV_GET_ERESTARTSYS schedule();