From patchwork Thu Jan 27 20:09:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12727339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E724BC433EF for ; Thu, 27 Jan 2022 20:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343619AbiA0UJq (ORCPT ); Thu, 27 Jan 2022 15:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240073AbiA0UJp (ORCPT ); Thu, 27 Jan 2022 15:09:45 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C291C061714; Thu, 27 Jan 2022 12:09:45 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id q75so3249765pgq.5; Thu, 27 Jan 2022 12:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vqz3x4L30hj6XxJnf3VM6m56+12Dc+5qoM6cpW+3GgI=; b=TfCKmEOPUtKjcU1P322uV0VSo/0Hqbtrig/Js9i+E+ivMVt2IuJuaLJ3KjRNyJpJUl LKyYz1cheJSjBgwSjJd3tsp5gaSmWsuVE4NlrfuLVTrv/PCqYvGSPlaqAFI/oI4Ws7sH nsPzhS597DmrtybtMIv+gth14gXgssjQajvGVt03B29q/j9/nnfnC9CLzm9tZ4HOEYXY 61aFSnSMMHxiPXzQLDOJyvOcTeKkzJibuTMFeU+GLNwHjyFGXg7v20II/TroRiZ6Hwy6 riB8654moFLoI+FC671uGGD2QhR4x1OaN+lrC5Crdwxy0jAz3rzZN2IkUJkUoTuBfzep g4Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vqz3x4L30hj6XxJnf3VM6m56+12Dc+5qoM6cpW+3GgI=; b=mhRPM7K4Y2OocpZguKoGviYjCHvP/2YXYV4LJd+lS6rWreSGI7UZzMQh55dUKF2JJV THY60O0iarXbRjqz/awSIK+9LGXwkGgrvb3P9tIcWEj4pl+I/L+7Yz+LJp/Ew7n/Aa0h KlAldVk61oG3IGV5+/eO7gQLYu6/g8+3dlNDED6UTNfGDuo75W+KyiiM4On2tSYZWXrm 6zSGN9i4KD4vZFY4QZjLVegvhygQAjFH2ZW1ZF1MrIMKU3RwuQf8odkdp6U87mZsxHgc JFmAQJ/ThWm4l7wnFtqy2/EuHBJVdn3cm97np0NAxMiC96aJAsbrQ/Me+hqXqsbs+OHF BoxA== X-Gm-Message-State: AOAM533bIPqYj7u6cjGYDPUL8eTr2xbICWMTTGziQRVXQbQrsUwDjejM baVoKwZDEkV9yQeNk4383e4= X-Google-Smtp-Source: ABdhPJzx24L1v1OGbNhbkdY9s4EzWFpeWN4ZqMRKU6+pWr/ZYaUDcuhrMwqllkD6u619ubiMQYFs5Q== X-Received: by 2002:a63:8ac9:: with SMTP id y192mr3835856pgd.409.1643314184953; Thu, 27 Jan 2022 12:09:44 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:ab5e:9016:8c9e:ba75]) by smtp.gmail.com with ESMTPSA id y42sm5697892pfw.157.2022.01.27.12.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 12:09:44 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: Chuck Lever , linux-nfs , netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Date: Thu, 27 Jan 2022 12:09:35 -0800 Message-Id: <20220127200937.2157402-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220127200937.2157402-1-eric.dumazet@gmail.com> References: <20220127200937.2157402-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Eric Dumazet struct svc_xprt holds a long lived reference to a netns, it is worth tracking it. Signed-off-by: Eric Dumazet Acked-by: Chuck Lever --- include/linux/sunrpc/svc_xprt.h | 1 + net/sunrpc/svc_xprt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index 571f605bc91ef8fa190e7fd5504efb76ec3fa89e..382af90320acc3a7b3817bf66f65fbb15447ae7d 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h @@ -88,6 +88,7 @@ struct svc_xprt { struct list_head xpt_users; /* callbacks on free */ struct net *xpt_net; + netns_tracker ns_tracker; const struct cred *xpt_cred; struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */ struct rpc_xprt_switch *xpt_bc_xps; /* NFSv4.1 backchannel */ diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index b21ad79941474685597c9c7c07b862ef7e98ad74..db878e833b672864551bc9ef884a3cd6ca6c2603 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref) if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags)) svcauth_unix_info_release(xprt); put_cred(xprt->xpt_cred); - put_net(xprt->xpt_net); + put_net_track(xprt->xpt_net, &xprt->ns_tracker); /* See comment on corresponding get in xs_setup_bc_tcp(): */ if (xprt->xpt_bc_xprt) xprt_put(xprt->xpt_bc_xprt); @@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl, mutex_init(&xprt->xpt_mutex); spin_lock_init(&xprt->xpt_lock); set_bit(XPT_BUSY, &xprt->xpt_flags); - xprt->xpt_net = get_net(net); + xprt->xpt_net = get_net_track(net, &xprt->ns_tracker, GFP_ATOMIC); strcpy(xprt->xpt_remotebuf, "uninitialized"); } EXPORT_SYMBOL_GPL(svc_xprt_init); From patchwork Thu Jan 27 20:09:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12727340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D37BC433F5 for ; Thu, 27 Jan 2022 20:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343827AbiA0UJt (ORCPT ); Thu, 27 Jan 2022 15:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240073AbiA0UJr (ORCPT ); Thu, 27 Jan 2022 15:09:47 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A3EC061714; Thu, 27 Jan 2022 12:09:47 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id i186so1356346pfe.0; Thu, 27 Jan 2022 12:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/qrkGMnIvAK9NC9pELAwNsO56PYT1J3Scvu6zLU6DAQ=; b=htYtGfMS6PvXV7MRAPe7nd0bUYu9h+QHungGiCM0+Q62e9sDaWAlTTouXh/PMthAcr Gsz3dlC11SEzm/swcOVp7naJhMbPJVB2ghJf9aL4Pf1Ry3nCxwGzO/DgR8EWaQcf0IZg 98uMJT8Ck//6rroBUyPYGjUAokob7P09pJPCxfqwfwgfCZzkv0mjUUB0UVTRIg/7iqkY SE//c/DmSLzASb3OqL6V4+piJGlrtCaxy1lKwEZqj0IQ80adUrkHAEOZqZlnZIixFz9Y glMI4NRpFOXXVwGJBGMNoKrB4JWhONgLG1A3tKNwp+n6ccWpwwssJMUlHZllpt/MEyV6 z7Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/qrkGMnIvAK9NC9pELAwNsO56PYT1J3Scvu6zLU6DAQ=; b=G8cpqI6HBnVzJvbNO3WCVs5c0upOixufi7AO31WSFm8kh8onYoYvPQiFaul+z0Wpib vAxoIl+01bmwGQuAu5Tvy+/XKBYqVqPGd30i6zgBh3E9KGClSuBqprXHxOXGSibesZ+g DJ8UI+pr+QGJi/LeD7MfioJ2JblisKrGLryaXJaUwmhruT/16CEveB0nqgQrqPnGv6kE 9YtDEC8ufwhk3NthwWni905P+mYrogH9+tv4ycIDd5UmbZ2FAM6ZpxOfm0KZ2OEY2AFF cjV0Eu62e5U0TKrNe2mUD493bei1PpAD1uVkIFBIc+sokKlAWVUUOyA8RYfTU3+X1LeP 1U6g== X-Gm-Message-State: AOAM531XTPlqHhs7FxpD1E5ZK/BkwIEF0uO/uBjx3aKC4mNBa2vfTZzp n5jjtDGliAT/4Am0GaCgh48= X-Google-Smtp-Source: ABdhPJz8/tNNG5S9NwkbTWGX2C935svId5l5FkW7M40mATr/cqPLvYg4bPcvjQaOv3nO6h13SO0bZw== X-Received: by 2002:a63:b90f:: with SMTP id z15mr3993038pge.73.1643314187259; Thu, 27 Jan 2022 12:09:47 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:ab5e:9016:8c9e:ba75]) by smtp.gmail.com with ESMTPSA id y42sm5697892pfw.157.2022.01.27.12.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 12:09:46 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: Chuck Lever , linux-nfs , netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 2/3] SUNRPC: add netns refcount tracker to struct gss_auth Date: Thu, 27 Jan 2022 12:09:36 -0800 Message-Id: <20220127200937.2157402-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220127200937.2157402-1-eric.dumazet@gmail.com> References: <20220127200937.2157402-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Eric Dumazet Signed-off-by: Eric Dumazet --- net/sunrpc/auth_gss/auth_gss.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 5f42aa5fc612850b526c160ab5e5c75416862676..8eb7e8544815a8bc20a79b21b01e3ba110fc6b47 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -72,7 +72,8 @@ struct gss_auth { struct gss_api_mech *mech; enum rpc_gss_svc service; struct rpc_clnt *client; - struct net *net; + struct net *net; + netns_tracker ns_tracker; /* * There are two upcall pipes; dentry[1], named "gssd", is used * for the new text-based upcall; dentry[0] is named after the @@ -1013,7 +1014,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) goto err_free; } gss_auth->client = clnt; - gss_auth->net = get_net(rpc_net_ns(clnt)); + gss_auth->net = get_net_track(rpc_net_ns(clnt), &gss_auth->ns_tracker, + GFP_KERNEL); err = -EINVAL; gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); if (!gss_auth->mech) @@ -1068,7 +1070,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) err_put_mech: gss_mech_put(gss_auth->mech); err_put_net: - put_net(gss_auth->net); + put_net_track(gss_auth->net, &gss_auth->ns_tracker); err_free: kfree(gss_auth->target_name); kfree(gss_auth); @@ -1084,7 +1086,7 @@ gss_free(struct gss_auth *gss_auth) gss_pipe_free(gss_auth->gss_pipe[0]); gss_pipe_free(gss_auth->gss_pipe[1]); gss_mech_put(gss_auth->mech); - put_net(gss_auth->net); + put_net_track(gss_auth->net, &gss_auth->ns_tracker); kfree(gss_auth->target_name); kfree(gss_auth); From patchwork Thu Jan 27 20:09:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12727341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44C9FC433FE for ; Thu, 27 Jan 2022 20:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240073AbiA0UJu (ORCPT ); Thu, 27 Jan 2022 15:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343849AbiA0UJt (ORCPT ); Thu, 27 Jan 2022 15:09:49 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825D3C06173B; Thu, 27 Jan 2022 12:09:49 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id 192so3831420pfz.3; Thu, 27 Jan 2022 12:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RkfqaIYdIflD5OrIVUZ3ltg7/5gsx64rX1PAV9PiRlk=; b=PKuRIZiAC8lWuO37QCM7QnFpEOPwpVOh73ngLaxQvAKXM+TShrd+ZTVHeiukqdYc1G FzhG9pxy4gjAtrO8vFCwZK75ZWZ/xT2UpDnYhNz256fQGoHJ1Q98vYbZmVtefLRvImon yteO0HGSfrmowCJ9qt2l10nW7+9BduHDSo6hBL66Abj9+/6/iBYOl0qB5lnJnCqp/QCy JrF/lF3vBXeDn1frlnLpdY1liCQc6rHKwZPY+wOhP0TwevpVSBKXjn2lJpYXXhjyg95L u00IaBjupO3Y2WEbCe2eU1j9boEVPm8tyfFlgm1otPbE1CWRwesyqgNEOnG5TPzswkwA tIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RkfqaIYdIflD5OrIVUZ3ltg7/5gsx64rX1PAV9PiRlk=; b=GwFCfg3SS6h7E1DPTtzbVR404o82gWtQhI/+DQhT57xEsp3Zv2AZagBDtDShLUHmjo GPmcNx9J0lXrttEihZ+nowzPgm5dh48TKXNt+QIWJoT1g/cTNQwGQ3tH0/PVPH0/BfH5 oXg32vh0WeRtck74fKANLrjickavkTNTBoxIibvz9zn5U04q2Ts3jWFT2mwAD/75WPca UFRW9+V+uJWjTrYDtTa5t+7vCyaF7k5PJ9lV2ZIuSF6oA6/ZF5zov2iet9NCZvq4eZg1 A7LnKoy1vMMcks/DDZFUsAFxek+4KH8/XsWucAMU5is6frrs4tpSWa8zBbnzngKBr0xe unUQ== X-Gm-Message-State: AOAM532ltnhAioCjrRAqxjIBehMxq2Z9miiRZc/O6wwTloFH6w0YL6KK 2yvpQRWynoDWVp9XnTy0erk= X-Google-Smtp-Source: ABdhPJz2BlCJ7i72gol7bA35OiGHesJ9FTrIqhv2J8Y6ozbv1dNkYJVEgmuBB06Vm0aly4O2cCm8tA== X-Received: by 2002:aa7:8706:: with SMTP id b6mr4414467pfo.61.1643314189009; Thu, 27 Jan 2022 12:09:49 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:ab5e:9016:8c9e:ba75]) by smtp.gmail.com with ESMTPSA id y42sm5697892pfw.157.2022.01.27.12.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 12:09:48 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: Chuck Lever , linux-nfs , netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt Date: Thu, 27 Jan 2022 12:09:37 -0800 Message-Id: <20220127200937.2157402-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220127200937.2157402-1-eric.dumazet@gmail.com> References: <20220127200937.2157402-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Eric Dumazet Signed-off-by: Eric Dumazet --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 955ea4d7af0b2fea1300a46fad963df35f25810c..3cdc8d878d81122e3318447df4770100500403e4 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -284,6 +284,7 @@ struct rpc_xprt { } stat; struct net *xprt_net; + netns_tracker ns_tracker; const char *servername; const char *address_strings[RPC_DISPLAY_MAX]; #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index a02de2bddb28b48bb6798327c0814e769314621b..5af484d6ba5e8bfb871768122009ee330c708c04 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1835,7 +1835,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc); void xprt_free(struct rpc_xprt *xprt) { - put_net(xprt->xprt_net); + put_net_track(xprt->xprt_net, &xprt->ns_tracker); xprt_free_all_slots(xprt); xprt_free_id(xprt); rpc_sysfs_xprt_destroy(xprt); @@ -2027,7 +2027,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net) xprt_init_xid(xprt); - xprt->xprt_net = get_net(net); + xprt->xprt_net = get_net_track(net, &xprt->ns_tracker, GFP_KERNEL); } /**