aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 13:16:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 13:16:38 -0400
commit8f45c1a58a25c3a1a2f42521445e1e786c4c0b92 (patch)
treef3557e803eb0b31fba027fe22c0afe1dfa3c6d4f /include/linux/blkdev.h
parent25a025863e024f6b86b48137b10b4960c50351b0 (diff)
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 <jens.axboe@oracle.com> Cc: Nick Piggin <npiggin@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c09696a90d6a..95864b3ff298 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -410,6 +410,12 @@ struct request_queue
410#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ 410#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */
411#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ 411#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */
412 412
413static inline int queue_is_locked(struct request_queue *q)
414{
415 spinlock_t *lock = q->queue_lock;
416 return lock && spin_is_locked(lock);
417}
418
413static inline void queue_flag_set_unlocked(unsigned int flag, 419static inline void queue_flag_set_unlocked(unsigned int flag,
414 struct request_queue *q) 420 struct request_queue *q)
415{ 421{
@@ -418,7 +424,7 @@ static inline void queue_flag_set_unlocked(unsigned int flag,
418 424
419static inline void queue_flag_set(unsigned int flag, struct request_queue *q) 425static inline void queue_flag_set(unsigned int flag, struct request_queue *q)
420{ 426{
421 WARN_ON_ONCE(!spin_is_locked(q->queue_lock)); 427 WARN_ON_ONCE(!queue_is_locked(q));
422 __set_bit(flag, &q->queue_flags); 428 __set_bit(flag, &q->queue_flags);
423} 429}
424 430
@@ -430,7 +436,7 @@ static inline void queue_flag_clear_unlocked(unsigned int flag,
430 436
431static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) 437static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
432{ 438{
433 WARN_ON_ONCE(!spin_is_locked(q->queue_lock)); 439 WARN_ON_ONCE(!queue_is_locked(q));
434 __clear_bit(flag, &q->queue_flags); 440 __clear_bit(flag, &q->queue_flags);
435} 441}
436 442