From patchwork Thu Jan 25 19:53:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531664 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F6B91339B2 for ; Thu, 25 Jan 2024 19:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212421; cv=none; b=teEKLMmLC61UtW43h2e0vxmRHbMzlPVSY6TUcbK3YnL+8N6lLjUG7i/N08cS6vm3cZ8DdQx4Myd30r+CSazr6Q0PrtMH3qIIHLp1HM/My6ujYLDmYbO1ZrV4BpJxL92gaZl3hzaZlMVJmUWHc6SoCmv5i4IVM+nLZpaLC67CiXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212421; c=relaxed/simple; bh=gj6BN5Ryi90FiGCGRLD4HyYT25snhN7XpbObeUR/VfU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LLKoHZFTCWN+Mx2mDvUBRAFczQj71ZqOhrQtB/XwJUkpZCSFyHrvGM3hp5RPiAogKRB+myx3wHTNTNZPVqLWey0BdgehoZ2VqXTnrM0HSswbxNi8MOvNH4qeqBC/DNjkpktjM0mA7qka/r8c24AC6LCo3ml6HBv7QDnbtMylr+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=vhuoelGH; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="vhuoelGH" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-dc372245aefso3290197276.2 for ; Thu, 25 Jan 2024 11:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212419; x=1706817219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hDFJ4ofz5JnRdgl61rMW+8vTooiJNkqwX2WXWFw/o7A=; b=vhuoelGHCuW93gZFYbpLy7Q56DDz7aTwoGFGDbvSmttEmkGTrGkVFJco5NEvtXIRfQ U/FASuM3Z/x1Dj9HT7lRzPRmbwWVgRzUY3GzaL8bbg8FEAXOaAzCQNhv49hcrnYKGDLg TSfJZ1TGYufnyFPLPylqOF4tS9bYyqqcGk4sZH3QtFoW4mqCmPv/XuYsWjS7fQD4XBaU bCtMsDHGhdtaHd8Dck6u1BuHw3sMAd5pIak2lD+6F/QfDUXmZF3GWf5cxnvVQ4aGMfUa +dfaXVS9Trnx4+WdnSkUe/TOhW3Lgeq50zf8fSfCQix1uOkX96WR/fcXcwD/0LR1MqHv 4vaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212419; x=1706817219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hDFJ4ofz5JnRdgl61rMW+8vTooiJNkqwX2WXWFw/o7A=; b=jVJiAsZ4hUFlAlQ2kcGFdXZ6hFNHBf1rwDPaCUK0vPN2BVYZjGPQnpFtnmnKNF79iF U0NgzMSGHCuONYxVKxySXSwKXvltKXZ0ZHSyBRlij2tPW5IErmT0TGLv1RfwxdfrS1Il Emtmv4YTj7lydXnLVNDxpMShUNFwt4LmlQDuIhiKcWHOB+8h9abNijXbnEKxLZ+XQHOJ /glxjhHdVojtv/5pt7qcSyi6bAyjJMxPdk4IvtQ8fANf5AiEd8v60FyYhQHzMxW8E46r bXtIYJTSyURmM1d9bGoIaTlZG+ec/XEIWYk0rFlrRun/JaDN1x3jZAS6QsnXB1k/YsAU 8qNQ== X-Gm-Message-State: AOJu0YzpDIbwKcAKaQIu4klpwlNkwHqkS8/yH47pl9sFupyOoP9Jd2FQ +gAPFWWfuZjq8kTckRVTUoa++gNoXpKyFlAAI7OyLoJ1LLN80ITm60yOJcL6drcdHRUSTXEJjXj M X-Google-Smtp-Source: AGHT+IESBSFidcjHUAc5SVVVilyydQld9Spj3Na0lIVbxNua5M1RWIhAjyTDLCHaHEAkeufXHgaDow== X-Received: by 2002:a25:bcce:0:b0:dc2:3ec3:95d4 with SMTP id l14-20020a25bcce000000b00dc23ec395d4mr306069ybm.47.1706212417486; Thu, 25 Jan 2024 11:53:37 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id s65-20020a25c244000000b00dc2310abe8bsm3692949ybf.38.2024.01.25.11.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:37 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 01/13] sunrpc: don't change ->sv_stats if it doesn't exist Date: Thu, 25 Jan 2024 14:53:11 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We check for the existence of ->sv_stats elsewhere except in the core processing code. It appears that only nfsd actual exports these values anywhere, everybody else just has a write only copy of sv_stats in their svc_program. Add a check for ->sv_stats before every adjustment to allow us to eliminate the stats struct from all the users who don't report the stats. Signed-off-by: Josef Bacik --- net/sunrpc/svc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index f60c93e5a25d..d2e6f3d59218 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1375,7 +1375,8 @@ svc_process_common(struct svc_rqst *rqstp) goto err_bad_proc; /* Syntactic check complete */ - serv->sv_stats->rpccnt++; + if (serv->sv_stats) + serv->sv_stats->rpccnt++; trace_svc_process(rqstp, progp->pg_name); aoffset = xdr_stream_pos(xdr); @@ -1427,7 +1428,8 @@ svc_process_common(struct svc_rqst *rqstp) goto close_xprt; err_bad_rpc: - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; xdr_stream_encode_u32(xdr, RPC_MSG_DENIED); xdr_stream_encode_u32(xdr, RPC_MISMATCH); /* Only RPCv2 supported */ @@ -1438,7 +1440,8 @@ svc_process_common(struct svc_rqst *rqstp) err_bad_auth: dprintk("svc: authentication failed (%d)\n", be32_to_cpu(rqstp->rq_auth_stat)); - serv->sv_stats->rpcbadauth++; + if (serv->sv_stats) + serv->sv_stats->rpcbadauth++; /* Restore write pointer to location of reply status: */ xdr_truncate_encode(xdr, XDR_UNIT * 2); xdr_stream_encode_u32(xdr, RPC_MSG_DENIED); @@ -1448,7 +1451,8 @@ svc_process_common(struct svc_rqst *rqstp) err_bad_prog: dprintk("svc: unknown program %d\n", rqstp->rq_prog); - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; *rqstp->rq_accept_statp = rpc_prog_unavail; goto sendit; @@ -1456,7 +1460,8 @@ svc_process_common(struct svc_rqst *rqstp) svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n", rqstp->rq_vers, rqstp->rq_prog, progp->pg_name); - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; *rqstp->rq_accept_statp = rpc_prog_mismatch; /* @@ -1470,19 +1475,22 @@ svc_process_common(struct svc_rqst *rqstp) err_bad_proc: svc_printk(rqstp, "unknown procedure (%d)\n", rqstp->rq_proc); - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; *rqstp->rq_accept_statp = rpc_proc_unavail; goto sendit; err_garbage_args: svc_printk(rqstp, "failed to decode RPC header\n"); - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; *rqstp->rq_accept_statp = rpc_garbage_args; goto sendit; err_system_err: - serv->sv_stats->rpcbadfmt++; + if (serv->sv_stats) + serv->sv_stats->rpcbadfmt++; *rqstp->rq_accept_statp = rpc_system_err; goto sendit; } @@ -1534,7 +1542,8 @@ void svc_process(struct svc_rqst *rqstp) out_baddir: svc_printk(rqstp, "bad direction 0x%08x, dropping request\n", be32_to_cpu(*p)); - rqstp->rq_server->sv_stats->rpcbadfmt++; + if (rqstp->rq_server->sv_stats) + rqstp->rq_server->sv_stats->rpcbadfmt++; out_drop: svc_drop(rqstp); } From patchwork Thu Jan 25 19:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531663 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACBF545C0B for ; Thu, 25 Jan 2024 19:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212421; cv=none; b=hEsjB/uGhPSpX69gwb1Jho2oWA4FYaeM/t15Zpckpz6md4DMYXBr4n4KEoCt+FRtRO2kK+TclYUKn/Xfvrhe0G4ENYfhjgkKf7P9tjq/NaT3gxg+N30LB0AiEASSgOpNkO4ecgPEMEpwJ7ExVj82yB9iKmnihGBzjR9sJohME/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212421; c=relaxed/simple; bh=5JQ1/M6bbxJsfyHx012U0mDRp/eH8t9frg0weJDiN9M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ib2Qy+VDi6CNrSC96NwBLlOrBWLHzYDOE9G4UiHbYTuNjEiDYiLCiptQzYjx/w1u7bhKmUlErW2jRjgN6uxXdpEoLhcunVJDfICyBOewKRkzUNO21tSwYzHQxIUYShdf+3Ryk7easZd5QlocCBX3+ciYYMI5R8UdpwjxfFxllpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=NFVjasuZ; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="NFVjasuZ" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-5ff828b93f0so65312527b3.3 for ; Thu, 25 Jan 2024 11:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212418; x=1706817218; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TN9NkdmlW/r4hsktKj1asTsOnKMChQLhJUHVox7Fcng=; b=NFVjasuZCBLCnnV4GzMkjlrpz+bTgQ3k5rBKuufq7AgBBcpUJPKEDPymspAvoPz47j F1OEpptDaAqyxV/C1Behz1VveM211pirHF6v6k5OuOe8HXfysJUgl5wj1bDwx9IhcZ/j tTYA/6cxA8mJJ8g/N9E9nhj/PwrP5NlKQaT2EJeJLAb3Hv6rVjhfyHOMeBKcUGOE/3Zx a/ziebf/b32kkE9lQWEpcUl9fSSZLNZPNq52tkaJ4S5RzuQiEAudLCWtkrp6xQTCseVu vDL8/rsShtMGmc924Q4NQZUJ4VRaIprxxXkuwYqJgs0DSsCEkWw19fL0GEy8HcA5/QLt EXog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212418; x=1706817218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TN9NkdmlW/r4hsktKj1asTsOnKMChQLhJUHVox7Fcng=; b=KbfH6NnMMna/ubVFAGFA8lTYXUQTqF9H+Eeamnvzf+wrgM1G2mhiTlAAE098HxklxJ rJtNMYByjYYNm+sGF23djnsNHcAFxVlUwwEWj8+9NZZNwoR+pIC9J40BOqOn4qw2ai7T l5/I+yfUkER3MP3lVfRKB8Hisfgj42Y3etGuMJEiNrDMmmAGE3p9oG6wtzBJErFBswWe y0S4eItxYbScxelkEK/GLTNypKVRfVM5eiG4Ywpz7TBxv1uoSQ3Jnv9sdNuHneqVPc36 ylJxGdF91u7bmRnZKtGe1v9+va3tMntcpK/dVj254q//6CfQL4YFDWbAU8gDjj7QJSBU Lu9g== X-Gm-Message-State: AOJu0YwwT6SP9ahdbL8ycDD3WUnqvdPpXR3cgLQUer0ZYObjTZot0500 /gzXijeSK1lYElW+29hSiH74qtyMlAUG2pwuPkyvebU9l7F8jOjDijeuj/0jET8p7yQ0gwIg/g7 y X-Google-Smtp-Source: AGHT+IEihT4vJuk6uQQMRhBdBOrk+URoheLYpMxQ73aJpgtetr5hpmhjgI162c9YHQAOFNn6oVZ5jw== X-Received: by 2002:a81:ce07:0:b0:5ff:7cb4:d200 with SMTP id t7-20020a81ce07000000b005ff7cb4d200mr363388ywi.17.1706212418439; Thu, 25 Jan 2024 11:53:38 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id hc5-20020a05690c480500b005ff952f0073sm860476ywb.11.2024.01.25.11.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:38 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 02/13] nfs: stop setting ->pg_stats for unused stats Date: Thu, 25 Jan 2024 14:53:12 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A lot of places are setting a blank svc_stats in ->pg_stats and never utilizing these stats. Remove all of these extra structs as we're not reporting these stats anywhere. Signed-off-by: Josef Bacik --- fs/lockd/svc.c | 3 --- fs/nfs/callback.c | 3 --- fs/nfsd/nfssvc.c | 5 ----- 3 files changed, 11 deletions(-) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index ce5862482097..ab8042a5b895 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -710,8 +710,6 @@ static const struct svc_version *nlmsvc_version[] = { #endif }; -static struct svc_stat nlmsvc_stats; - #define NLM_NRVERS ARRAY_SIZE(nlmsvc_version) static struct svc_program nlmsvc_program = { .pg_prog = NLM_PROGRAM, /* program number */ @@ -719,7 +717,6 @@ static struct svc_program nlmsvc_program = { .pg_vers = nlmsvc_version, /* version table */ .pg_name = "lockd", /* service name */ .pg_class = "nfsd", /* share authentication with nfsd */ - .pg_stats = &nlmsvc_stats, /* stats table */ .pg_authenticate = &lockd_authenticate, /* export authentication */ .pg_init_request = svc_generic_init_request, .pg_rpcbind_set = svc_generic_rpcbind_set, diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 760d27dd7225..8adfcd4c8c1a 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -356,15 +356,12 @@ static const struct svc_version *nfs4_callback_version[] = { [4] = &nfs4_callback_version4, }; -static struct svc_stat nfs4_callback_stats; - static struct svc_program nfs4_callback_program = { .pg_prog = NFS4_CALLBACK, /* RPC service number */ .pg_nvers = ARRAY_SIZE(nfs4_callback_version), /* Number of entries */ .pg_vers = nfs4_callback_version, /* version table */ .pg_name = "NFSv4 callback", /* service name */ .pg_class = "nfs", /* authentication class */ - .pg_stats = &nfs4_callback_stats, .pg_authenticate = nfs_callback_authenticate, .pg_init_request = svc_generic_init_request, .pg_rpcbind_set = svc_generic_rpcbind_set, diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 9a894c3511ba..a0b117107e86 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -80,7 +80,6 @@ unsigned long nfsd_drc_max_mem; unsigned long nfsd_drc_mem_used; #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) -static struct svc_stat nfsd_acl_svcstats; static const struct svc_version *nfsd_acl_version[] = { # if defined(CONFIG_NFSD_V2_ACL) [2] = &nfsd_acl_version2, @@ -99,15 +98,11 @@ static struct svc_program nfsd_acl_program = { .pg_vers = nfsd_acl_version, .pg_name = "nfsacl", .pg_class = "nfsd", - .pg_stats = &nfsd_acl_svcstats, .pg_authenticate = &svc_set_client, .pg_init_request = nfsd_acl_init_request, .pg_rpcbind_set = nfsd_acl_rpcbind_set, }; -static struct svc_stat nfsd_acl_svcstats = { - .program = &nfsd_acl_program, -}; #endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */ static const struct svc_version *nfsd_version[] = { From patchwork Thu Jan 25 19:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531666 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC8A41353F3 for ; Thu, 25 Jan 2024 19:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212423; cv=none; b=afH3Qd1fZv4Osc9vxAnTeeHShSYobGhnarfdupFnb6sEZIg0km+NOdlWKBWmI1QxaDTrpyoILFsVSaPi1kfcjXGzJeG5yxVjTwBPgKAKoXcs20AE70oETN9ZwNkDkRzIDFOHAksNsffFALcZo3q7cCrSFvWOilHS4VVL3cuOWWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212423; c=relaxed/simple; bh=k0ZWQi7GO3PvAug3PkTcFZb0EOU6br9+6/ZLyJ3Ee30=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K/Tq37S47Dwr2sG0NOPTT7z7aBnY7SUNdg1g7lrFv9U4SE+qY/UTAXVwm+uJhgDympoAOEJQ/WmsL4HdE8PjhRkO7UGVXUCp4d1HbDEVuPXSnPmweUgPYgToflJkhu2VtZMCVrhurgghGL96eASn756bT77w2unXHO4S814s+aM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=NDGfdSnE; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="NDGfdSnE" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-5f0629e67f4so75260887b3.3 for ; Thu, 25 Jan 2024 11:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212420; x=1706817220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fG75po66mqMBkWZW2dndPBmzyrMVNjybCLjhWLXsNwY=; b=NDGfdSnE0zMKHc783zCfwe/HDestAXkqtfPPT6mtBX4YtEonfS9wdirrs0/kNeXxdw Y/4rAmX8EWMD2WZGTnB4T4Go0n7ZexMXU30FqiZRBXh26juqP40NaLNK7oPLbx/oSXbw AmQeBsF+Fk67MnwdT9XyBCQG3H6yEc7pwuSSWZ7xic+nCX+ruBdyKkLLy7GgGOT7cAWp e2NhNn2fe/ETkz2XWRP/V48We+ZwiPA5WT+b3CEqXDKH10N5wlWsrzfvVbNnxU50gaw8 ZnuwEg7ydt9udNAYod7+Paf5WvVkoQ4mMPfK//r9ap3vWz5jyJ/9/3ec+tAEfPIFd+Hv x2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212420; x=1706817220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fG75po66mqMBkWZW2dndPBmzyrMVNjybCLjhWLXsNwY=; b=k1XIf6NQJycceV5sUCaBh85khhcyZ2JvMy5ipVQ4eO0nUncNplW7cVxxxylaJXaZIp Pmr2wUi702K9MQ3EWDMTORsIEOWDU0bqh7/KXq3i0eI4l4QsHWaZLV9xOspDQjPbclay 9cGQkNbt1y7cIXcbUHMbkTGSOVnSHe5WHRiwWIS/beFRlHeStwk0Ci42tGZI3UhvWZgc LeR6cvb4SiTZNuefUibaTwgpkylieRuOek1N9lU8PBEbpHm7ObUtbqLlbm7cLbwzQiPw eM9kUB07sQdQcSBbufQOyHOe56vB261CjCkTEKpD4S3z/yYs1fJ3MqGVDSEkPbZpYI0m kIgg== X-Gm-Message-State: AOJu0YwfPm1KPkzRZZg4/kFIN60Qa2E7zKBOyLIMbG8uWKwiJyMTRd9E cSR19a0wgnntzqXalck7yKXbLT9FxluIFozm2fXaFsvRzpwlaZNhW5mQ7CPvXJ+cMMKVudZkASR G X-Google-Smtp-Source: AGHT+IGU9R+Cbi4nQ/685/ANM/amMYIAmXoJiecZOYzJKlJR99EeegLQOALi9r+EHb4R0Y/13YaCeg== X-Received: by 2002:a05:690c:3507:b0:5f0:42de:8c3b with SMTP id fq7-20020a05690c350700b005f042de8c3bmr430671ywb.36.1706212419694; Thu, 25 Jan 2024 11:53:39 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id z133-20020a81658b000000b0060076613cbesm872319ywb.86.2024.01.25.11.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:39 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 03/13] sunrpc: pass in the sv_stats struct through svc_create* Date: Thu, 25 Jan 2024 14:53:13 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since only one service actually reports the rpc stats there's not much of a reason to have a pointer to it in the svc_program struct. Adjust the svc_create* functions to take the sv_stats as an argument and pass the struct through there as desired instead of getting it from the svc_program->pg_stats. Signed-off-by: Josef Bacik --- fs/lockd/svc.c | 2 +- fs/nfs/callback.c | 2 +- fs/nfsd/nfssvc.c | 3 ++- include/linux/sunrpc/svc.h | 8 ++++---- net/sunrpc/svc.c | 17 ++++++++++------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index ab8042a5b895..8fbbfc9aad69 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -337,7 +337,7 @@ static int lockd_get(void) nlm_timeout = LOCKD_DFLT_TIMEO; nlmsvc_timeout = nlm_timeout * HZ; - serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, lockd); + serv = svc_create(&nlmsvc_program, NULL, LOCKD_BUFSIZE, lockd); if (!serv) { printk(KERN_WARNING "lockd_up: create service failed\n"); return -ENOMEM; diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 8adfcd4c8c1a..4d56b4e73525 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -202,7 +202,7 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion) if (minorversion) return ERR_PTR(-ENOTSUPP); #endif - serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, + serv = svc_create(&nfs4_callback_program, NULL, NFS4_CALLBACK_BUFSIZE, threadfn); if (!serv) { printk(KERN_ERR "nfs_callback_create_svc: create service failed\n"); diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index a0b117107e86..d640f893021a 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -661,7 +661,8 @@ int nfsd_create_serv(struct net *net) if (nfsd_max_blksize == 0) nfsd_max_blksize = nfsd_get_default_max_blksize(); nfsd_reset_versions(nn); - serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, nfsd); + serv = svc_create_pooled(&nfsd_program, &nfsd_svcstats, + nfsd_max_blksize, nfsd); if (serv == NULL) return -ENOMEM; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 67cf1c9efd80..2a1447fa5ef2 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -402,8 +402,8 @@ struct svc_procedure { int svc_rpcb_setup(struct svc_serv *serv, struct net *net); void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net); int svc_bind(struct svc_serv *serv, struct net *net); -struct svc_serv *svc_create(struct svc_program *, unsigned int, - int (*threadfn)(void *data)); +struct svc_serv *svc_create(struct svc_program *, struct svc_stat *, + unsigned int, int (*threadfn)(void *data)); struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node); bool svc_rqst_replace_page(struct svc_rqst *rqstp, @@ -411,8 +411,8 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, void svc_rqst_release_pages(struct svc_rqst *rqstp); void svc_rqst_free(struct svc_rqst *); void svc_exit_thread(struct svc_rqst *); -struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, - int (*threadfn)(void *data)); +struct svc_serv * svc_create_pooled(struct svc_program *, struct svc_stat *, + unsigned int, int (*threadfn)(void *data)); int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); int svc_pool_stats_open(struct svc_info *si, struct file *file); void svc_process(struct svc_rqst *rqstp); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index d2e6f3d59218..f76ef8a3dd43 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -451,8 +451,8 @@ __svc_init_bc(struct svc_serv *serv) * Create an RPC service */ static struct svc_serv * -__svc_create(struct svc_program *prog, unsigned int bufsize, int npools, - int (*threadfn)(void *data)) +__svc_create(struct svc_program *prog, struct svc_stat *stats, + unsigned int bufsize, int npools, int (*threadfn)(void *data)) { struct svc_serv *serv; unsigned int vers; @@ -463,7 +463,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, return NULL; serv->sv_name = prog->pg_name; serv->sv_program = prog; - serv->sv_stats = prog->pg_stats; + serv->sv_stats = stats; if (bufsize > RPCSVC_MAXPAYLOAD) bufsize = RPCSVC_MAXPAYLOAD; serv->sv_max_payload = bufsize? bufsize : 4096; @@ -521,34 +521,37 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, /** * svc_create - Create an RPC service * @prog: the RPC program the new service will handle + * @stats: the stats struct if desired * @bufsize: maximum message size for @prog * @threadfn: a function to service RPC requests for @prog * * Returns an instantiated struct svc_serv object or NULL. */ -struct svc_serv *svc_create(struct svc_program *prog, unsigned int bufsize, - int (*threadfn)(void *data)) +struct svc_serv *svc_create(struct svc_program *prog, struct svc_stat *stats, + unsigned int bufsize, int (*threadfn)(void *data)) { - return __svc_create(prog, bufsize, 1, threadfn); + return __svc_create(prog, stats, bufsize, 1, threadfn); } EXPORT_SYMBOL_GPL(svc_create); /** * svc_create_pooled - Create an RPC service with pooled threads * @prog: the RPC program the new service will handle + * @stats: the stats struct if desired * @bufsize: maximum message size for @prog * @threadfn: a function to service RPC requests for @prog * * Returns an instantiated struct svc_serv object or NULL. */ struct svc_serv *svc_create_pooled(struct svc_program *prog, + struct svc_stat *stats, unsigned int bufsize, int (*threadfn)(void *data)) { struct svc_serv *serv; unsigned int npools = svc_pool_map_get(); - serv = __svc_create(prog, bufsize, npools, threadfn); + serv = __svc_create(prog, stats, bufsize, npools, threadfn); if (!serv) goto out_err; return serv; From patchwork Thu Jan 25 19:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531665 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD9813541E for ; Thu, 25 Jan 2024 19:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212423; cv=none; b=YuBQBw8clF7XI+oA0t4K5mEMGEXXzOhkhl43Up6C158W7vvpWV5i4Vgj0thBSyBC4OYtHGPZ656U4BNTk7zyW5XqbagE4YkRsuTXx+QPkd4FHUqWLWDptkZSCdyQvQ+99k8rTnY7xztkSSqcnxje7BS2FGqu2TTemzFmUBqjugs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212423; c=relaxed/simple; bh=DK5JO52DT0dw2uiHgctXjiifyDwEk2mR2WAVlrMnokk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cjQGyJoAmEEpT7kxsRTJ0VMTwXYDqHjYYpgn//u/6xYnazQ3UnjQg950PzRaEDt5Txhb047Jz6JblLMjrWRxveleuUpkX+RQSEwcsCyEqCkbQZp/YIAHteB4cFtczYwdW5FsSdJBaDEIpPlT5S/yF4qmG6L3vPY+ghCLyZopzKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=aCTIuBOI; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="aCTIuBOI" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-5ff7a8b5e61so63178237b3.2 for ; Thu, 25 Jan 2024 11:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212420; x=1706817220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bTIRqRIe5iARQFVR6OdQoP/uZDt3nDN1SfyB1LDrOKI=; b=aCTIuBOIygUkRv7x80ptomLilWgVap2t5nXp42nKjjA9G8okcWo0cRNdjG+gbxplrU eR/4VwTu3GpB/z3yioPdoXc7vaDEVbt4AUBn14awTZF7Hra/7YuTCRoNAvIdMznimDew GeEA1T0wi86O8s2yMTBvN9H3SEFYa1xdEE9G9jEwvQRfLmjW0km5wOoScVMO9eUuhxua N0kdFf8Pnio5jcVLGUXxVD0SA9hkci10CH1zJ08rv7kS83/AMNVQO9cTUrwPzLjoFAY7 Kx337ZV9QQYA6qKG0kTdqbRPZQAeAeuBgsbQMjT90Im/y1VXyxbbT58u+sMOBakXYSzq bcsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212420; x=1706817220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bTIRqRIe5iARQFVR6OdQoP/uZDt3nDN1SfyB1LDrOKI=; b=xRZXrbR117dOPtEcGe81FQGZrrY9hIdiouxCmRwxYegy1Mw4Rp0NanH4lDz4QfPZbX aEXESEh3B+TTZsuSYLBivqKwyT3JBkFKWIynR/FwUFh4Stsd4XdUNDBB98g54sj+18pk VqjAwqkWmGq/3AdkxO3kd7kvrKy4KyYxbLLYBZ70SBQFhD77Y3OcEKXalRi4YkJXP/JA LTXMz6eHaqHGcGhXKm0K4oLaVtlthNHmPn/T/iTrpY2difli6Uwd117ryoRoVzlVxM3L 02UtL6lZVrLCbius19FV8IYaaktmLbfPxQUxY0UOX2hSUzFrXDsAVaSZFCcYLmSt46pi 4YVA== X-Gm-Message-State: AOJu0YyCkRSta7RflPkzcJjsm/2IUWd82rZTVwIgAGnxBcUDfEm/lCjF mNjcneU+xomB706D1h9sxd6B4gs+HCAyiVQlWXF8DdH2oRKZ8N161VHVNoAeK1oL0Kt03uyDcbk p X-Google-Smtp-Source: AGHT+IGFaSNMCjDnMNm9PPSeVZz4AY6+MWwarcn2HyZndbnmqXqr1fG75vcQ036i0xi8L5RLrxbKow== X-Received: by 2002:a0d:d448:0:b0:600:255e:9320 with SMTP id w69-20020a0dd448000000b00600255e9320mr375564ywd.21.1706212420620; Thu, 25 Jan 2024 11:53:40 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id cd8-20020a05690c088800b005ffd0571b06sm856606ywb.4.2024.01.25.11.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:40 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 04/13] sunrpc: remove ->pg_stats from svc_program Date: Thu, 25 Jan 2024 14:53:14 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that this isn't used anywhere, remove it. Signed-off-by: Josef Bacik --- fs/nfsd/nfssvc.c | 1 - include/linux/sunrpc/svc.h | 1 - 2 files changed, 2 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index d640f893021a..d98a6abad990 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -127,7 +127,6 @@ struct svc_program nfsd_program = { .pg_vers = nfsd_version, /* version table */ .pg_name = "nfsd", /* program name */ .pg_class = "nfsd", /* authentication class */ - .pg_stats = &nfsd_svcstats, /* version table */ .pg_authenticate = &svc_set_client, /* export authentication */ .pg_init_request = nfsd_init_request, .pg_rpcbind_set = nfsd_rpcbind_set, diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 2a1447fa5ef2..9745ac61d83d 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -339,7 +339,6 @@ struct svc_program { const struct svc_version **pg_vers; /* version array */ char * pg_name; /* service name */ char * pg_class; /* class name: services sharing authentication */ - struct svc_stat * pg_stats; /* rpc statistics */ enum svc_auth_status (*pg_authenticate)(struct svc_rqst *rqstp); __be32 (*pg_init_request)(struct svc_rqst *, const struct svc_program *, From patchwork Thu Jan 25 19:53:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531667 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDEBF1339B2 for ; Thu, 25 Jan 2024 19:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212424; cv=none; b=BL7ULf263rSHVu0i2LCs9G+UaErYzR+ut2Ff8nomsFHDswTh3NZN0dbSUFs8Oa388QJcq7VsVyfOWiAoAQzYgqeF0x9dP1m3gYBqHzdkCY3PM+kuFxE/57mZTmwngPkyJMdwlp7TsC4Sn1fRwpQ6fP0C7SuvQH8PdPrzeAwcDds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212424; c=relaxed/simple; bh=BqIK57GIa16QrlYmc+J5NJ1hTtuWen/iHq9iXCjlXxo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ba8xHD0PpAZXyaku6ser00EzCxDWAo/ZIqEx4EfdMQ5Wo0oFEJrnSd6N9iK++mDYnPMfr92Mmy5ZkX9FK2GucV6xL4mZIssKd+cZkXAOi4JBfqqbwRwzNppIpxSUxrw81bMsBM5tTsByfE5z0aarjtAeRaGY1aCfqocAyJ62bck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=ps+26CUh; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="ps+26CUh" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-5ebca94cf74so70549787b3.0 for ; Thu, 25 Jan 2024 11:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212421; x=1706817221; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0hyRY1P1IhywJGt2LJ0HW1TDW87f//AJSkNUh4WBQJY=; b=ps+26CUhbq7h7xmWmeZZ9LAFcXpH/Z/PG8LDKTpSPiMtorn5d56PcBiAqn1lifm1UH 871wtBdAR3fj6SOMmxzMdS5JLcAglfeXLoZwAkq06A7P0ECQn0ygRAO7wROTIs2urKkM kKJYtbv3LdjFmTwYw+ak0sStsrXzGjoJPy0/f1H3BF1lza25rne+VRaLlNHIbehA35w/ 2leXPz/rYoDwXKuomiUN0XxeB59FeIWcs12A7l+tD2FEnEvKOi9eZjH0uCJhDLje3Env kynBLsQKcXt0tOLNIMA73GeFrGFxg0TstelLGdpno6g/ErSh/4tF2O37YOvKC69juR1k 1j0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212421; x=1706817221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0hyRY1P1IhywJGt2LJ0HW1TDW87f//AJSkNUh4WBQJY=; b=TvorplCpPSW5Ystm0wXZkjD9LwV1zRrN2DAVwgo+snp7/5Y3+1AmMgRVJXgOBoxiYP zTjJb5o79S+pokuaqr3JypFBoHzGsd/7iG+PWz7kc+fyqowFsN+OCB0RnVB8I/yr5cxn n97dwBu54VDh0jut0Nj4db39Y7i6XVDP8ISA4oAKuG9XXgwpRsEsDBF54WjEHqe8QxEg httYWTBq+WBoNnrUoi58yaKM4+roiOii0su9X+spn4E1T/84cJpfNvMeZPkwTp5ghMzA +Jc96AyXooLd6WV5NDpdqR1O5bD/dRO4UQPNAdfbydo8j530S1osq4dFIsbsMX6qAGyt mn/w== X-Gm-Message-State: AOJu0YzEkAmHr/4uR7mq3hnQr/960Fntzvl15WBAMrGF2AduegGGQi6p LeiuRn3UeBNIfz6Ee0ai12oGBw6PnY46Civ34AtIHWXTAMm8iwAzN3qRaxVe/LXUJeVCzMxz565 J X-Google-Smtp-Source: AGHT+IGBnQ0x0mrcLh2JXW/5Ki/ILvyU19xKrXt/MKngkasuffJ5umzDyZupu6h+Nf6GN4dhtjk2oA== X-Received: by 2002:a0d:dd0c:0:b0:5ff:913b:1d56 with SMTP id g12-20020a0ddd0c000000b005ff913b1d56mr348276ywe.6.1706212421422; Thu, 25 Jan 2024 11:53:41 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id d13-20020a0ddb0d000000b005f900790763sm874900ywe.49.2024.01.25.11.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:41 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 05/13] sunrpc: add a struct rpc_stats arg to rpc_create_args Date: Thu, 25 Jan 2024 14:53:15 -0500 Message-ID: <4cc2a7aca55ff56ac3ced32aafa861f57f59db02.1706212208.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We want to be able to have our rpc stats handled in a per network namespace manner, so add an option to rpc_create_args to specify a different rpc_stats struct instead of using the one on the rpc_program. Signed-off-by: Josef Bacik --- fs/nfs/client.c | 2 +- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 44eca51b2808..590be14f182f 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -73,7 +73,7 @@ const struct rpc_program nfs_program = { .number = NFS_PROGRAM, .nrvers = ARRAY_SIZE(nfs_version), .version = nfs_version, - .stats = &nfs_rpcstat, + .stats = &nfs_rpcstat, .pipe_dir_name = NFS_PIPE_DIRNAME, }; diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 5e9d1469c6fa..5321585c778f 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -139,6 +139,7 @@ struct rpc_create_args { const char *servername; const char *nodename; const struct rpc_program *program; + struct rpc_stat *stats; u32 prognumber; /* overrides program->number */ u32 version; rpc_authflavor_t authflavor; diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index cda0935a68c9..bc8c209fc0c7 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -405,7 +405,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, clnt->cl_maxproc = version->nrprocs; clnt->cl_prog = args->prognumber ? : program->number; clnt->cl_vers = version->number; - clnt->cl_stats = program->stats; + clnt->cl_stats = args->stats ? : program->stats; clnt->cl_metrics = rpc_alloc_iostats(clnt); rpc_init_pipe_dir_head(&clnt->cl_pipedir_objects); err = -ENOMEM; From patchwork Thu Jan 25 19:53:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531668 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9816D135A7C for ; Thu, 25 Jan 2024 19:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212425; cv=none; b=WRDO5tdIYRXTMhAO1m66WSHczqHiubcq+wTEVcM/i5hOT+NA0Js+bY2mwTJNKAflZ9NYHaUegIpUxCbG61e7pLRmCvNwL46rmtboV5/4fK5Qq0rOtMZrQyQ5O1ddzuCOQHp+nG/w6y4++ut5JDBn6M3OhpP9J0w3XQt9/RqwCzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212425; c=relaxed/simple; bh=oPo2HSHbqQg92hg+sIJI4A54+JArwH/DlZtupCaGy64=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZzHRYkCD+A66OGz6k6BDQ3bB/EmG3VubFJVsxV1wwcco5WNm4S6miBuUX6tBnVw3in2G+gdi/9BF5zq+7Ez0TJZ7obwWPOlWuHUhOanBfacTMtgV5PSErQVyn0l+amMD6ECgqzVFTrHzjH/9fER0GXizK8BTxZIM7yc1CYIl918= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=gDJTfzQ/; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="gDJTfzQ/" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-db4364ecd6aso4644822276.2 for ; Thu, 25 Jan 2024 11:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212422; x=1706817222; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3IiehwB2G+Nt2uBxPih15JoYIXyWwYzVUYGRXkPDnck=; b=gDJTfzQ/nvntbwA9om9aELW9sFH08NeiFIK2NvcxYDcux3c4hKxVt8TqLra4yiTzGc hEG0Mm7NVBlxsSaDm+eUTz8vjC/BoVUOEOKpUxil9Waqw4acP9fmSrqaAbLUnOS3XB+t VUo5Xa/OdNhao4E70gkbeH+rfV6rwv+46lILH4uSxMJzbvRbqrAMDcMOAr1gbTY7hLo8 jZFXvJaAMkrRXV7RhkM4GB8kkNfBuSVTjXqjbxs5gsX2D7eZnb6NYiWan6Z0Oo/x7uw/ tqWePSoy9Vgrtg7eblcp1mDcT9u8DmKQc6stPDW/Glzuemul+sclHYF03+Iboe69RMKz 017w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212422; x=1706817222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3IiehwB2G+Nt2uBxPih15JoYIXyWwYzVUYGRXkPDnck=; b=aWtrE2mak0DrlR1balpRFob1DsVt7fjc6Z9a8AyqldJSB+IZyTYjTIgCgrgi2+yyPJ kx3hXr84TIH4rJ696OK2FXcg1oOSCEKgrP9TgtcImVStj83I2U440N1Shi9lt/SijKNy drslhs0W89n6K1UBbmRh8ozaZBtqBkSCB5fV+u/weyVO72umUv3oUpKFZM+x47qXL5bh dVofc0O8ty1YaA7RAMR0vNQfRk0HRAT02k+Rt60JVinMZG0xWz9g1V2RXhFqXwAuQ8Ij bbdD1HjdT1C2/v3mp2CAiZtsXSRn40ztIMqeCyvdNo+2vaadetSK8W/xOaJKe4hjJnls n9NQ== X-Gm-Message-State: AOJu0YyW7LBo/DLKekOrXxz9+I5HJiXVDsoEvyeCheu65f53eQFw/goY y8ZMeXRT88tyYFMQxlMjBjFyV0DU9LtrH8BITIdm4Zc9nwCPSABcH9NXPr5lu8wa9hx4tgOQkfi A X-Google-Smtp-Source: AGHT+IFMDlWF03RKSC83l3NeHQobNWKjGoPWLtQAHxdDJBanl1CeAPxc+gStJMVSBWECUNiCTUgslw== X-Received: by 2002:a25:838f:0:b0:dc2:279f:f7e with SMTP id t15-20020a25838f000000b00dc2279f0f7emr335563ybk.10.1706212422344; Thu, 25 Jan 2024 11:53:42 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id v14-20020a2583ce000000b00dc25400eda4sm3554187ybm.22.2024.01.25.11.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:42 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 06/13] sunrpc: use the struct net as the svc proc private Date: Thu, 25 Jan 2024 14:53:16 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 nfsd is the only thing using this helper, and it doesn't use the private currently. When we switch to per-network namespace stats we will need the struct net * in order to get to the nfsd_net. Use the net as the proc private so we can utilize this when we make the switch over. Signed-off-by: Josef Bacik --- net/sunrpc/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 65fc1297c6df..383860cb1d5b 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -314,7 +314,7 @@ EXPORT_SYMBOL_GPL(rpc_proc_unregister); struct proc_dir_entry * svc_proc_register(struct net *net, struct svc_stat *statp, const struct proc_ops *proc_ops) { - return do_register(net, statp->program->pg_name, statp, proc_ops); + return do_register(net, statp->program->pg_name, net, proc_ops); } EXPORT_SYMBOL_GPL(svc_proc_register); From patchwork Thu Jan 25 19:53:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531669 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78FC7136643 for ; Thu, 25 Jan 2024 19:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212426; cv=none; b=hfaChSavjmjafwqulrNw+rFM+kmPw2FFRH2T+rH5irPbZEtPgBQklEAXP35+AqUIYd6W0aCUkNHTY3dpf/SUTLX/nfgHnkL3b43XiiCiovJPhcrote5zDECFvzLqT2bn27oiMOvymACFwJQz9kR8Jb/4RvzoFyAaReM2zwD1nhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212426; c=relaxed/simple; bh=HYw7RJrKrn30ygP9WEHGLl9B1l9lIWNNnnl8a6T35kE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oaZHp4J7g6je/OgElM/6L6+PWXUFgHA7cxTNA71q6aVZP38Gswg74dwNtROHWFm22TeityfuVvH/spqL0SYA+p21KsWgvIpSql759vL6+5L2M4nt+Bt5IyzbLtlt+X5l6x4+O7qmz3BwJBk5q834DeHtZuuPq3n2XVq0Y/WfLf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=UwqG0ciW; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="UwqG0ciW" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-602a0a45dd6so20432357b3.1 for ; Thu, 25 Jan 2024 11:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212423; x=1706817223; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qhcT4LxscUNgYkzme87+B08aKhu2LGoP/3IfHmoLGzc=; b=UwqG0ciW8/AqiNzH7UMG/BO+wBzoDFiyeAGhg1NwJ7IzCLf9ujjc3t6Qp2SMFhRHkJ cPX6vGuHQkzLEZ1fPI102/qROO4fcQNBdRxv7W+RWiej32EYUEencPPM6RWqiAPInVJf JBTlPpy0BAjA+H03lXbMm0e8onh0/cNs8OKnGsMSYfMHdUD5H+NIbZOkkZa6Qw59/ouV 7napX/Lbvcsp+3x02L2oKOsaYpeo6/FXpLMChZVJ0+8s35nnjLrjpqVnyeJPxtPqpWnB +MOSzn2ygBc6aPJAp4Fd7Zu06hR5O7PtL26Ekx0Pk3TztGG7H2Zx1zbKqZBTED6R9soD qM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212423; x=1706817223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qhcT4LxscUNgYkzme87+B08aKhu2LGoP/3IfHmoLGzc=; b=ATG0jCOaRjQ/2obfCNiZCYFF7hy/+f4AbzceAH9tQ/mAcftdgkMhcWxBkj8q9QQtKx DrwfqFTTP4zyxyDJMr5HoNm8QQA6WRIcnTjk5HKg/cJvmF1nmIgmToeElshkzkJXbE5w 7Bvl6B1fazhnnCxybEMFnPiAPfkcQCoLFUTi4ryWa2WN1kMFAfU66+hakU9nS0dRDA4Q EEi0WwHpyE4rCyoAVX5EbCU78W5Ut3aKb7oNti0VDb3EgzgSaLtHmniTRje4COZK74NQ ZKLOME9o/lbOzmgTpxCRyUmELAGWB7VEJHJu93giaVAr2ZScRSdcJ83X9fJDAWPdb2Yf Gblw== X-Gm-Message-State: AOJu0YzrQ1sxsPSBstSJlCKkJof9qzk5HkamSDJlucEJU9Zd3gaL4cYQ PbgFg43r2nuQmNk2EemXoamGjcSRBlOvH3gQlRQR3y+zqhL/077aT0HVUBrGwp0iEGnsWdaBIEd 7 X-Google-Smtp-Source: AGHT+IEcVV5FZWaZpudtF4nG/BHtMqm2Ng/XQIsRu6owITdjzD+GgBIiEqJE13QrGZJ21iHtS7ZnEg== X-Received: by 2002:a81:ae21:0:b0:5ff:9903:8347 with SMTP id m33-20020a81ae21000000b005ff99038347mr327933ywh.64.1706212423291; Thu, 25 Jan 2024 11:53:43 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id d134-20020a0ddb8c000000b005ffd1bf706fsm866119ywe.96.2024.01.25.11.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:43 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 07/13] nfsd: rename NFSD_NET_* to NFSD_STATS_* Date: Thu, 25 Jan 2024 14:53:17 -0500 Message-ID: <3d99f0ca12126464c3cf6afa6d8cdff84bd3c5ea.1706212208.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We're going to merge the stats all into per network namespace in subsequent patches, rename these nn counters to be consistent with the rest of the stats. Signed-off-by: Josef Bacik --- fs/nfsd/netns.h | 4 ++-- fs/nfsd/nfscache.c | 4 ++-- fs/nfsd/stats.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 74b4360779a1..e3605cb5f044 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -26,9 +26,9 @@ struct nfsd4_client_tracking_ops; enum { /* cache misses due only to checksum comparison failures */ - NFSD_NET_PAYLOAD_MISSES, + NFSD_STATS_PAYLOAD_MISSES, /* amount of memory (in bytes) currently consumed by the DRC */ - NFSD_NET_DRC_MEM_USAGE, + NFSD_STATS_DRC_MEM_USAGE, NFSD_NET_COUNTERS_NUM }; diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 5c1a4a0aa605..3d4a9d181c43 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -687,7 +687,7 @@ int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) atomic_read(&nn->num_drc_entries)); seq_printf(m, "hash buckets: %u\n", 1 << nn->maskbits); seq_printf(m, "mem usage: %lld\n", - percpu_counter_sum_positive(&nn->counter[NFSD_NET_DRC_MEM_USAGE])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_DRC_MEM_USAGE])); seq_printf(m, "cache hits: %lld\n", percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_HITS])); seq_printf(m, "cache misses: %lld\n", @@ -695,7 +695,7 @@ int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) seq_printf(m, "not cached: %lld\n", percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE])); seq_printf(m, "payload misses: %lld\n", - percpu_counter_sum_positive(&nn->counter[NFSD_NET_PAYLOAD_MISSES])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_PAYLOAD_MISSES])); seq_printf(m, "longest chain len: %u\n", nn->longest_chain); seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize); return 0; diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h index 14f50c660b61..7ed4325ac691 100644 --- a/fs/nfsd/stats.h +++ b/fs/nfsd/stats.h @@ -81,17 +81,17 @@ static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount) static inline void nfsd_stats_payload_misses_inc(struct nfsd_net *nn) { - percpu_counter_inc(&nn->counter[NFSD_NET_PAYLOAD_MISSES]); + percpu_counter_inc(&nn->counter[NFSD_STATS_PAYLOAD_MISSES]); } static inline void nfsd_stats_drc_mem_usage_add(struct nfsd_net *nn, s64 amount) { - percpu_counter_add(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount); + percpu_counter_add(&nn->counter[NFSD_STATS_DRC_MEM_USAGE], amount); } static inline void nfsd_stats_drc_mem_usage_sub(struct nfsd_net *nn, s64 amount) { - percpu_counter_sub(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount); + percpu_counter_sub(&nn->counter[NFSD_STATS_DRC_MEM_USAGE], amount); } #ifdef CONFIG_NFSD_V4 From patchwork Thu Jan 25 19:53:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531670 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CCD7136651 for ; Thu, 25 Jan 2024 19:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212426; cv=none; b=Lg/qIq2RZ2QG8Q0z/Ignod7zzDj0STh/NdT6mC5Q3mOmDXN9Hxo2V68iQM2xFukdn5/ahU7Ty7aiMddPlTMs4NQ2IGnI8kLoUtVsxSPaDxHKAjJcMBZtBGnBoMSQ5BuBcVdWNrdzZyrlYs8bVEedjNaYSCUOlJ1MBRt7qJDLKYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212426; c=relaxed/simple; bh=oIVFoPMvY5SGkisb2sELX+f9WkOpaBpUfRMWGj42rI0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jNhbIwoY3lH0TZ6C82YaO4qi1CIcaQIKTQSLcVfQmIEdcwl1sW+PpXFRNRw+RyQXuR8fA2jn5ALHBIlvbbABbmXnP/n28kblj+Wgd3M+C6s1gK+Vu0uQtWfcgFchnIrjaA7FJGvt/mM2SEqvu76F3UnMFHAmUTKaYRYOMKEAW+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=UbIpu84M; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="UbIpu84M" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-600094c5703so45162837b3.3 for ; Thu, 25 Jan 2024 11:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212424; x=1706817224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Lbwexu1bLugmUgDGM5YUyVtPA9AXcJlbApt7mNBJh0E=; b=UbIpu84MVIo7ZpJBVs5zRJS4kD5evjCaPSajZ6z19y7zXjFkNqi9IEV0QkdonM889S kiplLMrwm//busfOgdmWVpk6ADExDG48x3Hsqn7bFgyM63wyrZKEvqLekrW+IVCjX0wv nUZP51oM4k+VN84JVWYzt0y8D3/Fhj5tB/WSi9F8A7kyDxv2kl3m1VGe9UNgn4t6e8cE kGc87xMJv2FgSvMt4w/50J3SKk4roHFahi85XvauLZ1TMFC5e14pW5wATWsCko9o0dB9 do4XbnuU7tTC2wEE6cVwdXvsjCnq6ATjb5epa1UzDuWeJggxuj+iVVgNcxBKFLq2BGVI bAuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212424; x=1706817224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lbwexu1bLugmUgDGM5YUyVtPA9AXcJlbApt7mNBJh0E=; b=lOVna9AFYtQ8YMWDPjlSnzZBSqoeXfsKeOH31+DCJnNk3QbXSruvO1JeeoWs0GyoJD xRCISN7preSAe7qVmudxoSHB+wQb7UdYUAOdMuMWd7I9njGl1Cgnd8klkOBRRJZP78kQ XCJXurZc04jXlfxtRg06ln1aCPNLH4Fup0O4LqpH/s1k2DVzO/JbA3oLrSaA9M7lwbvI bO1xwvoz6vUlBKcrcZuHGdrZYp92vUNXa9t4WFX/4gPfDNobsZsIVIjlJTbslrsVQzY2 l5fh1EtXyjjg59O4prz6YXXnj6TV2CRPkTNj5yQpsj5kyDQ5DGDbQFQAafH5oP0QN0Do uQTw== X-Gm-Message-State: AOJu0Yw6YskdOrOhJnKnvS5rbfywAng3+xfkueDmAQtiyvSb6PxEUgPi sxmMDoi1D/zs7hyk5P7myO6zfW1+PuxH1+TzAW53aw9qXiH8oFuav4bpD+xObYilIGNUrj8Mu4X Q X-Google-Smtp-Source: AGHT+IHiIaa4wPOAMB1jg4O7nLL39bDUaJUlY10BVxK/XODKB4QFmv7Mm6WTwbYk+jhhZL9GK2KNYw== X-Received: by 2002:a81:b654:0:b0:5ff:a9ae:4a81 with SMTP id h20-20020a81b654000000b005ffa9ae4a81mr304584ywk.77.1706212424204; Thu, 25 Jan 2024 11:53:44 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id i13-20020a81d50d000000b0060022aff36dsm844514ywj.107.2024.01.25.11.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:43 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 08/13] nfsd: expose /proc/net/sunrpc/nfsd in net namespaces Date: Thu, 25 Jan 2024 14:53:18 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We are running nfsd servers inside of containers with their own network namespace, and we want to monitor these services using the stats found in /proc. However these are not exposed in the proc inside of the container, so we have to bind mount the host /proc into our containers to get at this information. Separate out the stat counters init and the proc registration, and move the proc registration into the pernet operations entry and exit points so that these stats can be exposed inside of network namespaces. This is an intermediate step, this just exposes the global counters in the network namespace. Subsequent patches will move these counters into the per-network namespace container. Signed-off-by: Josef Bacik --- fs/nfsd/nfsctl.c | 8 +++++--- fs/nfsd/stats.c | 21 ++++++--------------- fs/nfsd/stats.h | 6 ++++-- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index f206ca32e7f5..b57480b50e35 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1679,6 +1679,7 @@ static __net_init int nfsd_net_init(struct net *net) nfsd4_init_leases_net(nn); get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key)); seqlock_init(&nn->writeverf_lock); + nfsd_proc_stat_init(net); return 0; @@ -1699,6 +1700,7 @@ static __net_exit void nfsd_net_exit(struct net *net) { struct nfsd_net *nn = net_generic(net, nfsd_net_id); + nfsd_proc_stat_shutdown(net); nfsd_net_reply_cache_destroy(nn); nfsd_idmap_shutdown(net); nfsd_export_shutdown(net); @@ -1722,7 +1724,7 @@ static int __init init_nfsd(void) retval = nfsd4_init_pnfs(); if (retval) goto out_free_slabs; - retval = nfsd_stat_init(); /* Statistics */ + retval = nfsd_stat_counters_init(); /* Statistics */ if (retval) goto out_free_pnfs; retval = nfsd_drc_slab_create(); @@ -1762,7 +1764,7 @@ static int __init init_nfsd(void) nfsd_lockd_shutdown(); nfsd_drc_slab_free(); out_free_stat: - nfsd_stat_shutdown(); + nfsd_stat_counters_destroy(); out_free_pnfs: nfsd4_exit_pnfs(); out_free_slabs: @@ -1780,7 +1782,7 @@ static void __exit exit_nfsd(void) nfsd_drc_slab_free(); remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs", NULL); - nfsd_stat_shutdown(); + nfsd_stat_counters_destroy(); nfsd_lockd_shutdown(); nfsd4_free_slabs(); nfsd4_exit_pnfs(); diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index 12d79f5d4eb1..394a65a33942 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c @@ -108,31 +108,22 @@ void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num) percpu_counter_destroy(&counters[i]); } -static int nfsd_stat_counters_init(void) +int nfsd_stat_counters_init(void) { return nfsd_percpu_counters_init(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM); } -static void nfsd_stat_counters_destroy(void) +void nfsd_stat_counters_destroy(void) { nfsd_percpu_counters_destroy(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM); } -int nfsd_stat_init(void) +void nfsd_proc_stat_init(struct net *net) { - int err; - - err = nfsd_stat_counters_init(); - if (err) - return err; - - svc_proc_register(&init_net, &nfsd_svcstats, &nfsd_proc_ops); - - return 0; + svc_proc_register(net, &nfsd_svcstats, &nfsd_proc_ops); } -void nfsd_stat_shutdown(void) +void nfsd_proc_stat_shutdown(struct net *net) { - nfsd_stat_counters_destroy(); - svc_proc_unregister(&init_net, "nfsd"); + svc_proc_unregister(net, "nfsd"); } diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h index 7ed4325ac691..38811aa7d13e 100644 --- a/fs/nfsd/stats.h +++ b/fs/nfsd/stats.h @@ -40,8 +40,10 @@ extern struct svc_stat nfsd_svcstats; int nfsd_percpu_counters_init(struct percpu_counter *counters, int num); void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num); void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num); -int nfsd_stat_init(void); -void nfsd_stat_shutdown(void); +int nfsd_stat_counters_init(void); +void nfsd_stat_counters_destroy(void); +void nfsd_proc_stat_init(struct net *net); +void nfsd_proc_stat_shutdown(struct net *net); static inline void nfsd_stats_rc_hits_inc(void) { From patchwork Thu Jan 25 19:53:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531671 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AC6813665E for ; Thu, 25 Jan 2024 19:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212428; cv=none; b=ssMMHGEbSgcidTpBHbZ/8VqYgBv1NKDrPxKw4I4T6VcOo6pBEE9lFUW0R3oVhkG6dCistFWeLOC8zrizm7EGcxt/lygv1TZ71sv1zyWsfxqYnoMvmp4WLZvnjClXuIp38BRTkrtQaQx2cEhXWsAN9lhQBoHxrH2B+k+TYteJeGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212428; c=relaxed/simple; bh=kH4C69gXhYzpUQZNXdH8fdQsSdqyLfCEoP54BXBFA0U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UwmMSMCfeAevu1bDwgMxCiukjTbbUzZwLZl6kVPltBGdDtSRf653kDlsFlnTSQMzOYfYf9lhhNAnQ83OKL3am3y9BuVs+Yfcot09ktMTTX9oQ9Mdu+FqdqxM30tuSTFWnC0BMd7A4v00kAOhOIauYGZ5VoqlNCheDIbRINNanjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=0MfeoNrr; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="0MfeoNrr" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-602c714bdbeso1127117b3.1 for ; Thu, 25 Jan 2024 11:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212425; x=1706817225; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pPYWgezIyTTIaXhRwEKknhgUQv07nyNgQ9eiW6X1xO4=; b=0MfeoNrrRu3u1BadiiEkcgNJl/NlH4BgaX0oXpyjbuvkLD1nOF5dAjaXsGAmxVo83o hTvBvOuFVVu/mKvkM0+7Gz+Qhrb71SOI0hERGRg8lwQC66BNgCtJqqaJA3sJCTzVuMDH mp6LOrGcgSRTQyb3Y4ejKI0iQ2xxEx4Lwx9EgIWRyyG+ypMu4lwVKs6uIEBmEE/aeUlZ CgWl2BPHy5oQJwfSLe1SCn/WIEPup6HdAwxzyVHw85ePGYcVZrrGLk6sNHUPCFsZ3qyl 0fB0Oa+qeXSG+LgbDPO8E1m7y8kzS6WXwyVwVsdFPXMJ6tvp41324y6cUhfxQ7rep7i6 M3ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212425; x=1706817225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pPYWgezIyTTIaXhRwEKknhgUQv07nyNgQ9eiW6X1xO4=; b=Bi5svypjkuMXtJrBXp2s0Zx3ri42Y4WoVOKzcXuy+8LaqsKp+lYzK2eSLyWtIgh82L QhnzSNzToTEDSPPQuTsGvfKw1rF4RrFNwbck+gHeuMO5xmPA/YWqOF/5BSvUwYl4l+LZ IbUOF4YJxiSAmu1ao9FRcxpaVwNa05DDUC6efdH1EiIL7MFK3Yd2MmgQOfzVDzkEuoqf eSIa3aXnD9a2Hgc6QHdhs9bS9QJRmK1Kq242M26fxafYjz2LCAiz+QJftbar62Hu1uFr hQs29btsV/BfAuFwxYzO+95YSnHmR3Ec/bGzoiEZ4yJUSiXVZ9hKMbD8aqtNf6r8roW6 XmBA== X-Gm-Message-State: AOJu0YybErTg4759XhbklKVKHvHFC2G2xr04PrhKkw53USRJqkyzQR+D xPnNh4uOJFF+JDlBEMr167I0IDRLQsGBufhSzveXy6MSigTl0BVDS61+NE5NE+9uiIiEITtDMzH B X-Google-Smtp-Source: AGHT+IFsOzuXZk//qgRYJuivzgjH+lWF4lFiDhXOwk7PVdoNeNzae2rMkZQa8lF5kaippUhdt4JC2A== X-Received: by 2002:a0d:dfd8:0:b0:5ff:64d6:ee4e with SMTP id i207-20020a0ddfd8000000b005ff64d6ee4emr50517ywe.26.1706212425169; Thu, 25 Jan 2024 11:53:45 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id i18-20020a0ddf12000000b005ffd0b5988asm854691ywe.65.2024.01.25.11.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:44 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 09/13] nfsd: make all of the nfsd stats per-network namespace Date: Thu, 25 Jan 2024 14:53:19 -0500 Message-ID: <5887c5d18cfc60e1c83187d191c8fd85f022e98b.1706212208.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have a global set of counters that we modify for all of the nfsd operations, but now that we're exposing these stats across all network namespaces we need to make the stats also be per-network namespace. We already have some caching stats that are per-network namespace, so move these definitions into the same counter and then adjust all the helpers and users of these stats to provide the appropriate nfsd_net struct so that the stats are maintained for the per-network namespace objects. Signed-off-by: Josef Bacik --- fs/nfsd/cache.h | 2 -- fs/nfsd/netns.h | 17 ++++++++++++-- fs/nfsd/nfs4proc.c | 6 ++--- fs/nfsd/nfs4state.c | 3 ++- fs/nfsd/nfscache.c | 36 ++++++------------------------ fs/nfsd/nfsctl.c | 12 +++------- fs/nfsd/nfsfh.c | 3 ++- fs/nfsd/stats.c | 26 ++++++++++++---------- fs/nfsd/stats.h | 54 ++++++++++++++++----------------------------- fs/nfsd/vfs.c | 5 +++-- 10 files changed, 68 insertions(+), 96 deletions(-) diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h index 4cbe0434cbb8..66a05fefae98 100644 --- a/fs/nfsd/cache.h +++ b/fs/nfsd/cache.h @@ -80,8 +80,6 @@ enum { int nfsd_drc_slab_create(void); void nfsd_drc_slab_free(void); -int nfsd_net_reply_cache_init(struct nfsd_net *nn); -void nfsd_net_reply_cache_destroy(struct nfsd_net *nn); int nfsd_reply_cache_init(struct nfsd_net *); void nfsd_reply_cache_shutdown(struct nfsd_net *); int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index e3605cb5f044..0cef4bb407a9 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,19 @@ enum { NFSD_STATS_PAYLOAD_MISSES, /* amount of memory (in bytes) currently consumed by the DRC */ NFSD_STATS_DRC_MEM_USAGE, - NFSD_NET_COUNTERS_NUM + NFSD_STATS_RC_HITS, /* repcache hits */ + NFSD_STATS_RC_MISSES, /* repcache misses */ + NFSD_STATS_RC_NOCACHE, /* uncached reqs */ + NFSD_STATS_FH_STALE, /* FH stale error */ + NFSD_STATS_IO_READ, /* bytes returned to read requests */ + NFSD_STATS_IO_WRITE, /* bytes passed in write requests */ +#ifdef CONFIG_NFSD_V4 + NFSD_STATS_FIRST_NFS4_OP, /* count of individual nfsv4 operations */ + NFSD_STATS_LAST_NFS4_OP = NFSD_STATS_FIRST_NFS4_OP + LAST_NFS4_OP, +#define NFSD_STATS_NFS4_OP(op) (NFSD_STATS_FIRST_NFS4_OP + (op)) + NFSD_STATS_WDELEG_GETATTR, /* count of getattr conflict with wdeleg */ +#endif + NFSD_STATS_COUNTERS_NUM }; /* @@ -164,7 +177,7 @@ struct nfsd_net { atomic_t num_drc_entries; /* Per-netns stats counters */ - struct percpu_counter counter[NFSD_NET_COUNTERS_NUM]; + struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM]; /* longest hash chain seen */ unsigned int longest_chain; diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 14712fa08f76..648ff427005e 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2490,10 +2490,10 @@ nfsd4_proc_null(struct svc_rqst *rqstp) return rpc_success; } -static inline void nfsd4_increment_op_stats(u32 opnum) +static inline void nfsd4_increment_op_stats(struct nfsd_net *nn, u32 opnum) { if (opnum >= FIRST_NFS4_OP && opnum <= LAST_NFS4_OP) - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_NFS4_OP(opnum)]); + percpu_counter_inc(&nn->counter[NFSD_STATS_NFS4_OP(opnum)]); } static const struct nfsd4_operation nfsd4_ops[]; @@ -2768,7 +2768,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) status, nfsd4_op_name(op->opnum)); nfsd4_cstate_clear_replay(cstate); - nfsd4_increment_op_stats(op->opnum); + nfsd4_increment_op_stats(nn, op->opnum); } fh_put(current_fh); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index fbf8b426950e..83c260ab485d 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -8457,6 +8457,7 @@ __be32 nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) { __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct file_lock_context *ctx; struct file_lock *fl; struct nfs4_delegation *dp; @@ -8486,7 +8487,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) } break_lease: spin_unlock(&ctx->flc_lock); - nfsd_stats_wdeleg_getattr_inc(); + nfsd_stats_wdeleg_getattr_inc(nn); status = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ)); if (status != nfserr_jukebox || !nfsd_wait_for_delegreturn(rqstp, inode)) diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 3d4a9d181c43..cfcc6ac8f255 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -176,27 +176,6 @@ void nfsd_drc_slab_free(void) kmem_cache_destroy(drc_slab); } -/** - * nfsd_net_reply_cache_init - per net namespace reply cache set-up - * @nn: nfsd_net being initialized - * - * Returns zero on succes; otherwise a negative errno is returned. - */ -int nfsd_net_reply_cache_init(struct nfsd_net *nn) -{ - return nfsd_percpu_counters_init(nn->counter, NFSD_NET_COUNTERS_NUM); -} - -/** - * nfsd_net_reply_cache_destroy - per net namespace reply cache tear-down - * @nn: nfsd_net being freed - * - */ -void nfsd_net_reply_cache_destroy(struct nfsd_net *nn) -{ - nfsd_percpu_counters_destroy(nn->counter, NFSD_NET_COUNTERS_NUM); -} - int nfsd_reply_cache_init(struct nfsd_net *nn) { unsigned int hashsize; @@ -501,7 +480,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct nfsd_cacherep *key, int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, unsigned int len, struct nfsd_cacherep **cacherep) { - struct nfsd_net *nn; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct nfsd_cacherep *rp, *found; __wsum csum; struct nfsd_drc_bucket *b; @@ -510,7 +489,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, int rtn = RC_DOIT; if (type == RC_NOCACHE) { - nfsd_stats_rc_nocache_inc(); + nfsd_stats_rc_nocache_inc(nn); goto out; } @@ -520,7 +499,6 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, * Since the common case is a cache miss followed by an insert, * preallocate an entry. */ - nn = net_generic(SVC_NET(rqstp), nfsd_net_id); rp = nfsd_cacherep_alloc(rqstp, csum, nn); if (!rp) goto out; @@ -537,7 +515,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, nfsd_cacherep_dispose(&dispose); - nfsd_stats_rc_misses_inc(); + nfsd_stats_rc_misses_inc(nn); atomic_inc(&nn->num_drc_entries); nfsd_stats_drc_mem_usage_add(nn, sizeof(*rp)); goto out; @@ -545,7 +523,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start, found_entry: /* We found a matching entry which is either in progress or done. */ nfsd_reply_cache_free_locked(NULL, rp, nn); - nfsd_stats_rc_hits_inc(); + nfsd_stats_rc_hits_inc(nn); rtn = RC_DROPIT; rp = found; @@ -689,11 +667,11 @@ int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) seq_printf(m, "mem usage: %lld\n", percpu_counter_sum_positive(&nn->counter[NFSD_STATS_DRC_MEM_USAGE])); seq_printf(m, "cache hits: %lld\n", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_HITS])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS])); seq_printf(m, "cache misses: %lld\n", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_MISSES])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES])); seq_printf(m, "not cached: %lld\n", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE])); seq_printf(m, "payload misses: %lld\n", percpu_counter_sum_positive(&nn->counter[NFSD_STATS_PAYLOAD_MISSES])); seq_printf(m, "longest chain len: %u\n", nn->longest_chain); diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index b57480b50e35..ea3c8114245c 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1671,7 +1671,7 @@ static __net_init int nfsd_net_init(struct net *net) retval = nfsd_idmap_init(net); if (retval) goto out_idmap_error; - retval = nfsd_net_reply_cache_init(nn); + retval = nfsd_stat_counters_init(nn); if (retval) goto out_repcache_error; nn->nfsd_versions = NULL; @@ -1701,7 +1701,7 @@ static __net_exit void nfsd_net_exit(struct net *net) struct nfsd_net *nn = net_generic(net, nfsd_net_id); nfsd_proc_stat_shutdown(net); - nfsd_net_reply_cache_destroy(nn); + nfsd_stat_counters_destroy(nn); nfsd_idmap_shutdown(net); nfsd_export_shutdown(net); nfsd_netns_free_versions(nn); @@ -1724,12 +1724,9 @@ static int __init init_nfsd(void) retval = nfsd4_init_pnfs(); if (retval) goto out_free_slabs; - retval = nfsd_stat_counters_init(); /* Statistics */ - if (retval) - goto out_free_pnfs; retval = nfsd_drc_slab_create(); if (retval) - goto out_free_stat; + goto out_free_pnfs; nfsd_lockd_init(); /* lockd->nfsd callbacks */ retval = create_proc_exports_entry(); if (retval) @@ -1763,8 +1760,6 @@ static int __init init_nfsd(void) out_free_lockd: nfsd_lockd_shutdown(); nfsd_drc_slab_free(); -out_free_stat: - nfsd_stat_counters_destroy(); out_free_pnfs: nfsd4_exit_pnfs(); out_free_slabs: @@ -1782,7 +1777,6 @@ static void __exit exit_nfsd(void) nfsd_drc_slab_free(); remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs", NULL); - nfsd_stat_counters_destroy(); nfsd_lockd_shutdown(); nfsd4_free_slabs(); nfsd4_exit_pnfs(); diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index dbfa0ac13564..40fecf7b224f 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -327,6 +327,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) __be32 fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) { + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct svc_export *exp = NULL; struct dentry *dentry; __be32 error; @@ -395,7 +396,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) out: trace_nfsd_fh_verify_err(rqstp, fhp, type, access, error); if (error == nfserr_stale) - nfsd_stats_fh_stale_inc(exp); + nfsd_stats_fh_stale_inc(nn, exp); return error; } diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index 394a65a33942..44e275324b06 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c @@ -34,15 +34,17 @@ struct svc_stat nfsd_svcstats = { static int nfsd_show(struct seq_file *seq, void *v) { + struct net *net = pde_data(file_inode(seq->file)); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); int i; seq_printf(seq, "rc %lld %lld %lld\nfh %lld 0 0 0 0\nio %lld %lld\n", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_HITS]), - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_MISSES]), - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]), - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_FH_STALE]), - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_IO_READ]), - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_IO_WRITE])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]), + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES]), + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE]), + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_FH_STALE]), + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_READ]), + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE])); /* thread usage: */ seq_printf(seq, "th %u 0", atomic_read(&nfsdstats.th_cnt)); @@ -63,10 +65,10 @@ static int nfsd_show(struct seq_file *seq, void *v) seq_printf(seq, "proc4ops %u", LAST_NFS4_OP + 1); for (i = 0; i <= LAST_NFS4_OP; i++) { seq_printf(seq, " %lld", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_NFS4_OP(i)])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_NFS4_OP(i)])); } seq_printf(seq, "\nwdeleg_getattr %lld", - percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_WDELEG_GETATTR])); + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR])); seq_putc(seq, '\n'); #endif @@ -108,14 +110,14 @@ void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num) percpu_counter_destroy(&counters[i]); } -int nfsd_stat_counters_init(void) +int nfsd_stat_counters_init(struct nfsd_net *nn) { - return nfsd_percpu_counters_init(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM); + return nfsd_percpu_counters_init(nn->counter, NFSD_STATS_COUNTERS_NUM); } -void nfsd_stat_counters_destroy(void) +void nfsd_stat_counters_destroy(struct nfsd_net *nn) { - nfsd_percpu_counters_destroy(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM); + nfsd_percpu_counters_destroy(nn->counter, NFSD_STATS_COUNTERS_NUM); } void nfsd_proc_stat_init(struct net *net) diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h index 38811aa7d13e..c24be4ddbe7d 100644 --- a/fs/nfsd/stats.h +++ b/fs/nfsd/stats.h @@ -10,26 +10,7 @@ #include #include - -enum { - NFSD_STATS_RC_HITS, /* repcache hits */ - NFSD_STATS_RC_MISSES, /* repcache misses */ - NFSD_STATS_RC_NOCACHE, /* uncached reqs */ - NFSD_STATS_FH_STALE, /* FH stale error */ - NFSD_STATS_IO_READ, /* bytes returned to read requests */ - NFSD_STATS_IO_WRITE, /* bytes passed in write requests */ -#ifdef CONFIG_NFSD_V4 - NFSD_STATS_FIRST_NFS4_OP, /* count of individual nfsv4 operations */ - NFSD_STATS_LAST_NFS4_OP = NFSD_STATS_FIRST_NFS4_OP + LAST_NFS4_OP, -#define NFSD_STATS_NFS4_OP(op) (NFSD_STATS_FIRST_NFS4_OP + (op)) - NFSD_STATS_WDELEG_GETATTR, /* count of getattr conflict with wdeleg */ -#endif - NFSD_STATS_COUNTERS_NUM -}; - struct nfsd_stats { - struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM]; - atomic_t th_cnt; /* number of available threads */ }; @@ -40,43 +21,46 @@ extern struct svc_stat nfsd_svcstats; int nfsd_percpu_counters_init(struct percpu_counter *counters, int num); void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num); void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num); -int nfsd_stat_counters_init(void); -void nfsd_stat_counters_destroy(void); +int nfsd_stat_counters_init(struct nfsd_net *nn); +void nfsd_stat_counters_destroy(struct nfsd_net *nn); void nfsd_proc_stat_init(struct net *net); void nfsd_proc_stat_shutdown(struct net *net); -static inline void nfsd_stats_rc_hits_inc(void) +static inline void nfsd_stats_rc_hits_inc(struct nfsd_net *nn) { - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_HITS]); + percpu_counter_inc(&nn->counter[NFSD_STATS_RC_HITS]); } -static inline void nfsd_stats_rc_misses_inc(void) +static inline void nfsd_stats_rc_misses_inc(struct nfsd_net *nn) { - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_MISSES]); + percpu_counter_inc(&nn->counter[NFSD_STATS_RC_MISSES]); } -static inline void nfsd_stats_rc_nocache_inc(void) +static inline void nfsd_stats_rc_nocache_inc(struct nfsd_net *nn) { - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]); + percpu_counter_inc(&nn->counter[NFSD_STATS_RC_NOCACHE]); } -static inline void nfsd_stats_fh_stale_inc(struct svc_export *exp) +static inline void nfsd_stats_fh_stale_inc(struct nfsd_net *nn, + struct svc_export *exp) { - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_FH_STALE]); + percpu_counter_inc(&nn->counter[NFSD_STATS_FH_STALE]); if (exp && exp->ex_stats) percpu_counter_inc(&exp->ex_stats->counter[EXP_STATS_FH_STALE]); } -static inline void nfsd_stats_io_read_add(struct svc_export *exp, s64 amount) +static inline void nfsd_stats_io_read_add(struct nfsd_net *nn, + struct svc_export *exp, s64 amount) { - percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_READ], amount); + percpu_counter_add(&nn->counter[NFSD_STATS_IO_READ], amount); if (exp && exp->ex_stats) percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_READ], amount); } -static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount) +static inline void nfsd_stats_io_write_add(struct nfsd_net *nn, + struct svc_export *exp, s64 amount) { - percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_WRITE], amount); + percpu_counter_add(&nn->counter[NFSD_STATS_IO_WRITE], amount); if (exp && exp->ex_stats) percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_WRITE], amount); } @@ -97,9 +81,9 @@ static inline void nfsd_stats_drc_mem_usage_sub(struct nfsd_net *nn, s64 amount) } #ifdef CONFIG_NFSD_V4 -static inline void nfsd_stats_wdeleg_getattr_inc(void) +static inline void nfsd_stats_wdeleg_getattr_inc(struct nfsd_net *nn) { - percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_WDELEG_GETATTR]); + percpu_counter_inc(&nn->counter[NFSD_STATS_WDELEG_GETATTR]); } #endif #endif /* _NFSD_STATS_H */ diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index f57749cd6f0b..33af4bc7f423 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1002,7 +1002,8 @@ static __be32 nfsd_finish_read(struct svc_rqst *rqstp, struct svc_fh *fhp, unsigned long *count, u32 *eof, ssize_t host_err) { if (host_err >= 0) { - nfsd_stats_io_read_add(fhp->fh_export, host_err); + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + nfsd_stats_io_read_add(nn, fhp->fh_export, host_err); *eof = nfsd_eof_on_read(file, offset, host_err, *count); *count = host_err; fsnotify_access(file); @@ -1185,7 +1186,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf, goto out_nfserr; } *cnt = host_err; - nfsd_stats_io_write_add(exp, *cnt); + nfsd_stats_io_write_add(nn, exp, *cnt); fsnotify_modify(file); host_err = filemap_check_wb_err(file->f_mapping, since); if (host_err < 0) From patchwork Thu Jan 25 19:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531672 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93E771350EE for ; Thu, 25 Jan 2024 19:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212429; cv=none; b=GvZHfbgpAwgfNHxDSJO9crZZsTbiTsEvvDu+XJf9JyGsmEPtt3Zr9u1PDzBQ5TKN8uVQxesxr5A1WNvaSmmwPMYuGe7ilrVSRIOdWhMsMPfCt8KGu3jUX2QhrPxXYL906DQKdxqWDE7jROvII27+2IEmAKp9rl/pEL7BKYXxWMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212429; c=relaxed/simple; bh=3SsWqV/5EIVOO4foAtM76z534ziowrHVUYxtts28L8g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y+fDhsi55ANUhLPlsjezTZf8+FX3qUKOfY6oKasIKiKV3McNl9LBvHC/fSs9L0pVEmah52o+CvsOtLlGD6nZDw4garTnsYxISpX4YoJiLU9RXf6IzKAuvs5vthCw1KXhaJusCxN2Y9WHeKaEEDcYdF9QyDEhuc18lwCjB3KiZCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=JMQaxR8s; arc=none smtp.client-ip=209.85.219.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="JMQaxR8s" Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-dc226bad48cso5172344276.3 for ; Thu, 25 Jan 2024 11:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212426; x=1706817226; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sAC6z9QLfDSrDi4k1JAIOPF/ceu4/dSJ0FAYR6smJ0Y=; b=JMQaxR8shOJcZcsV8fmZIjTwsy07T3ZArmJFtkiu8E57MnWqNWP5gZqmQPkZp//Xzb Rn2p6JTUSiz3VIfugVrDBiM9vVI2vhlx3wGbk0eWMfNCz3eXEnTolz+SKgm1ueoM33Wh S3C6VwoFPtY0AkAVYq89m8U+1LaQ6Lv7tD2WPTaBXShYlUsxTSFPmUMPVHdpAS2fecy9 7BCSkWRMKKIW9iDOn3LCmBTt44X/p0MsLXSpXdIQXn2e86RuInMVCmqsIKSIh3+dWlaR Yqzi8ha/7LS6ZnR1iQOFXVdDQtKTWZyC7XydJzxYTNOkxqvTlm21AMPvSW3N/YmHXNL5 ZeWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212426; x=1706817226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sAC6z9QLfDSrDi4k1JAIOPF/ceu4/dSJ0FAYR6smJ0Y=; b=W/51I6ZHs4N/5WMNQycjFbLr8QiK9iWelCF8eGRII9N5aA1NOav1JkPdKH4fKYYP5F QwgNMJBrdPSonWID06MSPhnETEk8frcai5yqzqb4ECqxj5BYCNqqIAu8ODIPIWN146nL TfEwnpnqiczvTA5rtgevkbp1rvz3RHWVqtEaK8W7XpW5IXnmlHVCCdIHDSlUbNqL9QwE X/ALvL7VuW1wX+FsRMFMULHyjUNU+07eZ4uyHZkv8CXT3a8ajgr29If5XuQl1Wo+ZKD0 ju4yTlfhxxLhmy0RQndKcqP9epa9g5FYmB2po2c2w/iIjFlMZGsPnJSHIrqyzFiU430t wviw== X-Gm-Message-State: AOJu0Yy7tk2rhGweaxQ33iivASnseuf34uZ1hHV226tCubO9tkkYQ5Wm n8pLUmBv2U4b27e5hV006jPaKKtdTuXmcCqORdkSDEgzjcoZKReILVnDXrfgZ0CNnt1bcFrZOJ7 s X-Google-Smtp-Source: AGHT+IEIOiPRjx4bgmHMLRKhEdE6J7edCtBZvrDGcbBQOGw1xkABTl2Lu3tgyf02LRJ1bJ8qIy+MGw== X-Received: by 2002:a05:6902:2806:b0:dc2:65e1:706 with SMTP id ed6-20020a056902280600b00dc265e10706mr416409ybb.74.1706212426123; Thu, 25 Jan 2024 11:53:46 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id d82-20020a254f55000000b00dbd9eee633dsm3701478ybb.59.2024.01.25.11.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:45 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 10/13] nfsd: move th_cnt into nfsd_net Date: Thu, 25 Jan 2024 14:53:20 -0500 Message-ID: <0fa7bf5b5bbc863180e50363435b5a56c43dc5e3.1706212208.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is the last global stat, move it into nfsd_net and adjust all the users to use that variant instead of the global one. Signed-off-by: Josef Bacik --- fs/nfsd/netns.h | 3 +++ fs/nfsd/nfssvc.c | 4 ++-- fs/nfsd/stats.c | 4 ++-- fs/nfsd/stats.h | 6 ------ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 0cef4bb407a9..8d3f4cb7cab4 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -179,6 +179,9 @@ struct nfsd_net { /* Per-netns stats counters */ struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM]; + /* number of available threads */ + atomic_t th_cnt; + /* longest hash chain seen */ unsigned int longest_chain; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index d98a6abad990..0961b95dcef6 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -924,7 +924,7 @@ nfsd(void *vrqstp) current->fs->umask = 0; - atomic_inc(&nfsdstats.th_cnt); + atomic_inc(&nn->th_cnt); set_freezable(); @@ -940,7 +940,7 @@ nfsd(void *vrqstp) nfsd_file_net_dispose(nn); } - atomic_dec(&nfsdstats.th_cnt); + atomic_dec(&nn->th_cnt); out: /* Release the thread */ diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index 44e275324b06..360e6dbf4e5c 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c @@ -27,7 +27,6 @@ #include "nfsd.h" -struct nfsd_stats nfsdstats; struct svc_stat nfsd_svcstats = { .program = &nfsd_program, }; @@ -47,7 +46,7 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE])); /* thread usage: */ - seq_printf(seq, "th %u 0", atomic_read(&nfsdstats.th_cnt)); + seq_printf(seq, "th %u 0", atomic_read(&nn->th_cnt)); /* deprecated thread usage histogram stats */ for (i = 0; i < 10; i++) @@ -112,6 +111,7 @@ void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num) int nfsd_stat_counters_init(struct nfsd_net *nn) { + atomic_set(&nn->th_cnt, 0); return nfsd_percpu_counters_init(nn->counter, NFSD_STATS_COUNTERS_NUM); } diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h index c24be4ddbe7d..5675d283a537 100644 --- a/fs/nfsd/stats.h +++ b/fs/nfsd/stats.h @@ -10,12 +10,6 @@ #include #include -struct nfsd_stats { - atomic_t th_cnt; /* number of available threads */ -}; - -extern struct nfsd_stats nfsdstats; - extern struct svc_stat nfsd_svcstats; int nfsd_percpu_counters_init(struct percpu_counter *counters, int num); From patchwork Thu Jan 25 19:53:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531673 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98E0C13666B for ; Thu, 25 Jan 2024 19:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212430; cv=none; b=UaoTrn3OoOvtOLrMomsrlSteEicHN/pbYA7Rl72UYiA5mVSWfO4ZT/4gM5jmD0a+/+FJE74zLtS4m6tJyad147Y7MhL4I/voMIbuhgntT0Bn3zUReAriq3bgfdbT5Gn6ygt8XImJG2oAf/mQzKXa8TCfkKFPr8V/aOqkid5iJ9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212430; c=relaxed/simple; bh=IX7p0SsOy1Dkkd3HatPleJ0FZisFP0H+hR0nLdYx1Xk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Iesg4eQ0IB71mDpSnm746d82IfzDUVtygQTFG74zIF5W+YL35o+WWPsDAHywxbZ26g1e/EYOefPMjv0uoZVrTeZwTdXD1MeZIQLrs97OcKzXRSQ7f00HPXTctDHmopZ3m7fuDuxkI/4nN2XXw8oQi+vt4GNY8fBvGfw5P+yD9XU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=BOqS5MM+; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="BOqS5MM+" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-60032f9e510so29141307b3.2 for ; Thu, 25 Jan 2024 11:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212427; x=1706817227; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hU+BKQwdeLARoJuGNZq8IqNPghLfsVNLxT7WEA+90mQ=; b=BOqS5MM+iFcO47fbqOWmqsWg3iQ2KBc7VAJOCOzsFGJZjkkPJywGmC/xI24gmuMAhz JB2FLc/uiv8lOx5ZRaQPu0k+8g0AUNhIyvyctkF5034fRLmu0U3aPKF5z/Vg4RIXLwLn rzsPu5L8GuZTUuTTo++wcV7PNiLZ6cr7pD6otZ9+nzdpWbZPHKpYyJi6MctH59WkzMdE hG0xw7VNbfjsP9lzdBpExkjfkuHtLq/h5uAf578gzFQjbYjGVmGrOQC0qmcozPsr+BmF HIgRgFewPvFW9uSpWsgTruvB4e4BS6jJLdBcn4q4Wps4eaqomST4csdFzU1fZ/VdTUKr 5D0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212427; x=1706817227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hU+BKQwdeLARoJuGNZq8IqNPghLfsVNLxT7WEA+90mQ=; b=eUyo4hrBGmm2E2uhpMVz4brq3GVWfme7O9sf814MaPlwZ6uyUUF1mvAW48l+KwDAbc unqKOWiwjlBPXxtH7L7P8nSZ3PSU1/kh+Q80bs7A9CyVNF7S+x+swuiFP3Ayx5j/agcX v267AHm0+mig/VGhv4n0vFH7ixF8dNe7XTSHoybWxh4Op5AHSKiI4uVH9qFIm+JpATdS KHBPSzyu2UBR5QRiiHg5QyBc1nwGED4j6zotbfOD+jYMV5O7Kl+C1837rlJvhaohYLEM ONFVGwhNncSwp/hWr+SLiDlLQvNKbz7UHQ2OykbDIcaYJVgn7SjL8l8oPyjqYO0zjspU f8hg== X-Gm-Message-State: AOJu0Yw12dHgHXHpvXj3Hd4qSiRRCHF+Ep4Ljq1x81htZYHBwYxR94Hb pyZH24NYLia0LkwnHzdJdl6EyujcV5U2hLqCF3IM/tAFmOuSCHq+bY9s0Mm42fFZTrhfQL7um9Y A X-Google-Smtp-Source: AGHT+IHTZk9ncjBjmgQDDt9JWcrRaHkAWug8eOm2f8Yi8Z8JzyAWLdQTSmCk0SSAtb3hBJLZ3xMGIw== X-Received: by 2002:a81:b510:0:b0:5ff:9236:10df with SMTP id t16-20020a81b510000000b005ff923610dfmr365144ywh.84.1706212427205; Thu, 25 Jan 2024 11:53:47 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id cm30-20020a05690c0c9e00b005ff928d6effsm860856ywb.33.2024.01.25.11.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:46 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 11/13] nfsd: make svc_stat per-network namespace instead of global Date: Thu, 25 Jan 2024 14:53:21 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The final bit of stats that is global is the rpc svc_stat. Move this into the nfsd_net struct and use that everywhere instead of the global struct. Remove the unused global struct. Signed-off-by: Josef Bacik --- fs/nfsd/netns.h | 4 ++++ fs/nfsd/nfsctl.c | 2 ++ fs/nfsd/nfssvc.c | 2 +- fs/nfsd/stats.c | 10 ++++------ fs/nfsd/stats.h | 2 -- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 8d3f4cb7cab4..8fa23898669d 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -14,6 +14,7 @@ #include #include #include +#include /* Hash tables for nfs4_clientid state */ #define CLIENT_HASH_BITS 4 @@ -182,6 +183,9 @@ struct nfsd_net { /* number of available threads */ atomic_t th_cnt; + /* sunrpc svc stats */ + struct svc_stat nfsd_svcstats; + /* longest hash chain seen */ unsigned int longest_chain; diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index ea3c8114245c..5a5547bd6ecf 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1674,6 +1674,8 @@ static __net_init int nfsd_net_init(struct net *net) retval = nfsd_stat_counters_init(nn); if (retval) goto out_repcache_error; + memset(&nn->nfsd_svcstats, 0, sizeof(nn->nfsd_svcstats)); + nn->nfsd_svcstats.program = &nfsd_program; nn->nfsd_versions = NULL; nn->nfsd4_minorversions = NULL; nfsd4_init_leases_net(nn); diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 0961b95dcef6..ee39d4702811 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -660,7 +660,7 @@ int nfsd_create_serv(struct net *net) if (nfsd_max_blksize == 0) nfsd_max_blksize = nfsd_get_default_max_blksize(); nfsd_reset_versions(nn); - serv = svc_create_pooled(&nfsd_program, &nfsd_svcstats, + serv = svc_create_pooled(&nfsd_program, &nn->nfsd_svcstats, nfsd_max_blksize, nfsd); if (serv == NULL) return -ENOMEM; diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index 360e6dbf4e5c..06f52dcda528 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c @@ -27,10 +27,6 @@ #include "nfsd.h" -struct svc_stat nfsd_svcstats = { - .program = &nfsd_program, -}; - static int nfsd_show(struct seq_file *seq, void *v) { struct net *net = pde_data(file_inode(seq->file)); @@ -56,7 +52,7 @@ static int nfsd_show(struct seq_file *seq, void *v) seq_puts(seq, "\nra 0 0 0 0 0 0 0 0 0 0 0 0\n"); /* show my rpc info */ - svc_seq_show(seq, &nfsd_svcstats); + svc_seq_show(seq, &nn->nfsd_svcstats); #ifdef CONFIG_NFSD_V4 /* Show count for individual nfsv4 operations */ @@ -122,7 +118,9 @@ void nfsd_stat_counters_destroy(struct nfsd_net *nn) void nfsd_proc_stat_init(struct net *net) { - svc_proc_register(net, &nfsd_svcstats, &nfsd_proc_ops); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + + svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops); } void nfsd_proc_stat_shutdown(struct net *net) diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h index 5675d283a537..d2753e975dfd 100644 --- a/fs/nfsd/stats.h +++ b/fs/nfsd/stats.h @@ -10,8 +10,6 @@ #include #include -extern struct svc_stat nfsd_svcstats; - int nfsd_percpu_counters_init(struct percpu_counter *counters, int num); void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num); void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num); From patchwork Thu Jan 25 19:53:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531674 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B26E13666C for ; Thu, 25 Jan 2024 19:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212430; cv=none; b=CRIDuIqOo4gOt7I1UU3Hr6aBRiN4liHPZGxkHKZ1TWtC11wt4vIN9hW0tonZOZ8PKk/3EOAOhirWMkkfs2f/XCiZI9jQZqynqwxmD1KIBnLOMmvCGEeE7vhDkdwOTV9LJ7JqFOPZV1TSxnPDAmUXS9OdYMRREs10210TOJCcMXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212430; c=relaxed/simple; bh=u1dHi6mNixi1zGBfCROOYSu8eSvq8Cesu/3w1LhDWZk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bFRM29I6gVTlpZi+HdxhU4LFSm4dpy7PE3ZzHFRVyyMH7Li5ypiBBZ51VBzb2qn5rXExRWfeHIV3xZtpxxDEKpCZYBh+vWv901XTfO3yMyevn32wZfakWTRZFg/AKUXT5ySSFUapxpdW7PWjIOeavToJt28g+mp1K8sI2c+23H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=i5BSsuoT; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="i5BSsuoT" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dc223f3dd5eso6063972276.2 for ; Thu, 25 Jan 2024 11:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212428; x=1706817228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9Yo0e/Lck+pvwePZ6CWknvlExNBTLSvDrEZMiXn1aeM=; b=i5BSsuoT25ftojA1XvPe4txi7OcOoRQ2zWNwZsomeBx1jAKRqrUfJq5lsVTl8koPKi hliCmj4q/DJeqbzbdADKqeKtT/oQpHmveL2dn2Q3CILiLC3KEudcf72G3XvNRAVPmn9C OGtky5QBCErN8Ul4eKCxnkQKfq5Ue3Bd7u33ff95lFRm+M8luzIC+xe/xQHliJZRZthK hbzjuc+cU1MtW+CxvQ29FOuR5O+Kij0c4F8JrqOZmLsheqt77plj/USfERjC6WhjWlP7 w5jMrAznF64xiR9HPVbezITRkkcc+RQ/Xbg9tQmTv810JoXoOJ9HYX95/DUgu25sdaIp Uwrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212428; x=1706817228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Yo0e/Lck+pvwePZ6CWknvlExNBTLSvDrEZMiXn1aeM=; b=edMaJ2LXyEwuDh0LuZFOYcG0bC5vCzVB8gxoQ+H/uexOjy2KDs7b2UFgDcpBQrVAoT n3pFtZgFOuyabHbUM+mURN1OUAQuIvwTJutaI/rd1pkDU/ADiRBNS5NHV7HQv4U6TuHr DDTv6iethXXAoR7+kfzqqlJqHbz4/UXBAgDZwD8n57yAGOpDReP2MzboFaA6QKI8TFJx 9zJIl+ac0G5yWLhJOsBU7nRWFCrFx+NSBbwr9ZDgdTTNv/KeWk1S/G2z/ynkzak4U6db NXXc2effQVdWml2wpbruAfYRdatW0K0EcTfdQZDwnQVWl7/YkYFJR0E1y/8t/uam7cra j8zg== X-Gm-Message-State: AOJu0YwvqR2XGV7P0QnFg0bvGj8wPqBKD+DzrjbKL1H0pGWNK33yn1dL ClCmlM+IXLc+nEZjj4uaIFrbdMHr159Cxy5aA6pE08NVyTuKuS922oOyJ6NOAyV80igdhajI3k1 T X-Google-Smtp-Source: AGHT+IE60uMzVgsOJM6M2FS5Ila2N6Sc6vPcXptooEdHNkB1W5CtjtmRT3mX+MKiKpxQ3I1Vd7OvNQ== X-Received: by 2002:a25:2fce:0:b0:dc6:18fb:447d with SMTP id v197-20020a252fce000000b00dc618fb447dmr394393ybv.13.1706212428181; Thu, 25 Jan 2024 11:53:48 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id c18-20020a5b0bd2000000b00dc255105656sm3574061ybr.4.2024.01.25.11.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:47 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 12/13] nfs: expose /proc/net/sunrpc/nfs in net namespaces Date: Thu, 25 Jan 2024 14:53:22 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We're using nfs mounts inside of containers in production and noticed that the nfs stats are not exposed in /proc. This is a problem for us as we use these stats for monitoring, and have to do this awkward bind mount from the main host into the container in order to get to these states. Add the rpc_proc_register call to the pernet operations entry and exit points so these stats can be exposed inside of network namespaces. Signed-off-by: Josef Bacik --- fs/nfs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index ebb8d60e1152..e11e9c34aa56 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -2427,11 +2427,13 @@ EXPORT_SYMBOL_GPL(nfs_net_id); static int nfs_net_init(struct net *net) { nfs_clients_init(net); + rpc_proc_register(net, &nfs_rpcstat); return nfs_fs_proc_net_init(net); } static void nfs_net_exit(struct net *net) { + rpc_proc_unregister(net, "nfs"); nfs_fs_proc_net_exit(net); nfs_clients_exit(net); } @@ -2486,15 +2488,12 @@ static int __init init_nfs_fs(void) if (err) goto out1; - rpc_proc_register(&init_net, &nfs_rpcstat); - err = register_nfs_fs(); if (err) goto out0; return 0; out0: - rpc_proc_unregister(&init_net, "nfs"); nfs_destroy_directcache(); out1: nfs_destroy_writepagecache(); @@ -2524,7 +2523,6 @@ static void __exit exit_nfs_fs(void) nfs_destroy_inodecache(); nfs_destroy_nfspagecache(); unregister_pernet_subsys(&nfs_net_ops); - rpc_proc_unregister(&init_net, "nfs"); unregister_nfs_fs(); nfs_fs_proc_exit(); nfsiod_stop(); From patchwork Thu Jan 25 19:53:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13531675 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48925135A5B for ; Thu, 25 Jan 2024 19:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212431; cv=none; b=Ge/PXhUlH5vX4t2WOiDm6Rmndj/KLELhviGwfroB1afvWFnmgaDL6NI98VSInRzniSVSb0IOn5GgSrp/7wPkD74b0dDRgs4i0wVX0WrqJBCFHGliC9a8pXYjoPUrEukXOB6+A96BsW0evKFdZmsTXKYFCw23QS+R6lrHirLI7mA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706212431; c=relaxed/simple; bh=0Swv5ltMaPmLpvzjUSQGWPiAJ0jJvwJ4r2aZ9TmQ5uc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nl7dEMxvO9+5f+wR7p2cBRe9uO5DPEo8gHbycKLglbhS3pyCNe2uUbEDgPi54zYIy86fwqFze4UlrhCmbYiGmFUWPtRYmjqO05SnSGAUqDo+6hV+hOzn3zG41sJx31pJEgdMZMTejI4P9upHsAQ4wgWxFWlfijTkm+bipbwsTgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=uPuoKODe; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="uPuoKODe" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-dc223d20a29so6030980276.3 for ; Thu, 25 Jan 2024 11:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1706212429; x=1706817229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pldtfI6J5p1Psab7h/+4/66zkVokyywUv447L2q1U/I=; b=uPuoKODeA8saYktr078+CM7UKBgWX7E0Dfa6DayhO4xKBggfMg0TDe2nnXzXEuXrWX l93Ng43dI/v8wMWDGkSgI9DJC+ruUFxYA6P6BEsUtAErboE0yyJZxXuBYWpZOIMSrqPJ fNxuO4L/e0TRZrYueMlUTR2q3jmqEe4Z+Aceva9LYmA6lwl/hk5/zkRUkJ/kmNf63wh8 uoWUcKBtvmJnLsN4duShVsdkY09bWgX91BB/0bC3HYxzG3zA0Dx/v03tav9naJZnyLJt xEDhOIHTQaeuS5YBEvypTrpdVtZogYkuD3twR3mtJUKjVE48W89EUU2MqrOmvEJGjCvI AN6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706212429; x=1706817229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pldtfI6J5p1Psab7h/+4/66zkVokyywUv447L2q1U/I=; b=qCmJvEd1UH75+xy1PItQgE5gxDDB2UosAsoYepOb4nxHo3XHS9ZA7GuWP6Qizgo4wR yRgXWKc3JAQ72/bWli6YflC5zOomPqmus17xlIFZ3WWqbQ9Cfi7KtLoMHAsfBrG1vdbV SKpvjP+4cIe9fhrWVfGzpkgaPCvnxU2R0LOeQ2mQ/ELWMf3ExK+i2/pnWfqNfgnMUtyf 7dFddJnNgLnFuHLSuHCdzwGyNMq5uhFYT8xX6fPtaHVoMh/sJzcHA2NR2KjkRsu86APU gaP9x6jsUlrAKgjcqyokg8lUYb1sJm8/TaN71P9cCgVQ/GyRf7ehvWLdNCmWBLl53aix sFrQ== X-Gm-Message-State: AOJu0YwMKuwP09egGyhX9LAxxb5J4H+8N0AWgYr2hT5UKp8in32758R0 Iez9UE8PqrIrRnQAo7NW4cQ34xQqOl8hjiEb15GscnsI5Ko++VhVH1GeRyVY9STq+Bh1R/EvAna 7 X-Google-Smtp-Source: AGHT+IGW6aMoTpQZQJchcUFpSSFKuZ4ll0jWfmiQA4Oa6jiBl0M0QhnUVXCuvB6SNzPZiJg2lT8PAw== X-Received: by 2002:a5b:610:0:b0:dc6:833:6fcd with SMTP id d16-20020a5b0610000000b00dc608336fcdmr311302ybq.120.1706212429169; Thu, 25 Jan 2024 11:53:49 -0800 (PST) Received: from localhost (076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id z13-20020a25664d000000b00dc278dca7cfsm3559012ybm.8.2024.01.25.11.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:53:48 -0800 (PST) From: Josef Bacik To: linux-nfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 13/13] nfs: make the rpc_stat per net namespace Date: Thu, 25 Jan 2024 14:53:23 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we're exposing the rpc stats on a per-network namespace basis, move this struct into struct nfs_net and use that to make sure only the per-network namespace stats are exposed. Signed-off-by: Josef Bacik --- fs/nfs/client.c | 5 ++++- fs/nfs/inode.c | 4 +++- fs/nfs/internal.h | 2 -- fs/nfs/netns.h | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 590be14f182f..4d9249c99989 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -73,7 +73,6 @@ const struct rpc_program nfs_program = { .number = NFS_PROGRAM, .nrvers = ARRAY_SIZE(nfs_version), .version = nfs_version, - .stats = &nfs_rpcstat, .pipe_dir_name = NFS_PIPE_DIRNAME, }; @@ -502,6 +501,7 @@ int nfs_create_rpc_client(struct nfs_client *clp, const struct nfs_client_initdata *cl_init, rpc_authflavor_t flavor) { + struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); struct rpc_clnt *clnt = NULL; struct rpc_create_args args = { .net = clp->cl_net, @@ -513,6 +513,7 @@ int nfs_create_rpc_client(struct nfs_client *clp, .servername = clp->cl_hostname, .nodename = cl_init->nodename, .program = &nfs_program, + .stats = &nn->rpcstats, .version = clp->rpc_ops->version, .authflavor = flavor, .cred = cl_init->cred, @@ -1175,6 +1176,8 @@ void nfs_clients_init(struct net *net) #endif spin_lock_init(&nn->nfs_client_lock); nn->boot_time = ktime_get_real(); + memset(&nn->rpcstats, 0, sizeof(nn->rpcstats)); + nn->rpcstats.program = &nfs_program; nfs_netns_sysfs_setup(nn, net); } diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index e11e9c34aa56..91b4d811958a 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -2426,8 +2426,10 @@ EXPORT_SYMBOL_GPL(nfs_net_id); static int nfs_net_init(struct net *net) { + struct nfs_net *nn = net_generic(net, nfs_net_id); + nfs_clients_init(net); - rpc_proc_register(net, &nfs_rpcstat); + rpc_proc_register(net, &nn->rpcstats); return nfs_fs_proc_net_init(net); } diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e3722ce6722e..06253695fe53 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -449,8 +449,6 @@ int nfs_try_get_tree(struct fs_context *); int nfs_get_tree_common(struct fs_context *); void nfs_kill_super(struct super_block *); -extern struct rpc_stat nfs_rpcstat; - extern int __init register_nfs_fs(void); extern void __exit unregister_nfs_fs(void); extern bool nfs_sb_active(struct super_block *sb); diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h index c8374f74dce1..a68b21603ea9 100644 --- a/fs/nfs/netns.h +++ b/fs/nfs/netns.h @@ -9,6 +9,7 @@ #include #include #include +#include struct bl_dev_msg { int32_t status; @@ -34,6 +35,7 @@ struct nfs_net { struct nfs_netns_client *nfs_client; spinlock_t nfs_client_lock; ktime_t boot_time; + struct rpc_stat rpcstats; #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_nfsfs; #endif