Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp111146ybi; Wed, 29 May 2019 17:44:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqygdQkGD427IIVR8VM9ZAgJebuTsPtMGxk08L2CrBFRBoDL75WrOTtXYdqRH0xS5jhnzwdZ X-Received: by 2002:a17:90a:ba96:: with SMTP id t22mr575448pjr.143.1559177045932; Wed, 29 May 2019 17:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559177045; cv=none; d=google.com; s=arc-20160816; b=cEiS+553TyPEJstVED/EnCWlZ6Hcktb1CJl63gFgB1Hkk37bCmZeb37yAg7Do/olji Dtg8wpQDSDUQ8osma8PhM2ozwsgc3HFlwpMIONTZkl495fiYAFM0ONwsccJx9bNzUZoa h2zub7l/8MKQAegQ33xeRnAeGhAmWtCG118pYK4iF+q8oXcZePvko0QqRo8+o+E0ccYm iYaYvUtNfIYhMBQnswNIQ6iZ9Xm7SqSzepF9r2hHEJZNwgPEfiVWJyiRurpJru0WAHXn 7/jGFJVpl7dn99KyoMgtjMpfXFnoD0ktohldW3yrFjcfeJk6QTyGAITAvtN+U7p9GSUS sKbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=z8fTfz84Se9EBhiwMIYWZGFMh3GdawroXLmSSEt10rU=; b=If8CFrYXmVVLXkYDS+0K4UwJJfHHVpxLtFUo896SVXeYj7NuQfrqnCLeSs7qJFKNBi YLbTJlB/mhwBrwjWl7VMFl1Vjn4jsk4I4I3NXebdCcWMkw1CsDXvy6nJVlc/N8to5i3T Cn5+FtW241SmKXXjkAa9QME5ob1cVoYMpUZmjSURy4w8qqs2d9gJjlfabwd/VtdIK5xJ 8DFnA/MnzvFdy1maC4uUEO39v9F68YWCjo3U3SA3aOmLJcRRND1gd4f8OyYPVS3N9EnM 1Nf4yc5fLlHctpAN3+ACk622U0MOxlgiEpjezIsYrMa7EKTF5kIqLm4KV29YMu66V4uE FATw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si1100728pjs.87.2019.05.29.17.43.51; Wed, 29 May 2019 17:44:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbfE3Anf (ORCPT + 99 others); Wed, 29 May 2019 20:43:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:46454 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726527AbfE3Anf (ORCPT ); Wed, 29 May 2019 20:43:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B8B06AC66; Thu, 30 May 2019 00:43:34 +0000 (UTC) From: NeilBrown To: Olga Kornievskaia , Chuck Lever , Schumaker Anna , Trond Myklebust Date: Thu, 30 May 2019 10:41:28 +1000 Subject: [PATCH 5/9] SUNRPC: add links for all client xprts to debugfs Cc: linux-nfs@vger.kernel.org Message-ID: <155917688872.3988.1542351454603489228.stgit@noble.brown> In-Reply-To: <155917564898.3988.6096672032831115016.stgit@noble.brown> References: <155917564898.3988.6096672032831115016.stgit@noble.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Now that a client can have multiple xprts, we need to add them all to debugs. The first one is still "xprt" Subsequent xprts are "xprt1", "xprt2", etc. Signed-off-by: NeilBrown --- net/sunrpc/debugfs.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index 95ebd76b132d..228bc7e8bca0 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c @@ -118,12 +118,38 @@ static const struct file_operations tasks_fops = { .release = tasks_release, }; +static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *numv) +{ + int len; + char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */ + char link[9]; /* enough for 8 hex digits + NULL */ + int *nump = numv; + + if (IS_ERR_OR_NULL(xprt->debugfs)) + return 0; + len = snprintf(name, sizeof(name), "../../rpc_xprt/%s", + xprt->debugfs->d_name.name); + if (len > sizeof(name)) + return -1; + if (*nump == 0) + strcpy(link, "xprt"); + else { + len = snprintf(link, sizeof(link), "xprt%d", *nump); + if (len > sizeof(link)) + return -1; + } + if (!debugfs_create_symlink(link, clnt->cl_debugfs, name)) + return -1; + (*nump)++; + return 0; +} + void rpc_clnt_debugfs_register(struct rpc_clnt *clnt) { int len; - char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */ - struct rpc_xprt *xprt; + char name[9]; /* enough for 8 hex digits + NULL */ + int xprtnum = 0; /* Already registered? */ if (clnt->cl_debugfs || !rpc_clnt_dir) @@ -143,21 +169,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) clnt, &tasks_fops)) goto out_err; - rcu_read_lock(); - xprt = rcu_dereference(clnt->cl_xprt); - /* no "debugfs" dentry? Don't bother with the symlink. */ - if (IS_ERR_OR_NULL(xprt->debugfs)) { - rcu_read_unlock(); - return; - } - len = snprintf(name, sizeof(name), "../../rpc_xprt/%s", - xprt->debugfs->d_name.name); - rcu_read_unlock(); - - if (len >= sizeof(name)) - goto out_err; - - if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name)) + if (rpc_clnt_iterate_for_each_xprt(clnt, do_xprt_debugfs, &xprtnum) < 0) goto out_err; return;