diff options
Diffstat (limited to 'net/sunrpc/debugfs.c')
-rw-r--r-- | net/sunrpc/debugfs.c | 66 |
1 files changed, 11 insertions, 55 deletions
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index 95ebd76b132d..707d7aab1546 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include "netns.h" | 11 | #include "netns.h" |
12 | 12 | ||
13 | static struct dentry *topdir; | 13 | static struct dentry *topdir; |
14 | static struct dentry *rpc_fault_dir; | ||
15 | static struct dentry *rpc_clnt_dir; | 14 | static struct dentry *rpc_clnt_dir; |
16 | static struct dentry *rpc_xprt_dir; | 15 | static struct dentry *rpc_xprt_dir; |
17 | 16 | ||
@@ -125,23 +124,16 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) | |||
125 | char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */ | 124 | char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */ |
126 | struct rpc_xprt *xprt; | 125 | struct rpc_xprt *xprt; |
127 | 126 | ||
128 | /* Already registered? */ | ||
129 | if (clnt->cl_debugfs || !rpc_clnt_dir) | ||
130 | return; | ||
131 | |||
132 | len = snprintf(name, sizeof(name), "%x", clnt->cl_clid); | 127 | len = snprintf(name, sizeof(name), "%x", clnt->cl_clid); |
133 | if (len >= sizeof(name)) | 128 | if (len >= sizeof(name)) |
134 | return; | 129 | return; |
135 | 130 | ||
136 | /* make the per-client dir */ | 131 | /* make the per-client dir */ |
137 | clnt->cl_debugfs = debugfs_create_dir(name, rpc_clnt_dir); | 132 | clnt->cl_debugfs = debugfs_create_dir(name, rpc_clnt_dir); |
138 | if (!clnt->cl_debugfs) | ||
139 | return; | ||
140 | 133 | ||
141 | /* make tasks file */ | 134 | /* make tasks file */ |
142 | if (!debugfs_create_file("tasks", S_IFREG | 0400, clnt->cl_debugfs, | 135 | debugfs_create_file("tasks", S_IFREG | 0400, clnt->cl_debugfs, clnt, |
143 | clnt, &tasks_fops)) | 136 | &tasks_fops); |
144 | goto out_err; | ||
145 | 137 | ||
146 | rcu_read_lock(); | 138 | rcu_read_lock(); |
147 | xprt = rcu_dereference(clnt->cl_xprt); | 139 | xprt = rcu_dereference(clnt->cl_xprt); |
@@ -157,8 +149,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) | |||
157 | if (len >= sizeof(name)) | 149 | if (len >= sizeof(name)) |
158 | goto out_err; | 150 | goto out_err; |
159 | 151 | ||
160 | if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name)) | 152 | debugfs_create_symlink("xprt", clnt->cl_debugfs, name); |
161 | goto out_err; | ||
162 | 153 | ||
163 | return; | 154 | return; |
164 | out_err: | 155 | out_err: |
@@ -226,9 +217,6 @@ rpc_xprt_debugfs_register(struct rpc_xprt *xprt) | |||
226 | static atomic_t cur_id; | 217 | static atomic_t cur_id; |
227 | char name[9]; /* 8 hex digits + NULL term */ | 218 | char name[9]; /* 8 hex digits + NULL term */ |
228 | 219 | ||
229 | if (!rpc_xprt_dir) | ||
230 | return; | ||
231 | |||
232 | id = (unsigned int)atomic_inc_return(&cur_id); | 220 | id = (unsigned int)atomic_inc_return(&cur_id); |
233 | 221 | ||
234 | len = snprintf(name, sizeof(name), "%x", id); | 222 | len = snprintf(name, sizeof(name), "%x", id); |
@@ -237,15 +225,10 @@ rpc_xprt_debugfs_register(struct rpc_xprt *xprt) | |||
237 | 225 | ||
238 | /* make the per-client dir */ | 226 | /* make the per-client dir */ |
239 | xprt->debugfs = debugfs_create_dir(name, rpc_xprt_dir); | 227 | xprt->debugfs = debugfs_create_dir(name, rpc_xprt_dir); |
240 | if (!xprt->debugfs) | ||
241 | return; | ||
242 | 228 | ||
243 | /* make tasks file */ | 229 | /* make tasks file */ |
244 | if (!debugfs_create_file("info", S_IFREG | 0400, xprt->debugfs, | 230 | debugfs_create_file("info", S_IFREG | 0400, xprt->debugfs, xprt, |
245 | xprt, &xprt_info_fops)) { | 231 | &xprt_info_fops); |
246 | debugfs_remove_recursive(xprt->debugfs); | ||
247 | xprt->debugfs = NULL; | ||
248 | } | ||
249 | 232 | ||
250 | atomic_set(&xprt->inject_disconnect, rpc_inject_disconnect); | 233 | atomic_set(&xprt->inject_disconnect, rpc_inject_disconnect); |
251 | } | 234 | } |
@@ -308,28 +291,11 @@ static const struct file_operations fault_disconnect_fops = { | |||
308 | .release = fault_release, | 291 | .release = fault_release, |
309 | }; | 292 | }; |
310 | 293 | ||
311 | static struct dentry * | ||
312 | inject_fault_dir(struct dentry *topdir) | ||
313 | { | ||
314 | struct dentry *faultdir; | ||
315 | |||
316 | faultdir = debugfs_create_dir("inject_fault", topdir); | ||
317 | if (!faultdir) | ||
318 | return NULL; | ||
319 | |||
320 | if (!debugfs_create_file("disconnect", S_IFREG | 0400, faultdir, | ||
321 | NULL, &fault_disconnect_fops)) | ||
322 | return NULL; | ||
323 | |||
324 | return faultdir; | ||
325 | } | ||
326 | |||
327 | void __exit | 294 | void __exit |
328 | sunrpc_debugfs_exit(void) | 295 | sunrpc_debugfs_exit(void) |
329 | { | 296 | { |
330 | debugfs_remove_recursive(topdir); | 297 | debugfs_remove_recursive(topdir); |
331 | topdir = NULL; | 298 | topdir = NULL; |
332 | rpc_fault_dir = NULL; | ||
333 | rpc_clnt_dir = NULL; | 299 | rpc_clnt_dir = NULL; |
334 | rpc_xprt_dir = NULL; | 300 | rpc_xprt_dir = NULL; |
335 | } | 301 | } |
@@ -337,26 +303,16 @@ sunrpc_debugfs_exit(void) | |||
337 | void __init | 303 | void __init |
338 | sunrpc_debugfs_init(void) | 304 | sunrpc_debugfs_init(void) |
339 | { | 305 | { |
340 | topdir = debugfs_create_dir("sunrpc", NULL); | 306 | struct dentry *rpc_fault_dir; |
341 | if (!topdir) | ||
342 | return; | ||
343 | 307 | ||
344 | rpc_fault_dir = inject_fault_dir(topdir); | 308 | topdir = debugfs_create_dir("sunrpc", NULL); |
345 | if (!rpc_fault_dir) | ||
346 | goto out_remove; | ||
347 | 309 | ||
348 | rpc_clnt_dir = debugfs_create_dir("rpc_clnt", topdir); | 310 | rpc_clnt_dir = debugfs_create_dir("rpc_clnt", topdir); |
349 | if (!rpc_clnt_dir) | ||
350 | goto out_remove; | ||
351 | 311 | ||
352 | rpc_xprt_dir = debugfs_create_dir("rpc_xprt", topdir); | 312 | rpc_xprt_dir = debugfs_create_dir("rpc_xprt", topdir); |
353 | if (!rpc_xprt_dir) | ||
354 | goto out_remove; | ||
355 | 313 | ||
356 | return; | 314 | rpc_fault_dir = debugfs_create_dir("inject_fault", topdir); |
357 | out_remove: | 315 | |
358 | debugfs_remove_recursive(topdir); | 316 | debugfs_create_file("disconnect", S_IFREG | 0400, rpc_fault_dir, NULL, |
359 | topdir = NULL; | 317 | &fault_disconnect_fops); |
360 | rpc_fault_dir = NULL; | ||
361 | rpc_clnt_dir = NULL; | ||
362 | } | 318 | } |