diff options
author | Yan Burman <burman.yan@gmail.com> | 2006-12-08 11:39:41 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 17:29:02 +0100 |
commit | 4b3bb06bea649396490094780f90d315c152f6ab (patch) | |
tree | 7aa0dac29fe4837735d215effa1dce469e792ab5 /fs/nfsd/vfs.c | |
parent | [PATCH] NFS3: Calculate 'w' a bit later in nfs3svc_encode_getaclres() (diff) | |
download | linux-4b3bb06bea649396490094780f90d315c152f6ab.tar.xz linux-4b3bb06bea649396490094780f90d315c152f6ab.zip |
[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.c | 37 |
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) return 0; if (cache_size < 2*RAPARM_HASH_SIZE) cache_size = 2*RAPARM_HASH_SIZE; - raparml = kmalloc(sizeof(struct raparms) * cache_size, GFP_KERNEL); - - if (raparml != NULL) { - dprintk("nfsd: allocating %d readahead buffers.\n", - cache_size); - for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) { - raparm_hash[i].pb_head = NULL; - spin_lock_init(&raparm_hash[i].pb_lock); - } - nperbucket = cache_size >> RAPARM_HASH_BITS; - memset(raparml, 0, sizeof(struct raparms) * cache_size); - for (i = 0; i < cache_size - 1; i++) { - if (i % nperbucket == 0) - raparm_hash[j++].pb_head = raparml + i; - if (i % nperbucket < nperbucket-1) - raparml[i].p_next = raparml + i + 1; - } - } else { + raparml = kcalloc(cache_size, sizeof(struct raparms), GFP_KERNEL); + + if (!raparml) { printk(KERN_WARNING - "nfsd: Could not allocate memory read-ahead cache.\n"); + "nfsd: Could not allocate memory read-ahead cache.\n"); return -ENOMEM; } + + dprintk("nfsd: allocating %d readahead buffers.\n", cache_size); + for (i = 0 ; i < RAPARM_HASH_SIZE ; i++) { + raparm_hash[i].pb_head = NULL; + spin_lock_init(&raparm_hash[i].pb_lock); + } + nperbucket = cache_size >> RAPARM_HASH_BITS; + for (i = 0; i < cache_size - 1; i++) { + if (i % nperbucket == 0) + raparm_hash[j++].pb_head = raparml + i; + if (i % nperbucket < nperbucket-1) + raparml[i].p_next = raparml + i + 1; + } + nfsdstats.ra_size = cache_size; return 0; } |