aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index f41a7cc4cf62..50b1a8b441fe 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -304,20 +304,21 @@ static void remove_cache_proc_entries(struct cache_detail *cd)
304 remove_proc_entry(cd->name, proc_net_rpc); 304 remove_proc_entry(cd->name, proc_net_rpc);
305} 305}
306 306
307static void create_cache_proc_entries(struct cache_detail *cd) 307#ifdef CONFIG_PROC_FS
308static int create_cache_proc_entries(struct cache_detail *cd)
308{ 309{
309 struct proc_dir_entry *p; 310 struct proc_dir_entry *p;
310 311
311 cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc); 312 cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc);
312 if (cd->proc_ent == NULL) 313 if (cd->proc_ent == NULL)
313 return; 314 goto out_nomem;
314 cd->proc_ent->owner = cd->owner; 315 cd->proc_ent->owner = cd->owner;
315 cd->channel_ent = cd->content_ent = NULL; 316 cd->channel_ent = cd->content_ent = NULL;
316 317
317 p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent); 318 p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent);
318 cd->flush_ent = p; 319 cd->flush_ent = p;
319 if (p == NULL) 320 if (p == NULL)
320 return; 321 goto out_nomem;
321 p->proc_fops = &cache_flush_operations; 322 p->proc_fops = &cache_flush_operations;
322 p->owner = cd->owner; 323 p->owner = cd->owner;
323 p->data = cd; 324 p->data = cd;
@@ -327,7 +328,7 @@ static void create_cache_proc_entries(struct cache_detail *cd)
327 cd->proc_ent); 328 cd->proc_ent);
328 cd->channel_ent = p; 329 cd->channel_ent = p;
329 if (p == NULL) 330 if (p == NULL)
330 return; 331 goto out_nomem;
331 p->proc_fops = &cache_file_operations; 332 p->proc_fops = &cache_file_operations;
332 p->owner = cd->owner; 333 p->owner = cd->owner;
333 p->data = cd; 334 p->data = cd;
@@ -337,16 +338,30 @@ static void create_cache_proc_entries(struct cache_detail *cd)
337 cd->proc_ent); 338 cd->proc_ent);
338 cd->content_ent = p; 339 cd->content_ent = p;
339 if (p == NULL) 340 if (p == NULL)
340 return; 341 goto out_nomem;
341 p->proc_fops = &content_file_operations; 342 p->proc_fops = &content_file_operations;
342 p->owner = cd->owner; 343 p->owner = cd->owner;
343 p->data = cd; 344 p->data = cd;
344 } 345 }
346 return 0;
347out_nomem:
348 remove_cache_proc_entries(cd);
349 return -ENOMEM;
345} 350}
351#else /* CONFIG_PROC_FS */
352static int create_cache_proc_entries(struct cache_detail *cd)
353{
354 return 0;
355}
356#endif
346 357
347void cache_register(struct cache_detail *cd) 358int cache_register(struct cache_detail *cd)
348{ 359{
349 create_cache_proc_entries(cd); 360 int ret;
361
362 ret = create_cache_proc_entries(cd);
363 if (ret)
364 return ret;
350 rwlock_init(&cd->hash_lock); 365 rwlock_init(&cd->hash_lock);
351 INIT_LIST_HEAD(&cd->queue); 366 INIT_LIST_HEAD(&cd->queue);
352 spin_lock(&cache_list_lock); 367 spin_lock(&cache_list_lock);
@@ -360,6 +375,7 @@ void cache_register(struct cache_detail *cd)
360 375
361 /* start the cleaning process */ 376 /* start the cleaning process */
362 schedule_delayed_work(&cache_cleaner, 0); 377 schedule_delayed_work(&cache_cleaner, 0);
378 return 0;
363} 379}
364 380
365void cache_unregister(struct cache_detail *cd) 381void cache_unregister(struct cache_detail *cd)