From patchwork Wed Jan 15 20:28:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3493651 X-Patchwork-Delegate: hal@mellanox.com 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 9084E9F32F for ; Wed, 15 Jan 2014 20:28:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB96B20155 for ; Wed, 15 Jan 2014 20:28:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D223220154 for ; Wed, 15 Jan 2014 20:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751637AbaAOU2p (ORCPT ); Wed, 15 Jan 2014 15:28:45 -0500 Received: from mail-ea0-f173.google.com ([209.85.215.173]:48124 "EHLO mail-ea0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbaAOU2o (ORCPT ); Wed, 15 Jan 2014 15:28:44 -0500 Received: by mail-ea0-f173.google.com with SMTP id o10so706583eaj.32 for ; Wed, 15 Jan 2014 12:28:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=I6zV37vLGaHtWbWJVmQ+bOIsvKQVge5OEXK0YQRPPyM=; b=cr2KJlgWwLzBH7NE3jdbCMUSpZYn3yeXDpZT/0DOMi8hK1xl8REoHXdHfEx3bf1sZS 2TAy98lOT1N6Vx650noRCUIiFkaG4gGPd0iWGlGSrmSEgxWUSo5NolYNHSx6vHjGz+B4 Zscot5Bjp5YfyxAsMDXy3+8xEwB8O7mQVVCyPUIp7Z8kXPg8002unW9TuS/6LMehSz1g mewZVGS/hSzkH/MiCDdmKGMkk7o3613wQKnhMI9mGs6lRCbDIBM0AhR/7bbQiPkYamgF 5BquIkZjCWHGKuZVrqsUJLWeRl8dfDqJseQkXXrWKpZ0yf0izeAW4RyYRBjW9Jyi2Cht euGg== X-Gm-Message-State: ALoCoQny9u/EveeP/e/fo1vmSoUxz4s4RTy3+Gzu0LxrlpCLrS8RyOWQeCh6iquM7LGNTLeVOXYS X-Received: by 10.14.212.69 with SMTP id x45mr6493182eeo.69.1389817723196; Wed, 15 Jan 2014 12:28:43 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id m1sm13070836eeg.0.2014.01.15.12.28.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 12:28:42 -0800 (PST) Message-ID: <52D6EF79.4090204@dev.mellanox.co.il> Date: Wed, 15 Jan 2014 15:28:41 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH opensm 2/4] osm_trap_rcv.c: In trap_rcv_process_request, change, locking strategy 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.2 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 1418f8a2673162fa888cf42f51ca5c4890dde3e8 Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Thu, 18 Oct 2012 17:59:04 +0200 Subject: [PATCH 2/4] osm_trap_rcv.c: In trap_rcv_process_request, change locking strategy RW lock is only needed for trap 145 when modifying SystemImageGUID Scope of holding RO lock holding fixes original reported issue with trap 144 for port disconnected during this code flow Signed-off-by: Hal Rosenstock --- opensm/osm_trap_rcv.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c index 9d7ed74..27f3e4a 100644 --- a/opensm/osm_trap_rcv.c +++ b/opensm/osm_trap_rcv.c @@ -447,7 +447,7 @@ static void trap_rcv_process_request(IN osm_sm_t * sm, } osm_dump_notice_v2(sm->p_log, p_ntci, FILE_ID, OSM_LOG_VERBOSE); - CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); + CL_PLOCK_ACQUIRE(sm->p_lock); p_physp = osm_get_physp_by_mad_addr(sm->p_log, sm->p_subn, &tmp_madw.mad_addr); if (p_physp) @@ -555,11 +555,18 @@ static void trap_rcv_process_request(IN osm_sm_t * sm, "trap 144: \"node description update\"\n"); goto check_sweep; } else if (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_SYS_IMG_GUID_CHANGED_TRAP) { - if (p_physp) - /* this assumes that trap 145 content is not broken? */ - p_physp->p_node->node_info.sys_guid = - p_ntci->data_details.ntc_145.new_sys_guid; - else + if (p_physp) { + CL_PLOCK_RELEASE(sm->p_lock); + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); + p_physp = osm_get_physp_by_mad_addr(sm->p_log, + sm->p_subn, + &tmp_madw.mad_addr); + if (p_physp) { + /* this assumes that trap 145 content is not broken? */ + p_physp->p_node->node_info.sys_guid = + p_ntci->data_details.ntc_145.new_sys_guid; + } + } else OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3813: No physical port found for " "trap 145: \"SystemImageGUID update\"\n");