From patchwork Wed Oct 1 11:02:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 5011111 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C99B69F375 for ; Wed, 1 Oct 2014 11:02:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9F5320221 for ; Wed, 1 Oct 2014 11:02:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C3BE2021B for ; Wed, 1 Oct 2014 11:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751222AbaJALCf (ORCPT ); Wed, 1 Oct 2014 07:02:35 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:52861 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751196AbaJALC1 (ORCPT ); Wed, 1 Oct 2014 07:02:27 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from ogerlitz@mellanox.com) with SMTP; 1 Oct 2014 13:02:20 +0200 Received: from r-vnc04.mtr.labs.mlnx (r-vnc04.mtr.labs.mlnx [10.208.0.116]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s91B2Hhd009732; Wed, 1 Oct 2014 14:02:19 +0300 From: Or Gerlitz To: Roland Dreier Cc: linux-rdma@vger.kernel.org, Sagi Grimberg , Roi Dayan , Ariel Nahum , Or Gerlitz Subject: [PATCH for-next 07/21] IB/iser: Unbind at conn_stop stage Date: Wed, 1 Oct 2014 14:02:03 +0300 Message-Id: <1412161337-25285-8-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1412161337-25285-1-git-send-email-ogerlitz@mellanox.com> References: <1412161337-25285-1-git-send-email-ogerlitz@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ariel Nahum Previously we didn't need to unbind the iser_conn and iscsi_conn since we always relied on iscsi daemon to teardown the connection and never let it finish before we cleanup all that is needed in iser. This is not the case anymore (for DEVICE_REMOVAL event). So avoid any possible chance we cause iscsi_conn dereference after iscsi_conn was freed. We also call iser_conn_terminate (safe to call multiple times) just for the corner case of iscsi daemon stopping an old connection before invoking endpoint removal (might happen if it was violently killed). Notice we are unbinding under a lock - which is required. Signed-off-by: Ariel Nahum Signed-off-by: Sagi Grimberg Signed-off-by: Roi Dayan Signed-off-by: Or Gerlitz --- drivers/infiniband/ulp/iser/iscsi_iser.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index db83530..7298e69 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -414,8 +414,15 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) * might have only partially setup the connection. */ if (iser_conn) { + mutex_lock(&iser_conn->state_mutex); + iser_conn_terminate(iser_conn); + + /* unbind */ + iser_conn->iscsi_conn = NULL; conn->dd_data = NULL; + complete(&iser_conn->stop_completion); + mutex_unlock(&iser_conn->state_mutex); } }