Commit 65033afd authored by Andrew Morton's avatar Andrew Morton Committed by james toy

Detect bh refcount underflows.

Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 8450dc77
......@@ -46,6 +46,14 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
#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)
{
......
......@@ -254,11 +254,7 @@ static inline void get_bh(struct buffer_head *bh)
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)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment