From patchwork Mon Feb 24 14:30:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 3709561 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 B18779F2ED for ; Mon, 24 Feb 2014 14:30:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A685920160 for ; Mon, 24 Feb 2014 14:30:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4EF720120 for ; Mon, 24 Feb 2014 14:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752930AbaBXOaf (ORCPT ); Mon, 24 Feb 2014 09:30:35 -0500 Received: from mailp.voltaire.com ([193.47.165.129]:37702 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752516AbaBXOad (ORCPT ); Mon, 24 Feb 2014 09:30:33 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from sagig@mellanox.com) with SMTP; 24 Feb 2014 16:30:21 +0200 Received: from r-vnc02.mtr.labs.mlnx (r-vnc02.mtr.labs.mlnx [172.30.0.127]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s1OEUL1P028336; Mon, 24 Feb 2014 16:30:21 +0200 Received: from r-vnc02.mtr.labs.mlnx (r-vnc02 [127.0.0.1]) by r-vnc02.mtr.labs.mlnx (8.14.4/8.14.4) with ESMTP id s1OEULuD030680; Mon, 24 Feb 2014 16:30:21 +0200 Received: (from sagig@localhost) by r-vnc02.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id s1OEUKXs030678; Mon, 24 Feb 2014 16:30:20 +0200 From: Sagi Grimberg To: bvanassche@acm.org Cc: roland@kernel.org, oren@mellanox.com, linux-rdma@vger.kernel.org, Vu Pham Subject: [PATCH v1 3/3] IB/srp: Protect free_tx iu list from concurrent flows Date: Mon, 24 Feb 2014 16:30:18 +0200 Message-Id: <1393252218-30638-4-git-send-email-sagig@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1393252218-30638-1-git-send-email-sagig@mellanox.com> References: <1393252218-30638-1-git-send-email-sagig@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=-6.9 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: Vu Pham srp_reconnect_rport() serializes calls of srp_rport_reconnect() with srp_queuecommand(), srp_abort(), srp_reset_device(), srp_reset_host() via rport->mutex and also blocks srp_queuecommand(); however, it cannot block scsi error handler commands (stu, tur). This may introduces corruption in free_tx IUs list and IU itself Signed-off-by: Vu Pham Signed-off-by: Sagi Grimberg --- drivers/infiniband/ulp/srp/ib_srp.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index b615135..656602b 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -859,6 +859,7 @@ static int srp_rport_reconnect(struct srp_rport *rport) { struct srp_target_port *target = rport->lld_data; int i, ret; + unsigned long flags; srp_disconnect_target(target); /* @@ -882,9 +883,11 @@ static int srp_rport_reconnect(struct srp_rport *rport) srp_finish_req(target, req, DID_RESET << 16); } + spin_lock_irqsave(&target->lock, flags); INIT_LIST_HEAD(&target->free_tx); for (i = 0; i < target->queue_size; ++i) list_add(&target->tx_ring[i]->list, &target->free_tx); + spin_unlock_irqrestore(&target->lock, flags); if (ret == 0) ret = srp_connect_target(target);