diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2008-07-03 13:18:54 +0200 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-07-03 13:21:15 +0200 |
commit | e48ec69005f02b70b7ecfde1bc39a599086d16ef (patch) | |
tree | 1868fc162e00af21332a82cdf348229c6b985d2f /include/linux/blkdev.h | |
parent | e180f5949327e897bc35a816f4f4010186632df9 (diff) | |
download | blackbird-op-linux-e48ec69005f02b70b7ecfde1bc39a599086d16ef.tar.gz blackbird-op-linux-e48ec69005f02b70b7ecfde1bc39a599086d16ef.zip |
block: extend queue_flag bitops
Add test_and_clear and test_and_set.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r-- | include/linux/blkdev.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ff9d0bdf2a16..e04c4ac8a7cf 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -428,6 +428,32 @@ static inline void queue_flag_set_unlocked(unsigned int flag, __set_bit(flag, &q->queue_flags); } +static inline int queue_flag_test_and_clear(unsigned int flag, + struct request_queue *q) +{ + WARN_ON_ONCE(!queue_is_locked(q)); + + if (test_bit(flag, &q->queue_flags)) { + __clear_bit(flag, &q->queue_flags); + return 1; + } + + return 0; +} + +static inline int queue_flag_test_and_set(unsigned int flag, + struct request_queue *q) +{ + WARN_ON_ONCE(!queue_is_locked(q)); + + if (!test_bit(flag, &q->queue_flags)) { + __set_bit(flag, &q->queue_flags); + return 0; + } + + return 1; +} + static inline void queue_flag_set(unsigned int flag, struct request_queue *q) { WARN_ON_ONCE(!queue_is_locked(q)); |