Skip to content

Commit 51b07fc

Browse files
Nick Piggintorvalds
authored andcommitted
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>
1 parent 8413ac9 commit 51b07fc

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎fs/buffer.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ EXPORT_SYMBOL(__lock_buffer);
7676

7777
void unlock_buffer(struct buffer_head *bh)
7878
{
79-
smp_mb__before_clear_bit();
80-
clear_buffer_locked(bh);
79+
clear_bit_unlock(BH_Lock, &bh->b_state);
8180
smp_mb__after_clear_bit();
8281
wake_up_bit(&bh->b_state, BH_Lock);
8382
}

‎include/linux/buffer_head.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static inline void wait_on_buffer(struct buffer_head *bh)
322322

323323
static inline int trylock_buffer(struct buffer_head *bh)
324324
{
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));
326326
}
327327

328328
static inline void lock_buffer(struct buffer_head *bh)

0 commit comments

Comments
 (0)