Skip to content

Commit 2f34b8b

Browse files
NeilBrownTrond Myklebust
authored andcommitted
SUNRPC: add links for all client xprts to debugfs
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 <neilb@suse.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 10db569 commit 2f34b8b

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

‎net/sunrpc/debugfs.c‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,38 @@ static const struct file_operations tasks_fops = {
118118
.release = tasks_release,
119119
};
120120

121+
static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *numv)
122+
{
123+
int len;
124+
char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */
125+
char link[9]; /* enough for 8 hex digits + NULL */
126+
int *nump = numv;
127+
128+
if (IS_ERR_OR_NULL(xprt->debugfs))
129+
return 0;
130+
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
131+
xprt->debugfs->d_name.name);
132+
if (len > sizeof(name))
133+
return -1;
134+
if (*nump == 0)
135+
strcpy(link, "xprt");
136+
else {
137+
len = snprintf(link, sizeof(link), "xprt%d", *nump);
138+
if (len > sizeof(link))
139+
return -1;
140+
}
141+
if (!debugfs_create_symlink(link, clnt->cl_debugfs, name))
142+
return -1;
143+
(*nump)++;
144+
return 0;
145+
}
146+
121147
void
122148
rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
123149
{
124150
int len;
125-
char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */
126-
struct rpc_xprt *xprt;
151+
char name[9]; /* enough for 8 hex digits + NULL */
152+
int xprtnum = 0;
127153

128154
/* Already registered? */
129155
if (clnt->cl_debugfs || !rpc_clnt_dir)
@@ -143,21 +169,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
143169
clnt, &tasks_fops))
144170
goto out_err;
145171

146-
rcu_read_lock();
147-
xprt = rcu_dereference(clnt->cl_xprt);
148-
/* no "debugfs" dentry? Don't bother with the symlink. */
149-
if (IS_ERR_OR_NULL(xprt->debugfs)) {
150-
rcu_read_unlock();
151-
return;
152-
}
153-
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
154-
xprt->debugfs->d_name.name);
155-
rcu_read_unlock();
156-
157-
if (len >= sizeof(name))
158-
goto out_err;
159-
160-
if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name))
172+
if (rpc_clnt_iterate_for_each_xprt(clnt, do_xprt_debugfs, &xprtnum) < 0)
161173
goto out_err;
162174

163175
return;

0 commit comments

Comments
 (0)