aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/vfs.c
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/nfsd/vfs.c
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/nfsd/vfs.c')
-rw-r--r--fs/nfsd/vfs.c37
1 files changed, 18 insertions, 19 deletions
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}