Skip to content

Commit

Permalink
block: use lockdep_assert_held for queue locking
Browse files Browse the repository at this point in the history
Instead of an ugly open coded variant.

Cc: axboe@kernel.dk
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Andi Kleen authored and Jens Axboe committed Mar 30, 2012
1 parent 00380a4 commit 8bcb6c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ void blk_throtl_drain(struct request_queue *q)
struct bio_list bl;
struct bio *bio;

WARN_ON_ONCE(!queue_is_locked(q));
queue_lockdep_assert_held(q);

bio_list_init(&bl);

Expand Down
18 changes: 7 additions & 11 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,10 @@ struct request_queue {
(1 << QUEUE_FLAG_SAME_COMP) | \
(1 << QUEUE_FLAG_ADD_RANDOM))

static inline int queue_is_locked(struct request_queue *q)
static inline void queue_lockdep_assert_held(struct request_queue *q)
{
#ifdef CONFIG_SMP
spinlock_t *lock = q->queue_lock;
return lock && spin_is_locked(lock);
#else
return 1;
#endif
if (q->queue_lock)
lockdep_assert_held(q->queue_lock);
}

static inline void queue_flag_set_unlocked(unsigned int flag,
Expand All @@ -445,7 +441,7 @@ static inline void queue_flag_set_unlocked(unsigned int flag,
static inline int queue_flag_test_and_clear(unsigned int flag,
struct request_queue *q)
{
WARN_ON_ONCE(!queue_is_locked(q));
queue_lockdep_assert_held(q);

if (test_bit(flag, &q->queue_flags)) {
__clear_bit(flag, &q->queue_flags);
Expand All @@ -458,7 +454,7 @@ static inline int queue_flag_test_and_clear(unsigned int flag,
static inline int queue_flag_test_and_set(unsigned int flag,
struct request_queue *q)
{
WARN_ON_ONCE(!queue_is_locked(q));
queue_lockdep_assert_held(q);

if (!test_bit(flag, &q->queue_flags)) {
__set_bit(flag, &q->queue_flags);
Expand All @@ -470,7 +466,7 @@ static inline int queue_flag_test_and_set(unsigned int flag,

static inline void queue_flag_set(unsigned int flag, struct request_queue *q)
{
WARN_ON_ONCE(!queue_is_locked(q));
queue_lockdep_assert_held(q);
__set_bit(flag, &q->queue_flags);
}

Expand All @@ -487,7 +483,7 @@ static inline int queue_in_flight(struct request_queue *q)

static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
{
WARN_ON_ONCE(!queue_is_locked(q));
queue_lockdep_assert_held(q);
__clear_bit(flag, &q->queue_flags);
}

Expand Down

0 comments on commit 8bcb6c7

Please sign in to comment.