|
4 | 4 |
|
5 | 5 | #include <linux/bio-integrity.h> |
6 | 6 | #include <linux/blk-crypto.h> |
| 7 | +#include <linux/lockdep.h> |
7 | 8 | #include <linux/memblock.h> /* for max_pfn/max_low_pfn */ |
8 | 9 | #include <linux/sched/sysctl.h> |
9 | 10 | #include <linux/timekeeping.h> |
@@ -35,8 +36,9 @@ struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, |
35 | 36 | void blk_free_flush_queue(struct blk_flush_queue *q); |
36 | 37 |
|
37 | 38 | void blk_freeze_queue(struct request_queue *q); |
38 | | -void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic); |
39 | | -void blk_queue_start_drain(struct request_queue *q); |
| 39 | +bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic); |
| 40 | +bool blk_queue_start_drain(struct request_queue *q); |
| 41 | +bool __blk_freeze_queue_start(struct request_queue *q); |
40 | 42 | int __bio_queue_enter(struct request_queue *q, struct bio *bio); |
41 | 43 | void submit_bio_noacct_nocheck(struct bio *bio); |
42 | 44 | void bio_await_chain(struct bio *bio); |
@@ -69,8 +71,11 @@ static inline int bio_queue_enter(struct bio *bio) |
69 | 71 | { |
70 | 72 | struct request_queue *q = bdev_get_queue(bio->bi_bdev); |
71 | 73 |
|
72 | | - if (blk_try_enter_queue(q, false)) |
| 74 | + if (blk_try_enter_queue(q, false)) { |
| 75 | + rwsem_acquire_read(&q->io_lockdep_map, 0, 0, _RET_IP_); |
| 76 | + rwsem_release(&q->io_lockdep_map, _RET_IP_); |
73 | 77 | return 0; |
| 78 | + } |
74 | 79 | return __bio_queue_enter(q, bio); |
75 | 80 | } |
76 | 81 |
|
@@ -724,4 +729,22 @@ void blk_integrity_verify(struct bio *bio); |
724 | 729 | void blk_integrity_prepare(struct request *rq); |
725 | 730 | void blk_integrity_complete(struct request *rq, unsigned int nr_bytes); |
726 | 731 |
|
| 732 | +static inline void blk_freeze_acquire_lock(struct request_queue *q, bool |
| 733 | + disk_dead, bool queue_dying) |
| 734 | +{ |
| 735 | + if (!disk_dead) |
| 736 | + rwsem_acquire(&q->io_lockdep_map, 0, 1, _RET_IP_); |
| 737 | + if (!queue_dying) |
| 738 | + rwsem_acquire(&q->q_lockdep_map, 0, 1, _RET_IP_); |
| 739 | +} |
| 740 | + |
| 741 | +static inline void blk_unfreeze_release_lock(struct request_queue *q, bool |
| 742 | + disk_dead, bool queue_dying) |
| 743 | +{ |
| 744 | + if (!queue_dying) |
| 745 | + rwsem_release(&q->q_lockdep_map, _RET_IP_); |
| 746 | + if (!disk_dead) |
| 747 | + rwsem_release(&q->io_lockdep_map, _RET_IP_); |
| 748 | +} |
| 749 | + |
727 | 750 | #endif /* BLK_INTERNAL_H */ |
0 commit comments