iscsi-scst: Fix a race condition triggered by logout

This patch fixes the following crash:

general protection fault: 0000 [#1] PREEMPT SMP
Modules linked in: scst_local(O) iscsi_scst(O) scst_vdisk(O) libcrc32c scst(O) brd netconsole target_core_mod configfs fcoe libfcoe libfc scsi_transport_fc scsi_tgt ib_iser rdma_cm ib_addr iw_cm ib_cm ib_sa ib_mad ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi aesni_intel aes_x86_64 glue_he
lper parport_pc ppdev lrw gf128mul ablk_helper cryptd joydev microcode mperf psmouse i2c_piix4 processor button intel_agp intel_gtt agpgart lp parport hid_generic usbhid hid ext4 jbd2 mbcache floppy ata_piix
CPU: 0 PID: 7735 Comm: iscsiwr3 Tainted: G           O 3.11.0-debug+ #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
task: ffff88000850cfc0 ti: ffff88002ea5c000 task.ti: ffff88002ea5c000
RIP: 0010:[<ffffffffa038dd7b>]  [<ffffffffa038dd7b>] target_del_all_sess+0x9b/0x180 [iscsi_scst]
RSP: 0018:ffff88002ea5dcc0  EFLAGS: 00010286
RAX: 00000000fffffffe RBX: dead0000000fefc0 RCX: 0000000000000001
RDX: ffff88000e609460 RSI: 001e00004f011780 RDI: ffff88000e609460
RBP: ffff88002ea5dce8 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff88000e6093b0
R13: ffff88000e609460 R14: 0000000000000000 R15: ffff88003e948158
FS:  0000000000000000(0000) GS:ffff88000f800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000427248 CR3: 0000000036d64000 CR4: 00000000000407f0
Stack:
 ffff88000e6093b0 ffff88003e85d600 ffff88003e948000 0000000000000030
 0000000000000000 ffff88002ea5dd28 ffffffffa038002b 0000000000000001
 ffff88003e55f880 ffff88002ea5dd28 ffffffffa0384d13 ffff88003e948000
Call Trace:
 [<ffffffffa038002b>] cmnd_tx_end+0x1db/0x1e0 [iscsi_scst]
 [<ffffffffa0384d13>] ? iscsi_do_send+0x23/0x60 [iscsi_scst]
 [<ffffffffa0385021>] iscsi_send+0x2d1/0x480 [iscsi_scst]
 [<ffffffff8104a802>] ? local_bh_enable_ip+0x82/0x110
 [<ffffffffa0380e8f>] ? conn_get+0x1f/0x70 [iscsi_scst]
 [<ffffffffa0385290>] scst_do_job_wr+0xc0/0x2d0 [iscsi_scst]
 [<ffffffffa038560d>] istwr+0x16d/0x2e0 [iscsi_scst]
 [<ffffffff8106a2e0>] ? wake_up_bit+0x40/0x40
 [<ffffffffa03854a0>] ? scst_do_job_wr+0x2d0/0x2d0 [iscsi_scst]
 [<ffffffff81069ea6>] kthread+0xd6/0xe0
 [<ffffffff81069dd0>] ? kthread_create_on_node+0x110/0x110
 [<ffffffff814debfc>] ret_from_fork+0x7c/0xb0
Code: 00 00 49 8b 94 24 b0 00 00 00 48 8b 1a 48 8d b2 c0 ee ff ff 48 81 eb 40 11 00 00 49 39 d5 74 28 44 89 f2 4c 89 e7 e8 15 fd ff ff <48> 8b 8b 40 11 00 00 48 89 de 48 8d 93 40 11 00 00 49 39 d5 48
[  474.156827] RIP  [<ffffffffa038dd7b>] target_del_all_sess+0x9b/0x180 [iscsi_scst]
 RSP <ffff88002ea5dcc0>

Signed-off-by: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5019 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2013-10-03 05:04:15 +00:00
parent 1342a944db
commit b96ab2a8bf

View File

@@ -2911,11 +2911,15 @@ void cmnd_tx_end(struct iscsi_cmnd *cmnd)
if (unlikely(cmnd->should_close_conn)) {
if (cmnd->should_close_all_conn) {
struct iscsi_target *target = cmnd->conn->session->target;
PRINT_INFO("Closing all connections for target %x at "
"initiator's %s request",
cmnd->conn->session->target->tid,
"initiator's %s request", target->tid,
conn->session->initiator_name);
target_del_all_sess(cmnd->conn->session->target, 0);
mutex_lock(&target->target_mutex);
target_del_all_sess(target, 0);
mutex_unlock(&target->target_mutex);
} else {
PRINT_INFO("Closing connection at initiator's %s "
"request", conn->session->initiator_name);