From patchwork Fri Aug 27 18:37:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12462669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36DB8C4320A for ; Fri, 27 Aug 2021 18:37:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E49F60FC4 for ; Fri, 27 Aug 2021 18:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbhH0SiS (ORCPT ); Fri, 27 Aug 2021 14:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbhH0SiS (ORCPT ); Fri, 27 Aug 2021 14:38:18 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12846C061757 for ; Fri, 27 Aug 2021 11:37:29 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id u21so6085430qtw.8 for ; Fri, 27 Aug 2021 11:37:29 -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=koi2dAiEUZGWQ61rcZsKU0jg5BRUtQ/tg2nRQ2aR2zE=; b=AhVKSuR225KNBMqmD+rg4d1zKvIjlBuFNBw+XJnQjEHcCvxf5ypn4dyINDk5Nnn+Oq o7S5vrbB3A0YlUzrBAeif0OeE4xatj5Ev2JSFUk5sXpPqTiMJij1C8AeS6WhZ4/egvhf RB4C8NegWcmUH1HctXXfq1i1lZ+qW1aAiOIoFmhougP2cqTnL8YEq1oeD4X7Iv/z+SMN VwUxL9DKIBGYGrYLewXfE9BTmZVsxzbBouyY4X1bU1v+1rhZsreLeM9EGQoeO+1CaQI6 feb1lRkpUduIK+RborDy0rfRdgzgFCXTphwtYbKqLQlsKhtM4+YCxbMjfAi+hDOSXIrR G2uA== 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=koi2dAiEUZGWQ61rcZsKU0jg5BRUtQ/tg2nRQ2aR2zE=; b=fqSXXe1f7/HfqdyPNLDvclHwTdmpW/sZKnBentMpOrjE2ZFxpyOtEij1Xz5o9BtgV9 T7QCIwP8IeA8ikQETI/JEpe99xHuWHXVbJVzeTNWuHf/sGp84oRCwoQytiOL9oIQm+lU COHwiDWEdy56snpagygDuQIvA9TIevVxaMltO9NXCCcfJkcaxYxNPjhwVgd/FcT6n2Z8 TbeIClefuLkursEdSSJ6OriT/UTOew1BmPisulEeOx3U/SE3XAvEU7JHr3mBMpvVI9bR Bz95JSBL7FkgifOLD0ekbEe2Pjn5/F2VbcAowa542XTAU5/8QywjZzC8Q6WI6UQW7GuX 3XQg== X-Gm-Message-State: AOAM533ieI4ykpmLJeG9Jq5Mih2kfLQ++q+lb6aNXsVxudsCaYocMhsJ GocWPEXpBpcKNHmG/obM5pI= X-Google-Smtp-Source: ABdhPJz8CUS9aBSNyqloebe7vPQJ62ROqxxptj4HSeB78uIaKqyv+HgWFjaZAZuBhAJmI4n5ExS4eg== X-Received: by 2002:ac8:4704:: with SMTP id f4mr9607375qtp.80.1630089448138; Fri, 27 Aug 2021 11:37:28 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com ([2600:1700:6a10:2e90:b143:41d3:e2f6:337b]) by smtp.gmail.com with ESMTPSA id bl36sm5207463qkb.37.2021.08.27.11.37.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 11:37:27 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v5 1/5] SUNRPC keep track of number of transports to unique addresses Date: Fri, 27 Aug 2021 14:37:14 -0400 Message-Id: <20210827183719.41057-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210827183719.41057-1-olga.kornievskaia@gmail.com> References: <20210827183719.41057-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Currently, xprt_switch keeps a number of all xprts (xps_nxprts) that were added to the switch regardless of whethere it's an nconnect transport or a transport to a trunkable address. Introduce a new counter to keep track of transports to unique destination addresses per xprt_switch. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprtmultipath.h | 1 + net/sunrpc/clnt.c | 2 +- net/sunrpc/xprtmultipath.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index b19addc8b715..bbb8a5fa0816 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -18,6 +18,7 @@ struct rpc_xprt_switch { unsigned int xps_id; unsigned int xps_nxprts; unsigned int xps_nactive; + unsigned int xps_nunique_destaddr_xprts; atomic_long_t xps_queuelen; struct list_head xps_xprt_list; diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index a5b7f6e34d15..451ac7d031db 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2799,7 +2799,7 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, task = rpc_call_null_helper(clnt, xprt, NULL, RPC_TASK_ASYNC, &rpc_cb_add_xprt_call_ops, data); - + data->xps->xps_nunique_destaddr_xprts++; rpc_put_task(task); success: return 1; diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index c60820e45082..1693f81aae37 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -139,6 +139,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt, xps->xps_iter_ops = &rpc_xprt_iter_singular; rpc_sysfs_xprt_switch_setup(xps, xprt, gfp_flags); xprt_switch_add_xprt_locked(xps, xprt); + xps->xps_nunique_destaddr_xprts = 1; rpc_sysfs_xprt_setup(xps, xprt, gfp_flags); } From patchwork Fri Aug 27 18:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12462671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9970AC43214 for ; Fri, 27 Aug 2021 18:37:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E64260FC4 for ; Fri, 27 Aug 2021 18:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbhH0SiU (ORCPT ); Fri, 27 Aug 2021 14:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbhH0SiU (ORCPT ); Fri, 27 Aug 2021 14:38:20 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4BEC061757 for ; Fri, 27 Aug 2021 11:37:31 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id p4so1884613qki.3 for ; Fri, 27 Aug 2021 11:37:31 -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=t8C+GGrkuHZuCFx+eMpPXA1G1r6jwtJtqK4jsR12uQk=; b=I4nE/ZBna7h4ebX6cNdZuklk/98bivnaPxFVgn3gm/9hUwIKB9/AqwKEPjC8tVaFs+ 1+q7ujyw2U2JHBfih5NGA0hP5r2lJkWAdy1AHq/FZ5M78LgcxqVYnJj0GKAIvPDjVv6B DBMXfAa2SfCXSyDLZvcXReuImdreHjR8acOXT23f/RwX1e7GobvmhFBSvHEKGQVTCb1J KHczTWv8WjFXYCAMQzsE/5x4pxHDfREpId6RIFmFxQYOabc02y6A1ntT/7C2kZQoLoHG 5Qy/YlkSGiir3X0cQpyIqGUBcp8RaRnlSMpwLxDqL7WBPr6+Rx8Pqd3gkTlOZjiPDPHF ijUA== 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=t8C+GGrkuHZuCFx+eMpPXA1G1r6jwtJtqK4jsR12uQk=; b=CRc2gVDSfsUqFFOvOCW9fKwnoFCumFw5XBfUpu3iEkoC9VnZtmg//5eyxGijZqh0xm PeJOaA2E8zZkq0LA9whT91d1cW4h0gw3ShY2xQ4gx3cdw0v/XeBdJ032GvWnjfWPg1k/ C3nnjuai+0TRusQ4YXeaJ/YIg9PkiA8hzK+uDB0aeMLf31begUCPM2jJva8+Y0Q5Ippd k3tRX0KQksJ6cIZjLSApWNXzBBKFoWNS26rbr6/9b+EwxlOMZJbwdKyX+Scev1BbJVcN cWgcA0RdTEYP3OKuojt8LUJ6zLRupsXj3xdG16HHnRLRz2Z94Jvcj9s62q2wlxHtYL+j 0o2g== X-Gm-Message-State: AOAM531LbyAysFj+KTTnNlzz6zF8z1uj4e0NV6fvCgH9nOVem18+qWKi 82w2kazjNhZ4A1kBvSZyakoONWYyJ0coSA== X-Google-Smtp-Source: ABdhPJwJILEeZHfaWa9zWATyxn9EhlrkoorNz6Dijp/QlIJJ7xtZ35RQDEg/zj2AJ7+ro/iJqnX3nw== X-Received: by 2002:a37:8243:: with SMTP id e64mr10542985qkd.89.1630089450302; Fri, 27 Aug 2021 11:37:30 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com ([2600:1700:6a10:2e90:b143:41d3:e2f6:337b]) by smtp.gmail.com with ESMTPSA id bl36sm5207463qkb.37.2021.08.27.11.37.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 11:37:29 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v5 2/5] SUNRPC add xps_nunique_destaddr_xprts to xprt_switch_info in sysfs Date: Fri, 27 Aug 2021 14:37:16 -0400 Message-Id: <20210827183719.41057-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210827183719.41057-1-olga.kornievskaia@gmail.com> References: <20210827183719.41057-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia In sysfs's xprt_switch_info attribute also display the value of number of transports with unique destination addresses for this xprt_switch. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 414c664a3199..9a6f17e18f73 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -207,8 +207,10 @@ static ssize_t rpc_sysfs_xprt_switch_info_show(struct kobject *kobj, if (!xprt_switch) return 0; - ret = sprintf(buf, "num_xprts=%u\nnum_active=%u\nqueue_len=%ld\n", + ret = sprintf(buf, "num_xprts=%u\nnum_active=%u\n" + "num_unique_destaddr=%u\nqueue_len=%ld\n", xprt_switch->xps_nxprts, xprt_switch->xps_nactive, + xprt_switch->xps_nunique_destaddr_xprts, atomic_long_read(&xprt_switch->xps_queuelen)); xprt_switch_put(xprt_switch); return ret + 1; From patchwork Fri Aug 27 18:37:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12462675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF42C432BE for ; Fri, 27 Aug 2021 18:37:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8985660EB5 for ; Fri, 27 Aug 2021 18:37:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhH0SiV (ORCPT ); Fri, 27 Aug 2021 14:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbhH0SiV (ORCPT ); Fri, 27 Aug 2021 14:38:21 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B4E8C061757 for ; Fri, 27 Aug 2021 11:37:32 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id e18so4544074qvo.1 for ; Fri, 27 Aug 2021 11:37:32 -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=zo4TDIEYdHuube7ARu42vguc1kT5xIUZHuSRtmn9BqY=; b=I9BLjzGKD4YZfcc0nYoFDnQ/W2Azn93/WRLg3mQKqLceiKauPgQhUVQCVCF9TsrXTH kQnvOIOqdW2E+dGk/EB4tM6uFwVYYHESw0bVozwsI8QzqSPMLGPdek65VKZHShfTW/bK 1opK4rbDPCKH7c52Tm1gBxy8eK+TyPgn7UOckfijT7nM4txiILnnAk4to91pORs+Yv8N 2Of6gqGsgvhPntmvUyY42InKA98V73ICpVP9Jpq5jhuCb9aZtUi0Eu47Fbob7ItqbE/o spxusaEQkioIPcnfHmOmb+jRfbEtE1dRcXiM8HI/XMv+rxhqcco9wIjMabyWeS4xsnJR 2ImA== 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=zo4TDIEYdHuube7ARu42vguc1kT5xIUZHuSRtmn9BqY=; b=WlCGw7ECEqx1NFVRCBGPupeYpCxEXjj4brnmmx/Oa+1HK7WzHcQbXeF/QXusVDROI4 MfcqGk4T7yRbd+nlW3NI+DSxvIqvxErhuwXC8tfOWYUPa31jUygbE+aCQuJ4dJqy/EjI wXs90Xx9n7UNVHgcWz5r9LLYuuoEa/d08YsnEr1SrzRGs3W2lEmUlggI85gMNSK62Bv+ juWYmZRDg1z13nuVCtqB17/0QiUMcXO2iYxebqSpZQZXjJQ/BYVdr+Oh6GNkqs9GR38/ 05O9P3cHfsm5QEmsX33CvelEeOJ77/5BDe/4pFzrsmW9MKPl/nInrXi8z7zkc0+gv6s2 urJQ== X-Gm-Message-State: AOAM532ACZVnGk/I3aL9SqY+tJEEgdntA7IdwL9lgTvHCxxEN4YGvlXF L9TeM2s/gVXhVGEyLsc7MSc= X-Google-Smtp-Source: ABdhPJwJVJzyAc0HxQ1k1YWqLC3UcMV2RX3fCCujiFpMiWgJRMNMa3l/pBYxvrycTnuYjmg6mTnKfA== X-Received: by 2002:a0c:fd21:: with SMTP id i1mr10703369qvs.29.1630089451328; Fri, 27 Aug 2021 11:37:31 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com ([2600:1700:6a10:2e90:b143:41d3:e2f6:337b]) by smtp.gmail.com with ESMTPSA id bl36sm5207463qkb.37.2021.08.27.11.37.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 11:37:30 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v5 3/5] NFSv4 introduce max_connect mount options Date: Fri, 27 Aug 2021 14:37:17 -0400 Message-Id: <20210827183719.41057-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210827183719.41057-1-olga.kornievskaia@gmail.com> References: <20210827183719.41057-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia This option will control up to how many xprts can the client establish to the server with a distinct address (that means nconnect connections are not counted towards this new limit). This patch is setting up nfs structures to keeep track of the max_connect limit (does not enforce it). The default value is kept at 1 so that no current mounts that don't want any additional connections would be effected. The maximum value is set at 16. Mounts to DS are not limited to default value of 1 but instead set to the maximum default value of 16 (NFS_MAX_TRANSPORTS). Signed-off-by: Olga Kornievskaia --- fs/nfs/client.c | 1 + fs/nfs/fs_context.c | 7 +++++++ fs/nfs/internal.h | 2 ++ fs/nfs/nfs4client.c | 12 ++++++++++-- fs/nfs/super.c | 2 ++ include/linux/nfs_fs.h | 5 +++++ include/linux/nfs_fs_sb.h | 1 + 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 330f65727c45..486dec59972b 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -179,6 +179,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) clp->cl_proto = cl_init->proto; clp->cl_nconnect = cl_init->nconnect; + clp->cl_max_connect = cl_init->max_connect ? cl_init->max_connect : 1; clp->cl_net = get_net(cl_init->net); clp->cl_principal = "*"; diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index d95c9a39bc70..0d444a90f513 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -60,6 +60,7 @@ enum nfs_param { Opt_mountvers, Opt_namelen, Opt_nconnect, + Opt_max_connect, Opt_port, Opt_posix, Opt_proto, @@ -158,6 +159,7 @@ static const struct fs_parameter_spec nfs_fs_parameters[] = { fsparam_u32 ("mountvers", Opt_mountvers), fsparam_u32 ("namlen", Opt_namelen), fsparam_u32 ("nconnect", Opt_nconnect), + fsparam_u32 ("max_connect", Opt_max_connect), fsparam_string("nfsvers", Opt_vers), fsparam_u32 ("port", Opt_port), fsparam_flag_no("posix", Opt_posix), @@ -770,6 +772,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc, goto out_of_bounds; ctx->nfs_server.nconnect = result.uint_32; break; + case Opt_max_connect: + if (result.uint_32 < 1 || result.uint_32 > NFS_MAX_TRANSPORTS) + goto out_of_bounds; + ctx->nfs_server.max_connect = result.uint_32; + break; case Opt_lookupcache: switch (result.uint_32) { case Opt_lookupcache_all: diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index a36af04188c2..66fc936834f2 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -67,6 +67,7 @@ struct nfs_client_initdata { int proto; u32 minorversion; unsigned int nconnect; + unsigned int max_connect; struct net *net; const struct rpc_timeout *timeparms; const struct cred *cred; @@ -121,6 +122,7 @@ struct nfs_fs_context { int port; unsigned short protocol; unsigned short nconnect; + unsigned short max_connect; unsigned short export_path_len; } nfs_server; diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 28431acd1230..270caa1805a2 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -865,6 +865,7 @@ static int nfs4_set_client(struct nfs_server *server, const char *ip_addr, int proto, const struct rpc_timeout *timeparms, u32 minorversion, unsigned int nconnect, + unsigned int max_connect, struct net *net) { struct nfs_client_initdata cl_init = { @@ -883,6 +884,8 @@ static int nfs4_set_client(struct nfs_server *server, if (minorversion == 0) __set_bit(NFS_CS_REUSEPORT, &cl_init.init_flags); + else + cl_init.max_connect = max_connect; if (proto == XPRT_TRANSPORT_TCP) cl_init.nconnect = nconnect; @@ -952,8 +955,10 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv, return ERR_PTR(-EINVAL); cl_init.hostname = buf; - if (mds_clp->cl_nconnect > 1 && ds_proto == XPRT_TRANSPORT_TCP) + if (mds_clp->cl_nconnect > 1 && ds_proto == XPRT_TRANSPORT_TCP) { cl_init.nconnect = mds_clp->cl_nconnect; + cl_init.max_connect = NFS_MAX_TRANSPORTS; + } if (mds_srv->flags & NFS_MOUNT_NORESVPORT) __set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags); @@ -1122,6 +1127,7 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc) &timeparms, ctx->minorversion, ctx->nfs_server.nconnect, + ctx->nfs_server.max_connect, fc->net_ns); if (error < 0) return error; @@ -1211,6 +1217,7 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc) parent_server->client->cl_timeout, parent_client->cl_mvops->minor_version, parent_client->cl_nconnect, + parent_client->cl_max_connect, parent_client->cl_net); if (!error) goto init_server; @@ -1226,6 +1233,7 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc) parent_server->client->cl_timeout, parent_client->cl_mvops->minor_version, parent_client->cl_nconnect, + parent_client->cl_max_connect, parent_client->cl_net); if (error < 0) goto error; @@ -1323,7 +1331,7 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname, error = nfs4_set_client(server, hostname, sap, salen, buf, clp->cl_proto, clnt->cl_timeout, clp->cl_minorversion, - clp->cl_nconnect, net); + clp->cl_nconnect, clp->cl_max_connect, net); clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status); if (error != 0) { nfs_server_insert_lists(server); diff --git a/fs/nfs/super.c b/fs/nfs/super.c index fe58525cfed4..e65c83494c05 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -480,6 +480,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, if (clp->cl_nconnect > 0) seq_printf(m, ",nconnect=%u", clp->cl_nconnect); if (version == 4) { + if (clp->cl_max_connect > 1) + seq_printf(m, ",max_connect=%u", clp->cl_max_connect); if (nfss->port != NFS_PORT) seq_printf(m, ",port=%u", nfss->port); } else diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index ce6474594872..b9a8b925db43 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -40,6 +40,11 @@ #include +/* + * These are the default for number of transports to different server IPs + */ +#define NFS_MAX_TRANSPORTS 16 + /* * These are the default flags for swap requests */ diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index d71a0e90faeb..2a9acbfe00f0 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -62,6 +62,7 @@ struct nfs_client { u32 cl_minorversion;/* NFSv4 minorversion */ unsigned int cl_nconnect; /* Number of connections */ + unsigned int cl_max_connect; /* max number of xprts allowed */ const char * cl_principal; /* used for machine cred */ #if IS_ENABLED(CONFIG_NFS_V4) From patchwork Fri Aug 27 18:37:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12462677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7677BC43216 for ; Fri, 27 Aug 2021 18:37:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61B1760FC4 for ; Fri, 27 Aug 2021 18:37:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbhH0SiW (ORCPT ); Fri, 27 Aug 2021 14:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbhH0SiW (ORCPT ); Fri, 27 Aug 2021 14:38:22 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3546FC061757 for ; Fri, 27 Aug 2021 11:37:33 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id m21so8147524qkm.13 for ; Fri, 27 Aug 2021 11:37:33 -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=1n7QWUAyir20rnEJ75DMV1yVxgJ5KdC9qxlhEbLzmGo=; b=ejhd46aq9QoFW9HDNv1Y/ezcX2Dqk3+W5EbDRO9H/H75B7oht+BiQ0Bd9K3zRm9H5K ZepWMnnpesbxYIVtHB+rZtmrJhxnjOyoC4fYL51UTsW7ua2DvYZE0yooclRVHXd/tuOt qwQxVcxo6J0VZqQ0plIsxGEPE7ZsvHH4avZ7tKrNS0un3sZ48pwRVN1ozX4PCtAqoqh5 DQdvdbl6sLmVAeXDjKcg7GTqc6y4MwOszGIDtQdBhCQh8S0L7L1hlGZuvo0K9c+WpBRO KLoqn97bGHwsy1gN9X/re7kBZwNCr25UwelpFQBtMHYRq9tZTlupGZx6q5pBEoS1mgmA 7CjQ== 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=1n7QWUAyir20rnEJ75DMV1yVxgJ5KdC9qxlhEbLzmGo=; b=ZrxQnuCNOymqImlPzYJMUOjZtpuyu1B/ltwWGi5AnnJWs9ZVoO7wYEVXV03Dqjfps0 YHblGQrcRop/eBgbmS9K7z6aoN8ObWw3ycc23j0+ZGT5vTPM3iku0moPL0GB8QehJNMf jvoVAdJwk/cV7bHci/Nlw8m5hYq9rg195gLYtsA1OPNzL87UGgU33yNadEkDLaEZJKb0 uGPOeW/6xcuyx7uodAMaNh1YN9MVjTz5cPUWJ9ahWyhrledW0XE7o80sRfrtmF1yZFN6 tS19E0cAoJm4+v/ilK+7XrgKrHGjtF1Bu3wk8DNSxrM9jxcXBOV0DSDoVxmUTM0c3OCw UkNw== X-Gm-Message-State: AOAM530r038iMkSiBIl4SviJp7p9EjbmqhAdex8S/7EbMLsoU7E5KvNz Noz4lyublon6UUDXpE3sE7Rv0a0OiHcq+A== X-Google-Smtp-Source: ABdhPJxR3obVczUtyKywiQrbaI9QWjkYIDwg84fF7RLucjINcccfyEGuXTQdxQ7pRZF5sRSubk05wg== X-Received: by 2002:a05:620a:199d:: with SMTP id bm29mr10476735qkb.14.1630089452398; Fri, 27 Aug 2021 11:37:32 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com ([2600:1700:6a10:2e90:b143:41d3:e2f6:337b]) by smtp.gmail.com with ESMTPSA id bl36sm5207463qkb.37.2021.08.27.11.37.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 11:37:32 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v5 4/5] SUNRPC enforce creation of no more than max_connect xprts Date: Fri, 27 Aug 2021 14:37:18 -0400 Message-Id: <20210827183719.41057-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210827183719.41057-1-olga.kornievskaia@gmail.com> References: <20210827183719.41057-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia If we are adding new transports via rpc_clnt_test_and_add_xprt() then check if we've reached the limit. Currently only pnfs path adds transports via that function but this is done in preparation when the client would add new transports when session trunking is detected. A warning is logged if the limit is reached. Signed-off-by: Olga Kornievskaia --- fs/nfs/client.c | 1 + include/linux/sunrpc/clnt.h | 2 ++ net/sunrpc/clnt.c | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 486dec59972b..23e165d5ec9c 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -541,6 +541,7 @@ int nfs_create_rpc_client(struct nfs_client *clp, clnt->cl_principal = clp->cl_principal; clp->cl_rpcclient = clnt; + clnt->cl_max_connect = clp->cl_max_connect; return 0; } EXPORT_SYMBOL_GPL(nfs_create_rpc_client); diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index b2edd5fc2f0c..a4661646adc9 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -82,6 +82,7 @@ struct rpc_clnt { struct work_struct cl_work; }; const struct cred *cl_cred; + unsigned int cl_max_connect; /* max number of transports not to the same IP */ }; /* @@ -136,6 +137,7 @@ struct rpc_create_args { char *client_name; struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */ const struct cred *cred; + unsigned int max_connect; }; struct rpc_add_xprt_test { diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 451ac7d031db..f056ff931444 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2787,6 +2787,15 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, struct rpc_cb_add_xprt_calldata *data; struct rpc_task *task; + if (xps->xps_nunique_destaddr_xprts + 1 > clnt->cl_max_connect) { + rcu_read_lock(); + pr_warn("SUNRPC: reached max allowed number (%d) did not add " + "transport to server: %s\n", clnt->cl_max_connect, + rpc_peeraddr2str(clnt, RPC_DISPLAY_ADDR)); + rcu_read_unlock(); + return -EINVAL; + } + data = kmalloc(sizeof(*data), GFP_NOFS); if (!data) return -ENOMEM; From patchwork Fri Aug 27 18:37:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12462679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBC3CC4320A for ; Fri, 27 Aug 2021 18:37:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B706460FC4 for ; Fri, 27 Aug 2021 18:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229977AbhH0SiY (ORCPT ); Fri, 27 Aug 2021 14:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbhH0SiX (ORCPT ); Fri, 27 Aug 2021 14:38:23 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888F6C061757 for ; Fri, 27 Aug 2021 11:37:34 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id m21so8147601qkm.13 for ; Fri, 27 Aug 2021 11:37:34 -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=vIOWLAR5baQ4wudUHjXS8yJqf6XzOgQ0+NlfjuEdhJQ=; b=JBEDGAYo8LOo0H4XpY+jgeX9Vl41MxYM9smP/hmI6EOGH2dJR3IdlsfwOznzusd57S tnZDpELvqnVTefYRx+SAou9NCEM0LQLrq/Bwq2FczimD1DN+uBVgspyM1msahF2vmHHl dHcQ1bNLqBi68/Px0dNWYniatYod48XS7qhOplfhH8PHxoBlWVuS6OSDvoE5EanW3iwy 0iTZJ7l47QzYJ6WSqA6KnkQAHpTh+oh8ZTfVsj2wGOmNpa9nyrUJY7EfyYBzzNmrAaPe uLAEy97V+ETYJzko3V3gWZWC0aHOgze4Lp+6W+pIiPfY8/HGhgbK+hCBRamZhL76+yCX Lrgw== 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=vIOWLAR5baQ4wudUHjXS8yJqf6XzOgQ0+NlfjuEdhJQ=; b=dBrMVt0V+rbdbcy1piKMcbDYfU/jbM5Q3cH4jEd3SN9Ttv/8zTAs+Ih6urCGyG+0D0 bau9X2Lsgtpmlu31QiB8/MX49g8lN9CpWcQeJCyjt82EgFa91ntJDm2z3Mz1a/i33erH HvQAwh104ntwFBdgTMqwf56QTFwQSQqNsMGKVKN7ffsdw64QiSBO/HYa7Gxdx7eaobD8 9f8XgDlVW8QCTSK18uyJ79bWue/UwG0a3UxbrI8w+kCvevZGGX3HoAB4nh3wXgBWXRk2 nwErC15Ey73CYXrbbSzlYorv7zj2LAtDxnizagSWIUK/xVZyQaj1TlZQylKl8YWFySyr vMtw== X-Gm-Message-State: AOAM530dKuCLpgKRHlua+Y3RHaxhI2jmKUJtFdkil5FcGjRUpnvUtOjg 07TrZShFbZehGlDnzan4QOA= X-Google-Smtp-Source: ABdhPJz/oRsLpWU2zhCHGYTwce7isukKCLbF1cidzoRlTYso4weGVEvJGdSdpmo6egeZjtb/rtH5UQ== X-Received: by 2002:a05:620a:2089:: with SMTP id e9mr10213761qka.298.1630089453690; Fri, 27 Aug 2021 11:37:33 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com ([2600:1700:6a10:2e90:b143:41d3:e2f6:337b]) by smtp.gmail.com with ESMTPSA id bl36sm5207463qkb.37.2021.08.27.11.37.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 11:37:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v5 5/5] NFSv4.1 add network transport when session trunking is detected Date: Fri, 27 Aug 2021 14:37:19 -0400 Message-Id: <20210827183719.41057-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210827183719.41057-1-olga.kornievskaia@gmail.com> References: <20210827183719.41057-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia After trunking is discovered in nfs4_discover_server_trunking(), add the transport to the old client structure if the allowed limit of transports has not been reached. An example: there exists a multi-homed server and client mounts one server address and some volume and then doest another mount to a different address of the same server and perhaps a different volume. Previously, the client checks that this is a session trunkable servers (same server), and removes the newly created client structure along with its transport. Now, the client adds the connection from the 2nd mount into the xprt switch of the existing client (it leads to having 2 available connections). Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4client.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 270caa1805a2..af57332503be 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -402,6 +402,33 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) return nfs4_init_callback(clp); } +static void nfs4_add_trunk(struct nfs_client *clp, struct nfs_client *old) +{ + struct sockaddr_storage clp_addr, old_addr; + struct sockaddr *clp_sap = (struct sockaddr *)&clp_addr; + struct sockaddr *old_sap = (struct sockaddr *)&old_addr; + size_t clp_salen; + struct xprt_create xprt_args = { + .ident = old->cl_proto, + .net = old->cl_net, + .servername = old->cl_hostname, + }; + + if (clp->cl_proto != old->cl_proto) + return; + clp_salen = rpc_peeraddr(clp->cl_rpcclient, clp_sap, sizeof(clp_addr)); + rpc_peeraddr(old->cl_rpcclient, old_sap, sizeof(old_addr)); + + if (clp_addr.ss_family != old_addr.ss_family) + return; + + xprt_args.dstaddr = clp_sap; + xprt_args.addrlen = clp_salen; + + rpc_clnt_add_xprt(old->cl_rpcclient, &xprt_args, + rpc_clnt_test_and_add_xprt, NULL); +} + /** * nfs4_init_client - Initialise an NFS4 client record * @@ -436,6 +463,8 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp, * won't try to use it. */ nfs_mark_client_ready(clp, -EPERM); + if (old->cl_mvops->session_trunk) + nfs4_add_trunk(clp, old); } clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags); nfs_put_client(clp);