Files
mirror_zfs/module/os/linux/zfs
Brian Behlendorf 9ec630ff2c 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
2022-02-03 15:28:01 -08:00
..
2021-03-19 21:00:59 -07:00
2019-09-12 13:33:44 -07:00
2019-09-12 13:33:44 -07:00
2020-11-13 13:51:51 -08:00
2021-11-02 09:50:30 -07:00
2021-06-24 13:12:36 -07:00
2020-04-10 10:33:35 -07:00
2021-11-02 09:50:30 -07:00
2021-06-24 13:13:40 -07:00
2021-09-14 14:31:50 -07:00
2021-09-14 15:42:59 -07:00
2022-02-03 15:28:01 -08:00