Skip to content

Commit

Permalink
zvol: Fix suspend lock leaks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
markjdb committed Jul 9, 2024
1 parent 326040b commit f90eb24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/os/freebsd/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
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 {
Expand Down Expand Up @@ -983,6 +984,7 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
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 {
Expand Down
1 change: 1 addition & 0 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ zvol_open(struct block_device *bdev, fmode_t flag)
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();
Expand Down

0 comments on commit f90eb24

Please sign in to comment.