Skip to content

Commit a50fdeb

Browse files
Chaitanya Kulkarnikawasaki
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]>
1 parent 868d59a commit a50fdeb

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
@@ -3422,6 +3422,23 @@ EXPORT_SYMBOL_GPL(blk_rq_prep_clone);
34223422
*/
34233423
void blk_steal_bios(struct bio_list *list, struct request *rq)
34243424
{
3425+
struct bio *bio;
3426+
3427+
for (bio = rq->bio; bio; bio = bio->bi_next) {
3428+
if (bio->bi_opf & REQ_POLLED) {
3429+
bio->bi_opf &= ~REQ_POLLED;
3430+
bio->bi_cookie = BLK_QC_T_NONE;
3431+
}
3432+
/*
3433+
* The alternate request queue that we may end up submitting
3434+
* the bio to may be frozen temporarily, in this case REQ_NOWAIT
3435+
* will fail the I/O immediately with EAGAIN to the issuer.
3436+
* We are not in the issuer context which cannot block. Clear
3437+
* the flag to avoid spurious EAGAIN I/O failures.
3438+
*/
3439+
bio->bi_opf &= ~REQ_NOWAIT;
3440+
}
3441+
34253442
if (rq->bio) {
34263443
if (list->tail)
34273444
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)