diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2007-11-12 17:04:29 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:04 -0500 |
commit | ffe9386b6e08e7132cb7730025d0ea310e08a182 (patch) | |
tree | 9189fca685067e105c4fbaf9f22d568e16639080 | |
parent | e331f606a85a2a9e84e9c63c94d43c0517136139 (diff) |
nfsd: move cache proc (un)registration to separate function
Just some minor cleanup.
Also I don't see much point in trying to register further proc entries
if initial entries fail; so just stop trying in that case.
Acked-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | net/sunrpc/cache.c | 99 |
1 files changed, 54 insertions, 45 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 365586a999ea..f41a7cc4cf62 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -290,44 +290,63 @@ static const struct file_operations cache_flush_operations; | |||
290 | static void do_cache_clean(struct work_struct *work); | 290 | static void do_cache_clean(struct work_struct *work); |
291 | static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); | 291 | static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); |
292 | 292 | ||
293 | void cache_register(struct cache_detail *cd) | 293 | static void remove_cache_proc_entries(struct cache_detail *cd) |
294 | { | 294 | { |
295 | cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc); | 295 | if (cd->proc_ent == NULL) |
296 | if (cd->proc_ent) { | 296 | return; |
297 | struct proc_dir_entry *p; | 297 | if (cd->flush_ent) |
298 | cd->proc_ent->owner = cd->owner; | 298 | remove_proc_entry("flush", cd->proc_ent); |
299 | cd->channel_ent = cd->content_ent = NULL; | 299 | if (cd->channel_ent) |
300 | remove_proc_entry("channel", cd->proc_ent); | ||
301 | if (cd->content_ent) | ||
302 | remove_proc_entry("content", cd->proc_ent); | ||
303 | cd->proc_ent = NULL; | ||
304 | remove_proc_entry(cd->name, proc_net_rpc); | ||
305 | } | ||
300 | 306 | ||
301 | p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, | 307 | static void create_cache_proc_entries(struct cache_detail *cd) |
302 | cd->proc_ent); | 308 | { |
303 | cd->flush_ent = p; | 309 | struct proc_dir_entry *p; |
304 | if (p) { | ||
305 | p->proc_fops = &cache_flush_operations; | ||
306 | p->owner = cd->owner; | ||
307 | p->data = cd; | ||
308 | } | ||
309 | 310 | ||
310 | if (cd->cache_request || cd->cache_parse) { | 311 | cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc); |
311 | p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR, | 312 | if (cd->proc_ent == NULL) |
312 | cd->proc_ent); | 313 | return; |
313 | cd->channel_ent = p; | 314 | cd->proc_ent->owner = cd->owner; |
314 | if (p) { | 315 | cd->channel_ent = cd->content_ent = NULL; |
315 | p->proc_fops = &cache_file_operations; | 316 | |
316 | p->owner = cd->owner; | 317 | p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent); |
317 | p->data = cd; | 318 | cd->flush_ent = p; |
318 | } | 319 | if (p == NULL) |
319 | } | 320 | return; |
320 | if (cd->cache_show) { | 321 | p->proc_fops = &cache_flush_operations; |
321 | p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, | 322 | p->owner = cd->owner; |
322 | cd->proc_ent); | 323 | p->data = cd; |
323 | cd->content_ent = p; | 324 | |
324 | if (p) { | 325 | if (cd->cache_request || cd->cache_parse) { |
325 | p->proc_fops = &content_file_operations; | 326 | p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR, |
326 | p->owner = cd->owner; | 327 | cd->proc_ent); |
327 | p->data = cd; | 328 | cd->channel_ent = p; |
328 | } | 329 | if (p == NULL) |
329 | } | 330 | return; |
331 | p->proc_fops = &cache_file_operations; | ||
332 | p->owner = cd->owner; | ||
333 | p->data = cd; | ||
334 | } | ||
335 | if (cd->cache_show) { | ||
336 | p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, | ||
337 | cd->proc_ent); | ||
338 | cd->content_ent = p; | ||
339 | if (p == NULL) | ||
340 | return; | ||
341 | p->proc_fops = &content_file_operations; | ||
342 | p->owner = cd->owner; | ||
343 | p->data = cd; | ||
330 | } | 344 | } |
345 | } | ||
346 | |||
347 | void cache_register(struct cache_detail *cd) | ||
348 | { | ||
349 | create_cache_proc_entries(cd); | ||
331 | rwlock_init(&cd->hash_lock); | 350 | rwlock_init(&cd->hash_lock); |
332 | INIT_LIST_HEAD(&cd->queue); | 351 | INIT_LIST_HEAD(&cd->queue); |
333 | spin_lock(&cache_list_lock); | 352 | spin_lock(&cache_list_lock); |
@@ -358,17 +377,7 @@ void cache_unregister(struct cache_detail *cd) | |||
358 | list_del_init(&cd->others); | 377 | list_del_init(&cd->others); |
359 | write_unlock(&cd->hash_lock); | 378 | write_unlock(&cd->hash_lock); |
360 | spin_unlock(&cache_list_lock); | 379 | spin_unlock(&cache_list_lock); |
361 | if (cd->proc_ent) { | 380 | remove_cache_proc_entries(cd); |
362 | if (cd->flush_ent) | ||
363 | remove_proc_entry("flush", cd->proc_ent); | ||
364 | if (cd->channel_ent) | ||
365 | remove_proc_entry("channel", cd->proc_ent); | ||
366 | if (cd->content_ent) | ||
367 | remove_proc_entry("content", cd->proc_ent); | ||
368 | |||
369 | cd->proc_ent = NULL; | ||
370 | remove_proc_entry(cd->name, proc_net_rpc); | ||
371 | } | ||
372 | if (list_empty(&cache_list)) { | 381 | if (list_empty(&cache_list)) { |
373 | /* module must be being unloaded so its safe to kill the worker */ | 382 | /* module must be being unloaded so its safe to kill the worker */ |
374 | cancel_delayed_work_sync(&cache_cleaner); | 383 | cancel_delayed_work_sync(&cache_cleaner); |