Skip to content

Commit b2c45ce

Browse files
Chaitanya Kulkarniaxboe
authored andcommitted
block: move bio queue-transition flag fixups into blk_steal_bios()
blk_steal_bios() transfers bios from a request to a bio_list when the request is requeued to a different queue. The NVMe multipath failover path (nvme_failover_req) currently open-codes clearing of REQ_POLLED, bi_cookie, and REQ_NOWAIT on each bio before calling blk_steal_bios(). Move these fixups into blk_steal_bios() itself so that any caller automatically gets correct flag state when bios cross queue boundaries. Simplify nvme_failover_req() accordingly. Signed-off-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 89d10b7 commit b2c45ce

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

block/blk-mq.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,23 @@ EXPORT_SYMBOL_GPL(blk_rq_prep_clone);
34243424
*/
34253425
void blk_steal_bios(struct bio_list *list, struct request *rq)
34263426
{
3427+
struct bio *bio;
3428+
3429+
for (bio = rq->bio; bio; bio = bio->bi_next) {
3430+
if (bio->bi_opf & REQ_POLLED) {
3431+
bio->bi_opf &= ~REQ_POLLED;
3432+
bio->bi_cookie = BLK_QC_T_NONE;
3433+
}
3434+
/*
3435+
* The alternate request queue that we may end up submitting
3436+
* the bio to may be frozen temporarily, in this case REQ_NOWAIT
3437+
* will fail the I/O immediately with EAGAIN to the issuer.
3438+
* We are not in the issuer context which cannot block. Clear
3439+
* the flag to avoid spurious EAGAIN I/O failures.
3440+
*/
3441+
bio->bi_opf &= ~REQ_NOWAIT;
3442+
}
3443+
34273444
if (rq->bio) {
34283445
if (list->tail)
34293446
list->tail->bi_next = rq->bio;

drivers/nvme/host/multipath.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,8 @@ void nvme_failover_req(struct request *req)
154154
}
155155

156156
spin_lock_irqsave(&ns->head->requeue_lock, flags);
157-
for (bio = req->bio; bio; bio = bio->bi_next) {
157+
for (bio = req->bio; bio; bio = bio->bi_next)
158158
bio_set_dev(bio, ns->head->disk->part0);
159-
if (bio->bi_opf & REQ_POLLED) {
160-
bio->bi_opf &= ~REQ_POLLED;
161-
bio->bi_cookie = BLK_QC_T_NONE;
162-
}
163-
/*
164-
* The alternate request queue that we may end up submitting
165-
* the bio to may be frozen temporarily, in this case REQ_NOWAIT
166-
* will fail the I/O immediately with EAGAIN to the issuer.
167-
* We are not in the issuer context which cannot block. Clear
168-
* the flag to avoid spurious EAGAIN I/O failures.
169-
*/
170-
bio->bi_opf &= ~REQ_NOWAIT;
171-
}
172159
blk_steal_bios(&ns->head->requeue_list, req);
173160
spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
174161

0 commit comments

Comments
 (0)