[PATCH 5/5] lockdep: Apply bit_spin_lock lockdep to BH_Uptodate_Lock

From: Byungchul Park
Date: Mon Jun 20 2016 - 01:12:44 EST


In order to use lockdep-enabled bit_spin_lock, we have to call
bit_spin_init() when a instance including the bit used as lock
creates, and bit_spin_free() when the instance including the bit
destroys.

BH_Uptodate_Lock bit of buffer head's b_state is one of
bit_spin_lock users. And this patch adds bit_spin_init() and
bit_spin_free() properly to apply the lock correctness validator.

Signed-off-by: Byungchul Park <byungchul.park@xxxxxxx>
---
fs/buffer.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/buffer.c b/fs/buffer.c
index a75ca74..65c0b8a 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3317,6 +3317,7 @@ struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
if (ret) {
INIT_LIST_HEAD(&ret->b_assoc_buffers);
preempt_disable();
+ bit_spin_init(BH_Uptodate_Lock, &ret->b_state);
__this_cpu_inc(bh_accounting.nr);
recalc_bh_state();
preempt_enable();
@@ -3328,6 +3329,7 @@ EXPORT_SYMBOL(alloc_buffer_head);
void free_buffer_head(struct buffer_head *bh)
{
BUG_ON(!list_empty(&bh->b_assoc_buffers));
+ bit_spin_free(BH_Uptodate_Lock, &bh->b_state);
kmem_cache_free(bh_cachep, bh);
preempt_disable();
__this_cpu_dec(bh_accounting.nr);
--
1.9.1