diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2007-11-08 17:20:34 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:05 -0500 |
commit | dbf847ecb6318d3a22c6758fe39696d00f39063a (patch) | |
tree | 2b71e776ca98bc94258f3539bd7f0ea53d2733a8 /net/sunrpc | |
parent | ffe9386b6e08e7132cb7730025d0ea310e08a182 (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')
-rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 17 | ||||
-rw-r--r-- | net/sunrpc/cache.c | 30 |
2 files changed, 36 insertions, 11 deletions
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index d329a12500aa..aa790bb4f7a1 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
@@ -1386,10 +1386,19 @@ int | |||
1386 | gss_svc_init(void) | 1386 | gss_svc_init(void) |
1387 | { | 1387 | { |
1388 | int rv = svc_auth_register(RPC_AUTH_GSS, &svcauthops_gss); | 1388 | int rv = svc_auth_register(RPC_AUTH_GSS, &svcauthops_gss); |
1389 | if (rv == 0) { | 1389 | if (rv) |
1390 | cache_register(&rsc_cache); | 1390 | return rv; |
1391 | cache_register(&rsi_cache); | 1391 | rv = cache_register(&rsc_cache); |
1392 | } | 1392 | if (rv) |
1393 | goto out1; | ||
1394 | rv = cache_register(&rsi_cache); | ||
1395 | if (rv) | ||
1396 | goto out2; | ||
1397 | return 0; | ||
1398 | out2: | ||
1399 | cache_unregister(&rsc_cache); | ||
1400 | out1: | ||
1401 | svc_auth_unregister(RPC_AUTH_GSS); | ||
1393 | return rv; | 1402 | return rv; |
1394 | } | 1403 | } |
1395 | 1404 | ||
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 | ||
307 | static void create_cache_proc_entries(struct cache_detail *cd) | 307 | #ifdef CONFIG_PROC_FS |
308 | static 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; | ||
347 | out_nomem: | ||
348 | remove_cache_proc_entries(cd); | ||
349 | return -ENOMEM; | ||
345 | } | 350 | } |
351 | #else /* CONFIG_PROC_FS */ | ||
352 | static int create_cache_proc_entries(struct cache_detail *cd) | ||
353 | { | ||
354 | return 0; | ||
355 | } | ||
356 | #endif | ||
346 | 357 | ||
347 | void cache_register(struct cache_detail *cd) | 358 | int 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 | ||
365 | void cache_unregister(struct cache_detail *cd) | 381 | void cache_unregister(struct cache_detail *cd) |