Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: buffer lock use lock bitops

trylock_buffer and unlock_buffer open and close a critical section.
Hence, we can use the lock bitops to get the desired memory ordering.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Nick Piggin and committed by
Linus Torvalds
51b07fc3 8413ac9d

+2 -3
+1 -2
fs/buffer.c
··· 76 76 77 77 void unlock_buffer(struct buffer_head *bh) 78 78 { 79 - smp_mb__before_clear_bit(); 80 - clear_buffer_locked(bh); 79 + clear_bit_unlock(BH_Lock, &bh->b_state); 81 80 smp_mb__after_clear_bit(); 82 81 wake_up_bit(&bh->b_state, BH_Lock); 83 82 }
+1 -1
include/linux/buffer_head.h
··· 322 322 323 323 static inline int trylock_buffer(struct buffer_head *bh) 324 324 { 325 - return likely(!test_and_set_bit(BH_Lock, &bh->b_state)); 325 + return likely(!test_and_set_bit_lock(BH_Lock, &bh->b_state)); 326 326 } 327 327 328 328 static inline void lock_buffer(struct buffer_head *bh)