Skip to content

Commit 1db2008

Browse files
KAGA-KOKOaxboe
authored andcommitted
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]>
1 parent 8b904b5 commit 1db2008

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/linux/blkdev.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,18 @@ static inline void queue_lockdep_assert_held(struct request_queue *q)
728728
static inline void queue_flag_set_unlocked(unsigned int flag,
729729
struct request_queue *q)
730730
{
731+
if (test_bit(QUEUE_FLAG_INIT_DONE, &q->queue_flags) &&
732+
kref_read(&q->kobj.kref))
733+
lockdep_assert_held(q->queue_lock);
731734
__set_bit(flag, &q->queue_flags);
732735
}
733736

734737
static inline void queue_flag_clear_unlocked(unsigned int flag,
735738
struct request_queue *q)
736739
{
740+
if (test_bit(QUEUE_FLAG_INIT_DONE, &q->queue_flags) &&
741+
kref_read(&q->kobj.kref))
742+
lockdep_assert_held(q->queue_lock);
737743
__clear_bit(flag, &q->queue_flags);
738744
}
739745

0 commit comments

Comments
 (0)