aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorYan Burman <burman.yan@gmail.com>2006-12-08 05:39:41 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:29:02 -0500
commit4b3bb06bea649396490094780f90d315c152f6ab (patch)
tree7aa0dac29fe4837735d215effa1dce469e792ab5 /fs
parent14d2b59e8c1634ceb995097b162592b0af139578 (diff)
[PATCH] nfsd: replace kmalloc+memset with kcalloc + simplify NULL check
Replace kmalloc+memset with kcalloc and simplify Signed-off-by: Yan Burman <burman.yan@gmail.com> Cc: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfscache.c3
-rw-r--r--fs/nfsd/vfs.c37
2 files changed, 19 insertions, 21 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 6100bbe27432..f90d70475854 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -66,14 +66,13 @@ nfsd_cache_init(void)
66 printk (KERN_ERR "nfsd: cannot allocate all %d cache entries, only got %d\n", 66 printk (KERN_ERR "nfsd: cannot allocate all %d cache entries, only got %d\n",
67 CACHESIZE, CACHESIZE-i); 67 CACHESIZE, CACHESIZE-i);
68 68
69 hash_list = kmalloc (HASHSIZE * sizeof(struct hlist_head), GFP_KERNEL); 69 hash_list = kcalloc (HASHSIZE, sizeof(struct hlist_head), GFP_KERNEL);
70 if (!hash_list) { 70 if (!hash_list) {
71 nfsd_cache_shutdown(); 71 nfsd_cache_shutdown();
72 printk (KERN_ERR "nfsd: cannot allocate %Zd bytes for hash list\n", 72 printk (KERN_ERR "nfsd: cannot allocate %Zd bytes for hash list\n",
73 HASHSIZE * sizeof(struct hlist_head)); 73 HASHSIZE * sizeof(struct hlist_head));
74 return; 74 return;
75 } 75 }
76 memset(hash_list, 0, HASHSIZE * sizeof(struct hlist_head));
77 76
78 cache_disabled = 0; 77 cache_disabled = 0;
79} 78}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index d610edde9386..4883d7586229 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1885,28 +1885,27 @@ nfsd_racache_init(int cache_size)
1885 return 0; 1885 return 0;
1886 if (cache_size < 2*RAPARM_HASH_SIZE) 1886 if (cache_size < 2*RAPARM_HASH_SIZE)
1887 cache_size = 2*RAPARM_HASH_SIZE; 1887 cache_size = 2*RAPARM_HASH_SIZE;
1888 raparml = kmalloc(sizeof(struct raparms) * cache_size, GFP_KERNEL); 1888 raparml = kcalloc(cache_size, sizeof(struct raparms), GFP_KERNEL);
1889 1889
1890 if (raparml != NULL) { 1890 if (!raparml) {
1891 dprintk("nfsd: allocating %d readahead buffers.\n",
1892 cache_size);
1893 for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) {
1894 raparm_hash[i].pb_head = NULL;
1895 spin_lock_init(&raparm_hash[i].pb_lock);
1896 }
1897 nperbucket = cache_size >> RAPARM_HASH_BITS;
1898 memset(raparml, 0, sizeof(struct raparms) * cache_size);
1899 for (i = 0; i < cache_size - 1; i++) {
1900 if (i % nperbucket == 0)
1901 raparm_hash[j++].pb_head = raparml + i;
1902 if (i % nperbucket < nperbucket-1)
1903 raparml[i].p_next = raparml + i + 1;
1904 }
1905 } else {
1906 printk(KERN_WARNING 1891 printk(KERN_WARNING
1907 "nfsd: Could not allocate memory read-ahead cache.\n"); 1892 "nfsd: Could not allocate memory read-ahead cache.\n");
1908 return -ENOMEM; 1893 return -ENOMEM;
1909 } 1894 }
1895
1896 dprintk("nfsd: allocating %d readahead buffers.\n", cache_size);
1897 for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) {
1898 raparm_hash[i].pb_head = NULL;
1899 spin_lock_init(&raparm_hash[i].pb_lock);
1900 }
1901 nperbucket = cache_size >> RAPARM_HASH_BITS;
1902 for (i = 0; i < cache_size - 1; i++) {
1903 if (i % nperbucket == 0)
1904 raparm_hash[j++].pb_head = raparml + i;
1905 if (i % nperbucket < nperbucket-1)
1906 raparml[i].p_next = raparml + i + 1;
1907 }
1908
1910 nfsdstats.ra_size = cache_size; 1909 nfsdstats.ra_size = cache_size;
1911 return 0; 1910 return 0;
1912} 1911}