mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
iscsi-target: Fix iser explicit logout TX kthread leak
commit007d038bdfupstream. This patch fixes a regression introduced with the following commit in v4.0-rc1 code, where an explicit iser-target logout would result in ->tx_thread_active being incorrectly cleared by the logout post handler, and subsequent TX kthread leak: commit88dcd2dab5Author: Nicholas Bellinger <nab@linux-iscsi.org> Date: Thu Feb 26 22:19:15 2015 -0800 iscsi-target: Convert iscsi_thread_set usage to kthread.h To address this bug, change iscsit_logout_post_handler_closesession() and iscsit_logout_post_handler_samecid() to only cmpxchg() on ->tx_thread_active for traditional iscsi/tcp connections. This is required because iscsi/tcp connections are invoking logout post handler logic directly from TX kthread context, while iser connections are invoking logout post handler logic from a seperate workqueue context. Cc: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5f4f44a51d
commit
725dbab305
@@ -4555,7 +4555,18 @@ static void iscsit_logout_post_handler_closesession(
|
||||
struct iscsi_conn *conn)
|
||||
{
|
||||
struct iscsi_session *sess = conn->sess;
|
||||
int sleep = cmpxchg(&conn->tx_thread_active, true, false);
|
||||
int sleep = 1;
|
||||
/*
|
||||
* Traditional iscsi/tcp will invoke this logic from TX thread
|
||||
* context during session logout, so clear tx_thread_active and
|
||||
* sleep if iscsit_close_connection() has not already occured.
|
||||
*
|
||||
* Since iser-target invokes this logic from it's own workqueue,
|
||||
* always sleep waiting for RX/TX thread shutdown to complete
|
||||
* within iscsit_close_connection().
|
||||
*/
|
||||
if (conn->conn_transport->transport_type == ISCSI_TCP)
|
||||
sleep = cmpxchg(&conn->tx_thread_active, true, false);
|
||||
|
||||
atomic_set(&conn->conn_logout_remove, 0);
|
||||
complete(&conn->conn_logout_comp);
|
||||
@@ -4569,7 +4580,10 @@ static void iscsit_logout_post_handler_closesession(
|
||||
static void iscsit_logout_post_handler_samecid(
|
||||
struct iscsi_conn *conn)
|
||||
{
|
||||
int sleep = cmpxchg(&conn->tx_thread_active, true, false);
|
||||
int sleep = 1;
|
||||
|
||||
if (conn->conn_transport->transport_type == ISCSI_TCP)
|
||||
sleep = cmpxchg(&conn->tx_thread_active, true, false);
|
||||
|
||||
atomic_set(&conn->conn_logout_remove, 0);
|
||||
complete(&conn->conn_logout_comp);
|
||||
|
||||
Reference in New Issue
Block a user