From patchwork Mon Sep 19 17:28:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9340113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E64466077A for ; Mon, 19 Sep 2016 17:28:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8311295B9 for ; Mon, 19 Sep 2016 17:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD0FB295DF; Mon, 19 Sep 2016 17:28:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4779A295B9 for ; Mon, 19 Sep 2016 17:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752452AbcISR2Z (ORCPT ); Mon, 19 Sep 2016 13:28:25 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:29490 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751856AbcISR2Z (ORCPT ); Mon, 19 Sep 2016 13:28:25 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8JHSM2q031716 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Sep 2016 17:28:22 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8JHSMXm025988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Sep 2016 17:28:22 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8JHSM5O021122; Mon, 19 Sep 2016 17:28:22 GMT Received: from yuval-net-srv-ca.us.oracle.com (/10.211.3.188) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Sep 2016 10:28:21 -0700 From: Yuval Shaia To: sean.hefty@intel.com, linux-rdma@vger.kernel.org Subject: [PATCH v2] ibacm: Handle EP expiration time Date: Mon, 19 Sep 2016 10:28:21 -0700 Message-Id: <1474306101-24718-1-git-send-email-yuval.shaia@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Old destination records are removed from EP's dest_map after timeout is expired in order to maintain a correct cache. Signed-off-by: Yuval Shaia --- v0 -> v1: * Move the status and timeout check to acmp_acquire_dest * Fix typo (Record expiered). * Use NULL instead of 0 v1 -> v2: * (uint64_t)~0ULL instead of 0xFFFFFFFFFFFFFFFF * Calculate expiration time once --- prov/acmp/src/acmp.c | 32 +++++++++++++++++++++++--------- 1 files changed, 23 insertions(+), 9 deletions(-) diff --git a/prov/acmp/src/acmp.c b/prov/acmp/src/acmp.c index ec64631..a26ed83 100644 --- a/prov/acmp/src/acmp.c +++ b/prov/acmp/src/acmp.c @@ -356,16 +356,39 @@ acmp_put_dest(struct acmp_dest *dest) } } +/* Caller must hold ep lock. */ +static void +acmp_remove_dest(struct acmp_ep *ep, struct acmp_dest *dest) +{ + acm_log(2, "%s\n", dest->name); + tdelete(dest->address, &ep->dest_map[dest->addr_type - 1], + acmp_compare_dest); + acmp_put_dest(dest); +} + static struct acmp_dest * acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) { struct acmp_dest *dest; + int64_t rec_expr_minutes; acm_format_name(2, log_data, sizeof log_data, addr_type, addr, ACM_MAX_ADDRESS); acm_log(2, "%s\n", log_data); lock_acquire(&ep->lock); dest = acmp_get_dest(ep, addr_type, addr); + if (dest && dest->state == ACMP_READY && + dest->addr_timeout != (uint64_t)~0ULL) { + rec_expr_minutes = dest->addr_timeout - time_stamp_min(); + if (rec_expr_minutes <= 0) { + acm_log(2, "Record expired\n"); + acmp_remove_dest(ep, dest); + dest = NULL; + } else { + acm_log(2, "Record valid for the next %ld minute(s)\n", + rec_expr_minutes); + } + } if (!dest) { dest = acmp_alloc_dest(addr_type, addr); if (dest) { @@ -378,15 +401,6 @@ acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) return dest; } -/* Caller must hold ep lock. */ -//static void -//acmp_remove_dest(struct acmp_ep *ep, struct acmp_dest *dest) -//{ -// acm_log(2, "%s\n", dest->name); -// tdelete(dest->address, &ep->dest_map[dest->addr_type - 1], acmp_compare_dest); -// acmp_put_dest(dest); -//} - static struct acmp_request *acmp_alloc_req(uint64_t id, struct acm_msg *msg) { struct acmp_request *req;