From patchwork Sun Mar 23 20:18:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 3880651 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43F40BF540 for ; Sun, 23 Mar 2014 20:18:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B18F20259 for ; Sun, 23 Mar 2014 20:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CFC92020F for ; Sun, 23 Mar 2014 20:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751001AbaCWUSn (ORCPT ); Sun, 23 Mar 2014 16:18:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:30878 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbaCWUSc (ORCPT ); Sun, 23 Mar 2014 16:18:32 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 23 Mar 2014 13:18:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,715,1389772800"; d="scan'208";a="505038284" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by fmsmga002.fm.intel.com with ESMTP; 23 Mar 2014 13:18:32 -0700 From: sean.hefty@intel.com To: sean.hefty@intel.com, ira.weiny@intel.com, kaike.wan@intel.com, john.fleck@intel.com, linux-rdma@vger.kernel.org Subject: [PATCH 4/9] ibacm: Relocate client refcnt Date: Sun, 23 Mar 2014 13:18:16 -0700 Message-Id: <1395605901-9080-5-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1395605901-9080-1-git-send-email-sean.hefty@intel.com> References: <1395605901-9080-1-git-send-email-sean.hefty@intel.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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Sean Hefty Adjust when we take a reference on the client connection. Increment the client reference when we begin processing the client's request, and release it when the response has been sent. The client reference will no longer be associated with the lifetime of any underlying acm_request structure. This change will allow the acm core to control the client reference count when we move to a provider plug-in model in subsequent patches. Signed-off-by: Sean Hefty --- src/acm.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/acm.c b/src/acm.c index c9e1b3c..4fc650b 100644 --- a/src/acm.c +++ b/src/acm.c @@ -441,7 +441,6 @@ acm_alloc_req(struct acm_client *client, struct acm_msg *msg) return NULL; } - (void) atomic_inc(&client->refcnt); req->client = client; memcpy(&req->msg, msg, sizeof(req->msg)); acm_log(2, "client %d, req %p\n", client->index, req); @@ -452,7 +451,6 @@ static void acm_free_req(struct acm_request *req) { acm_log(2, "%p\n", req); - (void) atomic_dec(&req->client->refcnt); free(req); } @@ -1084,6 +1082,7 @@ acm_client_resolve_resp(struct acm_client *client, struct acm_msg *req_msg, release: lock_release(&client->lock); + (void) atomic_dec(&client->refcnt); return ret; } @@ -1340,6 +1339,7 @@ acm_client_query_resp(struct acm_client *client, release: lock_release(&client->lock); + (void) atomic_dec(&client->refcnt); return ret; } @@ -2311,6 +2311,8 @@ put: static int acm_svr_resolve(struct acm_client *client, struct acm_msg *msg) { + (void) atomic_inc(&client->refcnt); + if (msg->resolve_data[0].type == ACM_EP_INFO_PATH) { if (msg->resolve_data[0].flags & ACM_FLAGS_QUERY_SA) { return acm_svr_query_path(client, msg);