Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] libiscsi: fix logout pdu processing

According to the iscsi RFC, we cannot send other requests if
we have sent a logout pdu. This patch enforces this requirement
by blocking the session and suspending the send thread. Userspace
decides if we restart the connection or if we just free everything.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

Mike Christie and committed by
James Bottomley
b5072ea0 5831c737

+23 -2
+23 -2
drivers/scsi/libiscsi.c
··· 578 578 } 579 579 EXPORT_SYMBOL_GPL(iscsi_conn_failure); 580 580 581 + static int iscsi_xmit_imm_task(struct iscsi_conn *conn) 582 + { 583 + struct iscsi_hdr *hdr = conn->mtask->hdr; 584 + int rc, was_logout = 0; 585 + 586 + if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) { 587 + conn->session->state = ISCSI_STATE_IN_RECOVERY; 588 + iscsi_block_session(session_to_cls(conn->session)); 589 + was_logout = 1; 590 + } 591 + rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask); 592 + if (rc) 593 + return rc; 594 + 595 + if (was_logout) { 596 + set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); 597 + return -ENODATA; 598 + } 599 + return 0; 600 + } 601 + 581 602 /** 582 603 * iscsi_data_xmit - xmit any command into the scheduled connection 583 604 * @conn: iscsi connection ··· 644 623 conn->ctask = NULL; 645 624 } 646 625 if (conn->mtask) { 647 - rc = tt->xmit_mgmt_task(conn, conn->mtask); 626 + rc = iscsi_xmit_imm_task(conn); 648 627 if (rc) 649 628 goto again; 650 629 /* done with this in-progress mtask */ ··· 659 638 list_add_tail(&conn->mtask->running, 660 639 &conn->mgmt_run_list); 661 640 spin_unlock_bh(&conn->session->lock); 662 - rc = tt->xmit_mgmt_task(conn, conn->mtask); 641 + rc = iscsi_xmit_imm_task(conn); 663 642 if (rc) 664 643 goto again; 665 644 }