Commit 0a0762c6c604bb0ce8afe4ee052514e0208152a0

Authored by Greg Kroah-Hartman
1 parent 702d6a834b

sunrpc: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190612145622.GA18839@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 11 additions and 55 deletions Side-by-side Diff

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