diff options
Diffstat (limited to 'fs/buffer.c')
-rw-r--r-- | fs/buffer.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index aecd057cd0e0..3deeb886f6e6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -2898,8 +2898,9 @@ static void recalc_bh_state(void) | |||
2898 | 2898 | ||
2899 | struct buffer_head *alloc_buffer_head(gfp_t gfp_flags) | 2899 | struct buffer_head *alloc_buffer_head(gfp_t gfp_flags) |
2900 | { | 2900 | { |
2901 | struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags); | 2901 | struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags); |
2902 | if (ret) { | 2902 | if (ret) { |
2903 | INIT_LIST_HEAD(&ret->b_assoc_buffers); | ||
2903 | get_cpu_var(bh_accounting).nr++; | 2904 | get_cpu_var(bh_accounting).nr++; |
2904 | recalc_bh_state(); | 2905 | recalc_bh_state(); |
2905 | put_cpu_var(bh_accounting); | 2906 | put_cpu_var(bh_accounting); |
@@ -2918,17 +2919,6 @@ void free_buffer_head(struct buffer_head *bh) | |||
2918 | } | 2919 | } |
2919 | EXPORT_SYMBOL(free_buffer_head); | 2920 | EXPORT_SYMBOL(free_buffer_head); |
2920 | 2921 | ||
2921 | static void | ||
2922 | init_buffer_head(void *data, struct kmem_cache *cachep, unsigned long flags) | ||
2923 | { | ||
2924 | if (flags & SLAB_CTOR_CONSTRUCTOR) { | ||
2925 | struct buffer_head * bh = (struct buffer_head *)data; | ||
2926 | |||
2927 | memset(bh, 0, sizeof(*bh)); | ||
2928 | INIT_LIST_HEAD(&bh->b_assoc_buffers); | ||
2929 | } | ||
2930 | } | ||
2931 | |||
2932 | static void buffer_exit_cpu(int cpu) | 2922 | static void buffer_exit_cpu(int cpu) |
2933 | { | 2923 | { |
2934 | int i; | 2924 | int i; |
@@ -2955,12 +2945,8 @@ void __init buffer_init(void) | |||
2955 | { | 2945 | { |
2956 | int nrpages; | 2946 | int nrpages; |
2957 | 2947 | ||
2958 | bh_cachep = kmem_cache_create("buffer_head", | 2948 | bh_cachep = KMEM_CACHE(buffer_head, |
2959 | sizeof(struct buffer_head), 0, | 2949 | SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD); |
2960 | (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC| | ||
2961 | SLAB_MEM_SPREAD), | ||
2962 | init_buffer_head, | ||
2963 | NULL); | ||
2964 | 2950 | ||
2965 | /* | 2951 | /* |
2966 | * Limit the bh occupancy to 10% of ZONE_NORMAL | 2952 | * Limit the bh occupancy to 10% of ZONE_NORMAL |