From 8f45c1a58a25c3a1a2f42521445e1e786c4c0b92 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 29 Apr 2008 10:16:38 -0700 Subject: [PATCH] block: fix queue locking verification The new queue_flag_set/clear() functions verify that the queue is locked, but in doing so they will actually instead oops if the queue lock hasn't been initialized at all. So fix the lock debug test to consider the "no lock" case to be unlocked. This way you get a nice WARN_ON_ONCE() instead of a fatal oops. Bug introduced by commit 75ad23bc0fcb4f992a5d06982bf0857ab1738e9e ("block: make queue flags non-atomic"). Cc: Jens Axboe Cc: Nick Piggin Signed-off-by: Linus Torvalds --- include/linux/blkdev.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index c09696a90d..95864b3ff2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -410,6 +410,12 @@ struct request_queue #define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ #define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ +static inline int queue_is_locked(struct request_queue *q) +{ + spinlock_t *lock = q->queue_lock; + return lock && spin_is_locked(lock); +} + static inline void queue_flag_set_unlocked(unsigned int flag, struct request_queue *q) { @@ -418,7 +424,7 @@ static inline void queue_flag_set_unlocked(unsigned int flag, static inline void queue_flag_set(unsigned int flag, struct request_queue *q) { - WARN_ON_ONCE(!spin_is_locked(q->queue_lock)); + WARN_ON_ONCE(!queue_is_locked(q)); __set_bit(flag, &q->queue_flags); } @@ -430,7 +436,7 @@ static inline void queue_flag_clear_unlocked(unsigned int flag, static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) { - WARN_ON_ONCE(!spin_is_locked(q->queue_lock)); + WARN_ON_ONCE(!queue_is_locked(q)); __clear_bit(flag, &q->queue_flags); } -- 2.39.5