Skip to content

Commit ce86dad

Browse files
igawChristoph Hellwig
authored andcommitted
nvme-multipath: reset bdev to ns head when failover
When a request finally completes in end_io() after it has failed over, the bdev pointer can be stale and thus the system can crash. Set the bdev back to ns head, so the request is map to an active path when resubmitted. Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent d4060d2 commit ce86dad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/nvme/host/multipath.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void nvme_failover_req(struct request *req)
7070
struct nvme_ns *ns = req->q->queuedata;
7171
u16 status = nvme_req(req)->status & 0x7ff;
7272
unsigned long flags;
73+
struct bio *bio;
7374

7475
nvme_mpath_clear_current_path(ns);
7576

@@ -84,6 +85,8 @@ void nvme_failover_req(struct request *req)
8485
}
8586

8687
spin_lock_irqsave(&ns->head->requeue_lock, flags);
88+
for (bio = req->bio; bio; bio = bio->bi_next)
89+
bio_set_dev(bio, ns->head->disk->part0);
8790
blk_steal_bios(&ns->head->requeue_list, req);
8891
spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
8992

0 commit comments

Comments
 (0)