Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp25830pxb; Thu, 15 Apr 2021 21:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnWHONL98c7LF7qedTCsOAropZQQWq2mCgp0dZGKIG+991CHPinOcGXUgcIswwRjqMBoWC X-Received: by 2002:a63:6ec3:: with SMTP id j186mr6398256pgc.249.1618547708656; Thu, 15 Apr 2021 21:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618547708; cv=none; d=google.com; s=arc-20160816; b=fjbmuFMMC0FxqHDK+PQb92nRBTmNj1SKvIQE4TSlL5DPaFdMRvtJWS1X+JuExOhVje Cw3PhpvW9inzXSEtUKT5fOfuN8bLPT+5ADb9tuI4sQtGvC6ObkHzSU5SNkYaay3mBBCt bD3n1y1+Cz2Eyt3/clgFW8zVNnr50heOeg9wH+mr/YyAMtNoZdUlDAyLtkJ2OG3/cf2k 5+qJqIoNsFZ3i0vvlFoxWolXG7B7+R1NtClZXRtAvLJnwRIfw9SM+R9tRXw3gEKW8igK /T2FWAsNnwV2WJK5zAMYqVhcbdgDBsDa5MgTRxhxktskbj2kN2a30r1Y9hv6+Uys5MV9 KXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qRdpiHoavL/giiAlZ2MhLMoCIxtj1P8713oUh2Q7kDY=; b=VTW2IzD35IgJv4ZuRdmQHkcP1JAezKhnDt9dEixIZvwFqqcqJi4Jr05n5Ob5l/Er0r fbCelpgLJUy4rT5pkH9HMiP+RQ55FCaOc+tvI5SKvOum4D3/53WvpDd/xzPO4l4ePAPc 5TX3rj2ApqhnuHzUayPR2YJEhZ/3DyCyEqegv+u0Cf8RVUw8vqccHXnsLOWYhtiJyr+w 6fiwWZ4BqGEtw1Bc08b1LusECpkxYYMhiL3jWaNbKrnDG83RPTJ+KayWl8AYj0XYOaPp L5+P42khn9IXIfyghSxQh1omqpOHDMJtjqF/2gTJbsqTpQsn1NLZ+RRpCXpG6Pk09DrM PlhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ca8u9/Pa"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si5313724pfc.246.2021.04.15.21.34.54; Thu, 15 Apr 2021 21:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ca8u9/Pa"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238296AbhDPDxC (ORCPT + 99 others); Thu, 15 Apr 2021 23:53:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238305AbhDPDxB (ORCPT ); Thu, 15 Apr 2021 23:53:01 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97DD5C061574 for ; Thu, 15 Apr 2021 20:52:36 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id j3so12833809qvs.1 for ; Thu, 15 Apr 2021 20:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qRdpiHoavL/giiAlZ2MhLMoCIxtj1P8713oUh2Q7kDY=; b=ca8u9/PaLRVue3d6jYvwoAfP+m+bwUB/LSlFcOzayHhHA36PtY0nnQMZTsm0StLf48 4F94vOL9+9lHz72eO7Zfa6CLKohR/gSq3geOJlYUHc8kkMnZ4Ow/K7zKpX+OpSswJ/uF cXUy4HnKfEN7suttZoAIzyJqR6iHnNGuZ8E6dqJ2wQ1VI9f0VbA4g+5U+sKmuQsgjogy pZOjTcs5elR4Wb1jlR3xTEXTI1EbV4VKwpl0UyUzNuISuJRqBogDnv1vZWZrrpiC/ktP o3hH2LrdQntQc1HsM5r7fb+OikjvXtc7kr0lFhfDTSbJLHjDp2RYg55Kq90CKVtCO9J8 syfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qRdpiHoavL/giiAlZ2MhLMoCIxtj1P8713oUh2Q7kDY=; b=bP1aW652G/kuEJT3SogtUlihdOsR49U64hsrtOSCX5sEKcFEKSA9Wlopymr4sGg3YZ RMQK5HpiONkzXodYp+uhhQrjvv6PQv4sOaO/j5jag2ZCIcvXCxOSeYdg5J9x+zwavOUX Wih9fb0+paj5IGi3qHB4KEQO6PzLxQvsMo6NrJSumQsjYWBpGpTh1R4c64FRHZVeinbV cvE/13Ly8PwGdYchuueoS/VVdUzweREmj/sM8odv1HQpTI1umcc0H9B7LG6BK/h4D117 7wiVz4p5Bre8MNU6D3E5cpBijlyRLrdVZYczbyYngwu4Zzamiy7MJ1mLltm1QSg6YTd7 GQPg== X-Gm-Message-State: AOAM5309Q+eXykIalYlJUfmCddDG4rS9KpAxkoi6Sq95eOuBTFEfq4Fs ZJFZBVLystRPB4NpqOJGQTB+/iFk+vw= X-Received: by 2002:a0c:e586:: with SMTP id t6mr6570882qvm.40.1618545155805; Thu, 15 Apr 2021 20:52:35 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id x82sm3500913qkb.0.2021.04.15.20.52.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Apr 2021 20:52:35 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 06/13] sunrpc: add IDs to multipath Date: Thu, 15 Apr 2021 23:52:19 -0400 Message-Id: <20210416035226.53588-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210416035226.53588-1-olga.kornievskaia@gmail.com> References: <20210416035226.53588-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia This is used to uniquely identify sunrpc multipath objects in /sys. Signed-off-by: Dan Aloni --- include/linux/sunrpc/xprtmultipath.h | 4 ++++ net/sunrpc/sunrpc_syms.c | 1 + net/sunrpc/xprtmultipath.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index c6cce3fbf29d..ef95a6f18ccf 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -14,6 +14,7 @@ struct rpc_xprt_switch { spinlock_t xps_lock; struct kref xps_kref; + unsigned int xps_id; unsigned int xps_nxprts; unsigned int xps_nactive; atomic_long_t xps_queuelen; @@ -71,4 +72,7 @@ extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi); extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, const struct sockaddr *sap); + +extern void xprt_multipath_cleanup_ids(void); + #endif diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index b61b74c00483..691c0000e9ea 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -134,6 +134,7 @@ cleanup_sunrpc(void) rpc_sysfs_exit(); rpc_cleanup_clids(); xprt_cleanup_ids(); + xprt_multipath_cleanup_ids(); rpcauth_remove_module(); cleanup_socket_xprt(); svc_cleanup_xprt_sock(); diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 78c075a68c04..b71dd95ad7de 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -86,6 +86,30 @@ void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, xprt_put(xprt); } +static DEFINE_IDA(rpc_xprtswitch_ids); + +void xprt_multipath_cleanup_ids(void) +{ + ida_destroy(&rpc_xprtswitch_ids); +} + +static int xprt_switch_alloc_id(struct rpc_xprt_switch *xps) +{ + int id; + + id = ida_simple_get(&rpc_xprtswitch_ids, 0, 0, GFP_KERNEL); + if (id < 0) + return id; + + xps->xps_id = id; + return 0; +} + +static void xprt_switch_free_id(struct rpc_xprt_switch *xps) +{ + ida_simple_remove(&rpc_xprtswitch_ids, xps->xps_id); +} + /** * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch * @xprt: pointer to struct rpc_xprt @@ -103,6 +127,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt, if (xps != NULL) { spin_lock_init(&xps->xps_lock); kref_init(&xps->xps_kref); + xprt_switch_alloc_id(xps); xps->xps_nxprts = xps->xps_nactive = 0; atomic_long_set(&xps->xps_queuelen, 0); xps->xps_net = NULL; @@ -136,6 +161,7 @@ static void xprt_switch_free(struct kref *kref) struct rpc_xprt_switch, xps_kref); xprt_switch_free_entries(xps); + xprt_switch_free_id(xps); kfree_rcu(xps, xps_rcu); } -- 2.27.0