From: Andrew Morton Detect bh refcount underflows. Signed-off-by: Andrew Morton --- fs/buffer.c | 8 ++++++++ include/linux/buffer_head.h | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff -puN fs/buffer.c~put_bh-debug fs/buffer.c --- a/fs/buffer.c~put_bh-debug +++ a/fs/buffer.c @@ -46,6 +46,14 @@ static int fsync_buffers_list(spinlock_t #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers) +void put_bh(struct buffer_head *bh) +{ + WARN_ON(atomic_read(&bh->b_count) <= 0); + smp_mb__before_atomic_dec(); + atomic_dec(&bh->b_count); +} +EXPORT_SYMBOL(put_bh); + inline void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private) { diff -puN include/linux/buffer_head.h~put_bh-debug include/linux/buffer_head.h --- a/include/linux/buffer_head.h~put_bh-debug +++ a/include/linux/buffer_head.h @@ -257,11 +257,7 @@ static inline void get_bh(struct buffer_ atomic_inc(&bh->b_count); } -static inline void put_bh(struct buffer_head *bh) -{ - smp_mb__before_atomic_dec(); - atomic_dec(&bh->b_count); -} +void put_bh(struct buffer_head *bh); static inline void brelse(struct buffer_head *bh) { _