diff options
-rw-r--r-- | block/blk-core.c | 2 | ||||
-rw-r--r-- | block/blk-flush.c | 2 | ||||
-rw-r--r-- | block/blk-mq.c | 14 | ||||
-rw-r--r-- | include/linux/blk-mq.h | 2 |
4 files changed, 15 insertions, 5 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 3bb9e9f7f87e..9677c6525ed8 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1102,7 +1102,7 @@ static struct request *blk_old_get_request(struct request_queue *q, int rw, | |||
1102 | struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask) | 1102 | struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask) |
1103 | { | 1103 | { |
1104 | if (q->mq_ops) | 1104 | if (q->mq_ops) |
1105 | return blk_mq_alloc_request(q, rw, gfp_mask); | 1105 | return blk_mq_alloc_request(q, rw, gfp_mask, false); |
1106 | else | 1106 | else |
1107 | return blk_old_get_request(q, rw, gfp_mask); | 1107 | return blk_old_get_request(q, rw, gfp_mask); |
1108 | } | 1108 | } |
diff --git a/block/blk-flush.c b/block/blk-flush.c index 3e4cc9c7890a..331e627301ea 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c | |||
@@ -286,7 +286,7 @@ static void mq_flush_work(struct work_struct *work) | |||
286 | 286 | ||
287 | /* We don't need set REQ_FLUSH_SEQ, it's for consistency */ | 287 | /* We don't need set REQ_FLUSH_SEQ, it's for consistency */ |
288 | rq = blk_mq_alloc_request(q, WRITE_FLUSH|REQ_FLUSH_SEQ, | 288 | rq = blk_mq_alloc_request(q, WRITE_FLUSH|REQ_FLUSH_SEQ, |
289 | __GFP_WAIT|GFP_ATOMIC); | 289 | __GFP_WAIT|GFP_ATOMIC, true); |
290 | rq->cmd_type = REQ_TYPE_FS; | 290 | rq->cmd_type = REQ_TYPE_FS; |
291 | rq->end_io = flush_end_io; | 291 | rq->end_io = flush_end_io; |
292 | 292 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index ac804c635040..2dc8de86d0d2 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -210,14 +210,15 @@ static struct request *blk_mq_alloc_request_pinned(struct request_queue *q, | |||
210 | return rq; | 210 | return rq; |
211 | } | 211 | } |
212 | 212 | ||
213 | struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp) | 213 | struct request *blk_mq_alloc_request(struct request_queue *q, int rw, |
214 | gfp_t gfp, bool reserved) | ||
214 | { | 215 | { |
215 | struct request *rq; | 216 | struct request *rq; |
216 | 217 | ||
217 | if (blk_mq_queue_enter(q)) | 218 | if (blk_mq_queue_enter(q)) |
218 | return NULL; | 219 | return NULL; |
219 | 220 | ||
220 | rq = blk_mq_alloc_request_pinned(q, rw, gfp, false); | 221 | rq = blk_mq_alloc_request_pinned(q, rw, gfp, reserved); |
221 | blk_mq_put_ctx(rq->mq_ctx); | 222 | blk_mq_put_ctx(rq->mq_ctx); |
222 | return rq; | 223 | return rq; |
223 | } | 224 | } |
@@ -1327,6 +1328,15 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg, | |||
1327 | reg->queue_depth = BLK_MQ_MAX_DEPTH; | 1328 | reg->queue_depth = BLK_MQ_MAX_DEPTH; |
1328 | } | 1329 | } |
1329 | 1330 | ||
1331 | /* | ||
1332 | * Set aside a tag for flush requests. It will only be used while | ||
1333 | * another flush request is in progress but outside the driver. | ||
1334 | * | ||
1335 | * TODO: only allocate if flushes are supported | ||
1336 | */ | ||
1337 | reg->queue_depth++; | ||
1338 | reg->reserved_tags++; | ||
1339 | |||
1330 | if (reg->queue_depth < (reg->reserved_tags + BLK_MQ_TAG_MIN)) | 1340 | if (reg->queue_depth < (reg->reserved_tags + BLK_MQ_TAG_MIN)) |
1331 | return ERR_PTR(-EINVAL); | 1341 | return ERR_PTR(-EINVAL); |
1332 | 1342 | ||
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 3368b97bee73..ab0e9b2025b3 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h | |||
@@ -124,7 +124,7 @@ void blk_mq_insert_request(struct request_queue *, struct request *, bool); | |||
124 | void blk_mq_run_queues(struct request_queue *q, bool async); | 124 | void blk_mq_run_queues(struct request_queue *q, bool async); |
125 | void blk_mq_free_request(struct request *rq); | 125 | void blk_mq_free_request(struct request *rq); |
126 | bool blk_mq_can_queue(struct blk_mq_hw_ctx *); | 126 | bool blk_mq_can_queue(struct blk_mq_hw_ctx *); |
127 | struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp); | 127 | struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, bool reserved); |
128 | struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, gfp_t gfp); | 128 | struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, gfp_t gfp); |
129 | struct request *blk_mq_rq_from_tag(struct request_queue *q, unsigned int tag); | 129 | struct request *blk_mq_rq_from_tag(struct request_queue *q, unsigned int tag); |
130 | 130 | ||