zfs: Fix zvol_cdev_open locking

First open locking changes were correctly applied to zvol_geom_open but
incorrectly applied to zvol_cdev_open, causing spa_namespace_lock to be
held indefinitely.

Make the first open locking in zvol_cdev_open match zvol_geom_open.

This change has been accepted upstream in openzfs/zfs#13016 but is not
yet merged.

Reviewed by:	mav
Fixes:		e92ffd9b62
Sponsored by:	iXsystems, Inc.
This commit is contained in:
Ryan Moeller 2022-01-26 18:33:23 +00:00
parent 9acd521dbd
commit 47e46b1123

View File

@ -928,8 +928,8 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
*/
if (!mutex_owned(&spa_namespace_lock)) {
if (!mutex_tryenter(&spa_namespace_lock)) {
rw_exit(&zvol_state_lock);
mutex_enter(&spa_namespace_lock);
mutex_exit(&zv->zv_state_lock);
rw_exit(&zv->zv_suspend_lock);
kern_yield(PRI_USER);
goto retry;
} else {