On 05/23/2017 06:48 PM, Bart Van Assche wrote: > Move the target_depend_item() call out of the critical section. > This patch avoids that lockdep reports the following: > > ====================================================== > [ INFO: possible circular locking dependency detected ] > 4.10.0-rc4-debug+ #1 Not tainted > ------------------------------------------------------- > rmdir/1799 is trying to acquire lock: > (&sess->cmdsn_mutex){+.+.+.}, at: [<ffffffffa02dc45d>] iscsit_free_all_ooo_cmdsns+0x2d/0xb0 [iscsi_target_mod] > > but task is already holding lock: > (&sb->s_type->i_mutex_key#15){++++++}, at: [<ffffffff811c58c0>] vfs_rmdir+0x50/0x140 > > which lock already depends on the new lock. > > the existing dependency chain (in reverse order) is: > > -> #2 (&sb->s_type->i_mutex_key#15){++++++}: > > [<ffffffff810b4731>] lock_acquire+0x71/0x90 > [<ffffffff8167eacf>] down_write+0x3f/0x70 > [<ffffffffa025315a>] configfs_depend_item+0x3a/0xb0 [configfs] > [<ffffffffa0264053>] target_depend_item+0x13/0x20 [target_core_mod] > [<ffffffffa02891db>] target_xcopy_locate_se_dev_e4+0xdb/0x1a0 [target_core_mod] > [<ffffffffa0289e6c>] target_do_xcopy+0x31c/0x8b0 [target_core_mod] > [<ffffffffa027d9a2>] __target_execute_cmd+0x22/0xa0 [target_core_mod] > [<ffffffffa027e409>] target_execute_cmd.part.20+0x1e9/0x290 [target_core_mod] > [<ffffffffa027e4c3>] target_execute_cmd+0x13/0x20 [target_core_mod] > [<ffffffffa02dc2d2>] iscsit_execute_cmd+0x1d2/0x230 [iscsi_target_mod] > [<ffffffffa02e4acb>] iscsit_sequence_cmd+0x10b/0x190 [iscsi_target_mod] > [<ffffffffa02eb01d>] iscsit_get_rx_pdu+0x37d/0xcd0 [iscsi_target_mod] > [<ffffffffa02ec93e>] iscsi_target_rx_thread+0x6e/0xa0 [iscsi_target_mod] > [<ffffffff810828c2>] kthread+0x102/0x140 > [<ffffffff81681b21>] ret_from_fork+0x31/0x40 > > -> #1 (g_device_mutex){+.+...}: > > [<ffffffff810b4731>] lock_acquire+0x71/0x90 > [<ffffffff8167c49f>] mutex_lock_nested+0x5f/0x670 > [<ffffffffa0289123>] target_xcopy_locate_se_dev_e4+0x23/0x1a0 [target_core_mod] > [<ffffffffa0289e6c>] target_do_xcopy+0x31c/0x8b0 [target_core_mod] > [<ffffffffa027d9a2>] __target_execute_cmd+0x22/0xa0 [target_core_mod] > [<ffffffffa027e409>] target_execute_cmd.part.20+0x1e9/0x290 [target_core_mod] > [<ffffffffa027e4c3>] target_execute_cmd+0x13/0x20 [target_core_mod] > [<ffffffffa02dc2d2>] iscsit_execute_cmd+0x1d2/0x230 [iscsi_target_mod] > [<ffffffffa02e4acb>] iscsit_sequence_cmd+0x10b/0x190 [iscsi_target_mod] > [<ffffffffa02eb01d>] iscsit_get_rx_pdu+0x37d/0xcd0 [iscsi_target_mod] > [<ffffffffa02ec93e>] iscsi_target_rx_thread+0x6e/0xa0 [iscsi_target_mod] > [<ffffffff810828c2>] kthread+0x102/0x140 > [<ffffffff81681b21>] ret_from_fork+0x31/0x40 > > -> #0 (&sess->cmdsn_mutex){+.+.+.}: > > [<ffffffff810b41e6>] __lock_acquire+0x10e6/0x1260 > [<ffffffff810b4731>] lock_acquire+0x71/0x90 > [<ffffffff8167c49f>] mutex_lock_nested+0x5f/0x670 > [<ffffffffa02dc45d>] iscsit_free_all_ooo_cmdsns+0x2d/0xb0 [iscsi_target_mod] > [<ffffffffa02ecc8c>] iscsit_close_session+0xac/0x200 [iscsi_target_mod] > [<ffffffffa02f27af>] lio_tpg_close_session+0x9f/0xb0 [iscsi_target_mod] > [<ffffffffa02796f3>] target_shutdown_sessions+0xc3/0xd0 [target_core_mod] > [<ffffffffa0279cf1>] core_tpg_del_initiator_node_acl+0x91/0x140 [target_core_mod] > [<ffffffffa026c8c0>] target_fabric_nacl_base_release+0x20/0x30 [target_core_mod] > [<ffffffffa02560ca>] config_item_release+0x5a/0xc0 [configfs] > [<ffffffffa025614d>] config_item_put+0x1d/0x1f [configfs] > [<ffffffffa02544d6>] configfs_rmdir+0x1a6/0x300 [configfs] > [<ffffffff811c5927>] vfs_rmdir+0xb7/0x140 > [<ffffffff811cb404>] do_rmdir+0x1f4/0x200 > [<ffffffff811cc131>] SyS_rmdir+0x11/0x20 > [<ffffffff81681885>] entry_SYSCALL_64_fastpath+0x23/0xc6 > > other info that might help us debug this: > > Chain exists of: > &sess->cmdsn_mutex --> g_device_mutex --> &sb->s_type->i_mutex_key#15 > > Possible unsafe locking scenario: > > CPU0 CPU1 > ---- ---- > lock(&sb->s_type->i_mutex_key#15); > lock(g_device_mutex); > lock(&sb->s_type->i_mutex_key#15); > lock(&sess->cmdsn_mutex); > Hey Bart, is the g_device_mutex an issue here? It is not clear to me. It looks like the problem that is reported is that: iscsit_sequence_cmd will grab the cmdsn mutex and then if it is a xcopy command we can end up calling configfs_depend_item which grabs the configfs/fs lock. And, if you remove a acl, it is saying we grab the same configfs/fs lock and then grab the cmdsn_mutex during cleanup, so here we have a issue. -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html