Commit a154f5f
scsi: target: core: Fix deadlock due to recursive locking
The following call trace shows a deadlock issue due to recursive locking of
mutex "device_mutex". First lock acquire is in target_for_each_device() and
second in target_free_device().
PID: 148266 TASK: ffff8be21ffb5d00 CPU: 10 COMMAND: "iscsi_ttx"
#0 [ffffa2bfc9ec3b18] __schedule at ffffffffa8060e7f
#1 [ffffa2bfc9ec3ba0] schedule at ffffffffa8061224
#2 [ffffa2bfc9ec3bb8] schedule_preempt_disabled at ffffffffa80615ee
#3 [ffffa2bfc9ec3bc8] __mutex_lock at ffffffffa8062fd7
#4 [ffffa2bfc9ec3c40] __mutex_lock_slowpath at ffffffffa80631d3
#5 [ffffa2bfc9ec3c50] mutex_lock at ffffffffa806320c
torvalds#6 [ffffa2bfc9ec3c68] target_free_device at ffffffffc0935998 [target_core_mod]
torvalds#7 [ffffa2bfc9ec3c90] target_core_dev_release at ffffffffc092f975 [target_core_mod]
torvalds#8 [ffffa2bfc9ec3ca0] config_item_put at ffffffffa79d250f
torvalds#9 [ffffa2bfc9ec3cd0] config_item_put at ffffffffa79d2583
torvalds#10 [ffffa2bfc9ec3ce0] target_devices_idr_iter at ffffffffc0933f3a [target_core_mod]
torvalds#11 [ffffa2bfc9ec3d00] idr_for_each at ffffffffa803f6fc
torvalds#12 [ffffa2bfc9ec3d60] target_for_each_device at ffffffffc0935670 [target_core_mod]
torvalds#13 [ffffa2bfc9ec3d98] transport_deregister_session at ffffffffc0946408 [target_core_mod]
torvalds#14 [ffffa2bfc9ec3dc8] iscsit_close_session at ffffffffc09a44a6 [iscsi_target_mod]
torvalds#15 [ffffa2bfc9ec3df0] iscsit_close_connection at ffffffffc09a4a88 [iscsi_target_mod]
torvalds#16 [ffffa2bfc9ec3df8] finish_task_switch at ffffffffa76e5d07
torvalds#17 [ffffa2bfc9ec3e78] iscsit_take_action_for_connection_exit at ffffffffc0991c23 [iscsi_target_mod]
torvalds#18 [ffffa2bfc9ec3ea0] iscsi_target_tx_thread at ffffffffc09a403b [iscsi_target_mod]
torvalds#19 [ffffa2bfc9ec3f08] kthread at ffffffffa76d8080
torvalds#20 [ffffa2bfc9ec3f50] ret_from_fork at ffffffffa8200364
Fixes: 36d4cb4 ("scsi: target: Avoid that EXTENDED COPY commands trigger lock inversion")
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Link: https://lore.kernel.org/r/20230918225848.66463-1-junxiao.bi@oracle.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent 2132df1 commit a154f5f
1 file changed
+4
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
846 | | - | |
847 | 846 | | |
848 | 847 | | |
849 | 848 | | |
| |||
853 | 852 | | |
854 | 853 | | |
855 | 854 | | |
| 855 | + | |
856 | 856 | | |
857 | 857 | | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | 858 | | |
862 | 859 | | |
863 | 860 | | |
| |||
867 | 864 | | |
868 | 865 | | |
869 | 866 | | |
870 | | - | |
871 | | - | |
| 867 | + | |
| 868 | + | |
872 | 869 | | |
873 | 870 | | |
874 | 871 | | |
875 | 872 | | |
| 873 | + | |
876 | 874 | | |
877 | 875 | | |
878 | 876 | | |
| |||
895 | 893 | | |
896 | 894 | | |
897 | 895 | | |
898 | | - | |
899 | 896 | | |
900 | 897 | | |
901 | 898 | | |
| |||
0 commit comments