aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorBart Van Assche <[email protected]>2018-03-07 17:10:11 -0800
committerJens Axboe <[email protected]>2018-03-08 14:13:48 -0700
commit1db2008b79a32db2ad41338c6c74c4735cf74f6d (patch)
treec417aaac9968d2d2af514c257773e7087ee0b679 /include/linux
parent8b904b5b6b58b9a29dcf3f82d936d9e7fd69fda6 (diff)
block: Complain if queue_flag_(set|clear)_unlocked() is abused
Since it is not safe to use queue_flag_(set|clear)_unlocked() without holding the queue lock after the sysfs entries for a queue have been created, complain if this happens. Cc: Mike Snitzer <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: Ming Lei <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/blkdev.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f84b3c7887b1..888c9b25cb8f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -728,12 +728,18 @@ static inline void queue_lockdep_assert_held(struct request_queue *q)
static inline void queue_flag_set_unlocked(unsigned int flag,
struct request_queue *q)
{
+ if (test_bit(QUEUE_FLAG_INIT_DONE, &q->queue_flags) &&
+ kref_read(&q->kobj.kref))
+ lockdep_assert_held(q->queue_lock);
__set_bit(flag, &q->queue_flags);
}
static inline void queue_flag_clear_unlocked(unsigned int flag,
struct request_queue *q)
{
+ if (test_bit(QUEUE_FLAG_INIT_DONE, &q->queue_flags) &&
+ kref_read(&q->kobj.kref))
+ lockdep_assert_held(q->queue_lock);
__clear_bit(flag, &q->queue_flags);
}