aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 10:16:38 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 10:16:38 -0700
commit8f45c1a58a25c3a1a2f42521445e1e786c4c0b92 (patch)
treef3557e803eb0b31fba027fe22c0afe1dfa3c6d4f /include/linux/blkdev.h
parentMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6 (diff)
downloadlinux-dev-8f45c1a58a25c3a1a2f42521445e1e786c4c0b92.tar.xz
linux-dev-8f45c1a58a25c3a1a2f42521445e1e786c4c0b92.zip
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
#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);
}