Skip to content

Commit bf57229

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: remove REQ_END
Pass an explicit parameter for the last request in a batch to ->queue_rq instead of using a request flag. Besides being a cleaner and non-stateful interface this is also required for the next patch, which fixes the blk-mq I/O submission code to not start a time too early. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 6d11fb4 commit bf57229

7 files changed

Lines changed: 14 additions & 25 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void blk_mq_complete_request(struct request *rq)
384384
}
385385
EXPORT_SYMBOL(blk_mq_complete_request);
386386

387-
static void blk_mq_start_request(struct request *rq, bool last)
387+
static void blk_mq_start_request(struct request *rq)
388388
{
389389
struct request_queue *q = rq->q;
390390

@@ -421,16 +421,6 @@ static void blk_mq_start_request(struct request *rq, bool last)
421421
*/
422422
rq->nr_phys_segments++;
423423
}
424-
425-
/*
426-
* Flag the last request in the series so that drivers know when IO
427-
* should be kicked off, if they don't do it on a per-request basis.
428-
*
429-
* Note: the flag isn't the only condition drivers should do kick off.
430-
* If drive is busy, the last request might not have the bit set.
431-
*/
432-
if (last)
433-
rq->cmd_flags |= REQ_END;
434424
}
435425

436426
static void __blk_mq_requeue_request(struct request *rq)
@@ -440,8 +430,6 @@ static void __blk_mq_requeue_request(struct request *rq)
440430
trace_block_rq_requeue(q, rq);
441431
clear_bit(REQ_ATOM_STARTED, &rq->atomic_flags);
442432

443-
rq->cmd_flags &= ~REQ_END;
444-
445433
if (q->dma_drain_size && blk_rq_bytes(rq))
446434
rq->nr_phys_segments--;
447435
}
@@ -755,9 +743,9 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
755743
rq = list_first_entry(&rq_list, struct request, queuelist);
756744
list_del_init(&rq->queuelist);
757745

758-
blk_mq_start_request(rq, list_empty(&rq_list));
746+
blk_mq_start_request(rq);
759747

760-
ret = q->mq_ops->queue_rq(hctx, rq);
748+
ret = q->mq_ops->queue_rq(hctx, rq, list_empty(&rq_list));
761749
switch (ret) {
762750
case BLK_MQ_RQ_QUEUE_OK:
763751
queued++;
@@ -1198,14 +1186,14 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
11981186
int ret;
11991187

12001188
blk_mq_bio_to_request(rq, bio);
1201-
blk_mq_start_request(rq, true);
1189+
blk_mq_start_request(rq);
12021190

12031191
/*
12041192
* For OK queue, we are done. For error, kill it. Any other
12051193
* error (busy), just add it to our list as we previously
12061194
* would have done
12071195
*/
1208-
ret = q->mq_ops->queue_rq(data.hctx, rq);
1196+
ret = q->mq_ops->queue_rq(data.hctx, rq, true);
12091197
if (ret == BLK_MQ_RQ_QUEUE_OK)
12101198
goto done;
12111199
else {

‎drivers/block/mtip32xx/mtip32xx.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3775,7 +3775,8 @@ static bool mtip_check_unal_depth(struct blk_mq_hw_ctx *hctx,
37753775
return false;
37763776
}
37773777

3778-
static int mtip_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
3778+
static int mtip_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq,
3779+
bool last)
37793780
{
37803781
int ret;
37813782

‎drivers/block/null_blk.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ static void null_request_fn(struct request_queue *q)
313313
}
314314
}
315315

316-
static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
316+
static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq,
317+
bool last)
317318
{
318319
struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq);
319320

‎drivers/block/virtio_blk.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ static void virtblk_done(struct virtqueue *vq)
164164
spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
165165
}
166166

167-
static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
167+
static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req,
168+
bool last)
168169
{
169170
struct virtio_blk *vblk = hctx->queue->queuedata;
170171
struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
171172
unsigned long flags;
172173
unsigned int num;
173174
int qid = hctx->queue_num;
174-
const bool last = (req->cmd_flags & REQ_END) != 0;
175175
int err;
176176
bool notify = false;
177177

‎drivers/scsi/scsi_lib.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,8 @@ static void scsi_mq_done(struct scsi_cmnd *cmd)
18551855
blk_mq_complete_request(cmd->request);
18561856
}
18571857

1858-
static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
1858+
static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req,
1859+
bool last)
18591860
{
18601861
struct request_queue *q = req->q;
18611862
struct scsi_device *sdev = q->queuedata;

‎include/linux/blk-mq.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct blk_mq_tag_set {
7777
struct list_head tag_list;
7878
};
7979

80-
typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *);
80+
typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *, bool);
8181
typedef struct blk_mq_hw_ctx *(map_queue_fn)(struct request_queue *, const int);
8282
typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int);
8383
typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int);

‎include/linux/blk_types.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ enum rq_flag_bits {
188188
__REQ_MIXED_MERGE, /* merge of different types, fail separately */
189189
__REQ_KERNEL, /* direct IO to kernel pages */
190190
__REQ_PM, /* runtime pm request */
191-
__REQ_END, /* last of chain of requests */
192191
__REQ_HASHED, /* on IO scheduler merge hash */
193192
__REQ_MQ_INFLIGHT, /* track inflight for MQ */
194193
__REQ_NR_BITS, /* stops here */
@@ -242,7 +241,6 @@ enum rq_flag_bits {
242241
#define REQ_SECURE (1ULL << __REQ_SECURE)
243242
#define REQ_KERNEL (1ULL << __REQ_KERNEL)
244243
#define REQ_PM (1ULL << __REQ_PM)
245-
#define REQ_END (1ULL << __REQ_END)
246244
#define REQ_HASHED (1ULL << __REQ_HASHED)
247245
#define REQ_MQ_INFLIGHT (1ULL << __REQ_MQ_INFLIGHT)
248246

0 commit comments

Comments
 (0)