mirror_zfs/module
Brian Behlendorf a4831fa023 Fix zvol_open() lock inversion
When restructuring the zvol_open() logic for the Linux 5.13 kernel
a lock inversion was accidentally introduced.  In the updated code
the spa_namespace_lock is now taken before the zv_suspend_lock
allowing the following scenario to occur:

    down_read <=== waiting for zv_suspend_lock
    zvol_open <=== holds spa_namespace_lock
    __blkdev_get
    blkdev_get_by_dev
    blkdev_open
    ...

     mutex_lock <== waiting for spa_namespace_lock
     spa_open_common
     spa_open
     dsl_pool_hold
     dmu_objset_hold_flags
     dmu_objset_hold
     dsl_prop_get
     dsl_prop_get_integer
     zvol_create_minor
     dmu_recv_end
     zfs_ioc_recv_impl <=== holds zv_suspend_lock via zvol_suspend()
     zfs_ioc_recv
     ...

This commit resolves the issue by moving the acquisition of the
spa_namespace_lock back to after the zv_suspend_lock which restores
the original ordering.

Additionally, as part of this change the error exit paths were
simplified where possible.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12863
2021-12-22 09:31:58 -08:00
..
avl Links in Source Files 2020-09-03 16:17:18 -07:00
icp Extending FreeBSD UIO Struct 2021-11-12 16:31:55 -08:00
lua Use fallthrough macro 2021-11-12 15:24:36 -08:00
nvpair Update checkstyle workflow env to ubuntu-20.04 2021-11-12 16:31:55 -08:00
os Fix zvol_open() lock inversion 2021-12-22 09:31:58 -08:00
spl Cleanup linux module kbuild files 2020-06-10 09:24:15 -07:00
unicode Update checkstyle workflow env to ubuntu-20.04 2021-11-12 16:31:55 -08:00
zcommon Fix AVX512BW Fletcher code on AVX512-but-not-BW machines 2021-06-23 13:22:14 -07:00
zfs ZFS send/recv with ashift 9->12 leads to data corruption 2021-12-07 17:03:17 -08:00
zstd Linux 5.16: Resolve ZSTD_isError symbol collision in Linux kernel 2021-12-07 13:15:12 -08:00
.gitignore Cleanup linux module kbuild files 2020-06-10 09:24:15 -07:00
Kbuild.in Add zstd support to zfs 2020-08-20 10:30:06 -07:00
Makefile.bsd Restore FreeBSD resource usage accounting 2021-03-05 12:50:32 -08:00
Makefile.in Update checkstyle workflow env to ubuntu-20.04 2021-11-12 16:31:55 -08:00