From 32ca0a7846d0f7f92c15c23dd6ed7f6f085124fa Mon Sep 17 00:00:00 2001 From: Israel Rukshin Date: Wed, 17 Aug 2016 07:27:15 +0000 Subject: [PATCH] isert: fix a possible extra refcount put of isert connection On login logout stress we can start a teardown flow before connection is fully established. In this case we have one less refcount on isert connection. Signed-off-by: Israel Rukshin git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6937 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser.h | 1 + iscsi-scst/kernel/isert-scst/iser_rdma.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/kernel/isert-scst/iser.h b/iscsi-scst/kernel/isert-scst/iser.h index eeb8040fc..501fcf7d0 100644 --- a/iscsi-scst/kernel/isert-scst/iser.h +++ b/iscsi-scst/kernel/isert-scst/iser.h @@ -160,6 +160,7 @@ struct isert_cq { #define ISERT_DRAIN_POSTED 1 #define ISERT_DRAIN_FAILED 2 #define ISERT_DISCON_CALLED 3 +#define ISERT_CONNECTION_EST 4 struct isert_connection { struct iscsi_conn iscsi ____cacheline_aligned; diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index c856f15d5..d78e2e08b 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -599,7 +599,10 @@ static void isert_conn_closed_do_work(struct work_struct *work) if (!test_and_set_bit(ISERT_DISCON_CALLED, &isert_conn->flags)) isert_connection_closed(&isert_conn->iscsi); - isert_conn_free(isert_conn); + /* if connection established we have another refcount */ + if (test_bit(ISERT_CONNECTION_EST, &isert_conn->flags)) { + isert_conn_free(isert_conn); + } } static void isert_sched_conn_closed(struct isert_connection *isert_conn) @@ -1480,6 +1483,8 @@ static int isert_cm_connect_handler(struct rdma_cm_id *cm_id, goto out; } + set_bit(ISERT_CONNECTION_EST, &isert_conn->flags); + if (push_saved_pdu) { pr_info("iser push saved rx pdu\n"); isert_recv_completion_handler(isert_conn->saved_wr);