aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2007-11-08 17:20:34 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-02-01 16:42:05 -0500
commitdbf847ecb6318d3a22c6758fe39696d00f39063a (patch)
tree2b71e776ca98bc94258f3539bd7f0ea53d2733a8 /net/sunrpc/cache.c
parentffe9386b6e08e7132cb7730025d0ea310e08a182 (diff)
knfsd: allow cache_register to return error on failure
Newer server features such as nfsv4 and gss depend on proc to work, so a failure to initialize the proc files they need should be treated as fatal. Thanks to Andrew Morton for style fix and compile fix in case where CONFIG_NFSD_V4 is undefined. Cc: Andrew Morton <akpm@linux-foundation.org> Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
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)