diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index d5ba0d93a5..a2a71cf0f9 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -185,18 +185,14 @@ zfsdev_close(void *data) zfsdev_state_t *zs = data; ASSERT(zs != NULL); + ASSERT3S(zs->zs_minor, >, 0); - mutex_enter(&zfsdev_state_lock); - - ASSERT(zs->zs_minor != 0); - - zs->zs_minor = -1; zfs_onexit_destroy(zs->zs_onexit); zfs_zevent_destroy(zs->zs_zevent); zs->zs_onexit = NULL; zs->zs_zevent = NULL; - - mutex_exit(&zfsdev_state_lock); + membar_producer(); + zs->zs_minor = -1; } static int diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c index 6f5cff1770..9b7ab647d5 100644 --- a/module/os/linux/zfs/zfs_ioctl_os.c +++ b/module/os/linux/zfs/zfs_ioctl_os.c @@ -136,22 +136,20 @@ zfsdev_state_init(struct file *filp) return (0); } -static int +static void zfsdev_state_destroy(struct file *filp) { - zfsdev_state_t *zs; + zfsdev_state_t *zs = filp->private_data; - ASSERT(MUTEX_HELD(&zfsdev_state_lock)); - ASSERT(filp->private_data != NULL); + ASSERT(zs != NULL); + ASSERT3S(zs->zs_minor, >, 0); - zs = filp->private_data; - zs->zs_minor = -1; zfs_onexit_destroy(zs->zs_onexit); zfs_zevent_destroy(zs->zs_zevent); zs->zs_onexit = NULL; zs->zs_zevent = NULL; - - return (0); + membar_producer(); + zs->zs_minor = -1; } static int @@ -169,13 +167,9 @@ zfsdev_open(struct inode *ino, struct file *filp) static int zfsdev_release(struct inode *ino, struct file *filp) { - int error; + zfsdev_state_destroy(filp); - mutex_enter(&zfsdev_state_lock); - error = zfsdev_state_destroy(filp); - mutex_exit(&zfsdev_state_lock); - - return (-error); + return (0); } static long