diff options
-rw-r--r-- | fs/nfsd/nfscache.c | 28 | ||||
-rw-r--r-- | fs/nfsd/nfsctl.c | 11 | ||||
-rw-r--r-- | include/linux/nfsd/cache.h | 4 |
3 files changed, 21 insertions, 22 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 578f2c9d56be..5bfc2ac60d54 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
@@ -44,17 +44,17 @@ static int nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *vec); | |||
44 | */ | 44 | */ |
45 | static DEFINE_SPINLOCK(cache_lock); | 45 | static DEFINE_SPINLOCK(cache_lock); |
46 | 46 | ||
47 | void | 47 | int nfsd_reply_cache_init(void) |
48 | nfsd_cache_init(void) | ||
49 | { | 48 | { |
50 | struct svc_cacherep *rp; | 49 | struct svc_cacherep *rp; |
51 | int i; | 50 | int i; |
52 | 51 | ||
53 | INIT_LIST_HEAD(&lru_head); | 52 | INIT_LIST_HEAD(&lru_head); |
54 | i = CACHESIZE; | 53 | i = CACHESIZE; |
55 | while(i) { | 54 | while (i) { |
56 | rp = kmalloc(sizeof(*rp), GFP_KERNEL); | 55 | rp = kmalloc(sizeof(*rp), GFP_KERNEL); |
57 | if (!rp) break; | 56 | if (!rp) |
57 | goto out_nomem; | ||
58 | list_add(&rp->c_lru, &lru_head); | 58 | list_add(&rp->c_lru, &lru_head); |
59 | rp->c_state = RC_UNUSED; | 59 | rp->c_state = RC_UNUSED; |
60 | rp->c_type = RC_NOCACHE; | 60 | rp->c_type = RC_NOCACHE; |
@@ -62,23 +62,19 @@ nfsd_cache_init(void) | |||
62 | i--; | 62 | i--; |
63 | } | 63 | } |
64 | 64 | ||
65 | if (i) | ||
66 | printk (KERN_ERR "nfsd: cannot allocate all %d cache entries, only got %d\n", | ||
67 | CACHESIZE, CACHESIZE-i); | ||
68 | |||
69 | hash_list = kcalloc (HASHSIZE, sizeof(struct hlist_head), GFP_KERNEL); | 65 | hash_list = kcalloc (HASHSIZE, sizeof(struct hlist_head), GFP_KERNEL); |
70 | if (!hash_list) { | 66 | if (!hash_list) |
71 | nfsd_cache_shutdown(); | 67 | goto out_nomem; |
72 | printk (KERN_ERR "nfsd: cannot allocate %Zd bytes for hash list\n", | ||
73 | HASHSIZE * sizeof(struct hlist_head)); | ||
74 | return; | ||
75 | } | ||
76 | 68 | ||
77 | cache_disabled = 0; | 69 | cache_disabled = 0; |
70 | return 0; | ||
71 | out_nomem: | ||
72 | printk(KERN_ERR "nfsd: failed to allocate reply cache\n"); | ||
73 | nfsd_reply_cache_shutdown(); | ||
74 | return -ENOMEM; | ||
78 | } | 75 | } |
79 | 76 | ||
80 | void | 77 | void nfsd_reply_cache_shutdown(void) |
81 | nfsd_cache_shutdown(void) | ||
82 | { | 78 | { |
83 | struct svc_cacherep *rp; | 79 | struct svc_cacherep *rp; |
84 | 80 | ||
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index ecf377944286..2bfda9b8f504 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -683,7 +683,9 @@ static int __init init_nfsd(void) | |||
683 | if (retval) | 683 | if (retval) |
684 | return retval; | 684 | return retval; |
685 | nfsd_stat_init(); /* Statistics */ | 685 | nfsd_stat_init(); /* Statistics */ |
686 | nfsd_cache_init(); /* RPC reply cache */ | 686 | retval = nfsd_reply_cache_init(); |
687 | if (retval) | ||
688 | goto out_free_stat; | ||
687 | nfsd_export_init(); /* Exports table */ | 689 | nfsd_export_init(); /* Exports table */ |
688 | nfsd_lockd_init(); /* lockd->nfsd callbacks */ | 690 | nfsd_lockd_init(); /* lockd->nfsd callbacks */ |
689 | nfsd_idmap_init(); /* Name to ID mapping */ | 691 | nfsd_idmap_init(); /* Name to ID mapping */ |
@@ -700,11 +702,12 @@ static int __init init_nfsd(void) | |||
700 | out_free_all: | 702 | out_free_all: |
701 | nfsd_idmap_shutdown(); | 703 | nfsd_idmap_shutdown(); |
702 | nfsd_export_shutdown(); | 704 | nfsd_export_shutdown(); |
703 | nfsd_cache_shutdown(); | 705 | nfsd_reply_cache_shutdown(); |
704 | remove_proc_entry("fs/nfs/exports", NULL); | 706 | remove_proc_entry("fs/nfs/exports", NULL); |
705 | remove_proc_entry("fs/nfs", NULL); | 707 | remove_proc_entry("fs/nfs", NULL); |
706 | nfsd_stat_shutdown(); | ||
707 | nfsd_lockd_shutdown(); | 708 | nfsd_lockd_shutdown(); |
709 | out_free_stat: | ||
710 | nfsd_stat_shutdown(); | ||
708 | nfsd4_free_slabs(); | 711 | nfsd4_free_slabs(); |
709 | return retval; | 712 | return retval; |
710 | } | 713 | } |
@@ -712,7 +715,7 @@ out_free_all: | |||
712 | static void __exit exit_nfsd(void) | 715 | static void __exit exit_nfsd(void) |
713 | { | 716 | { |
714 | nfsd_export_shutdown(); | 717 | nfsd_export_shutdown(); |
715 | nfsd_cache_shutdown(); | 718 | nfsd_reply_cache_shutdown(); |
716 | remove_proc_entry("fs/nfs/exports", NULL); | 719 | remove_proc_entry("fs/nfs/exports", NULL); |
717 | remove_proc_entry("fs/nfs", NULL); | 720 | remove_proc_entry("fs/nfs", NULL); |
718 | nfsd_stat_shutdown(); | 721 | nfsd_stat_shutdown(); |
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h index 007480cd6a60..7b5d784cc858 100644 --- a/include/linux/nfsd/cache.h +++ b/include/linux/nfsd/cache.h | |||
@@ -72,8 +72,8 @@ enum { | |||
72 | */ | 72 | */ |
73 | #define RC_DELAY (HZ/5) | 73 | #define RC_DELAY (HZ/5) |
74 | 74 | ||
75 | void nfsd_cache_init(void); | 75 | int nfsd_reply_cache_init(void); |
76 | void nfsd_cache_shutdown(void); | 76 | void nfsd_reply_cache_shutdown(void); |
77 | int nfsd_cache_lookup(struct svc_rqst *, int); | 77 | int nfsd_cache_lookup(struct svc_rqst *, int); |
78 | void nfsd_cache_update(struct svc_rqst *, int, __be32 *); | 78 | void nfsd_cache_update(struct svc_rqst *, int, __be32 *); |
79 | 79 | ||