Skip to contentSkip to conversation

nvme: reset disk to the mpath node also when requeuing

PATCH In review Daniel Wagner 2 participants 2 messages Jun 2, 2021 – Jun 3, 2021 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme: reset disk to the mpath node also when requeuing

Commit ce86dad222e9 ("nvme-multipath: reset bdev to ns head when failover") moved the reset code where the bio is added to the requeue_list for the failover path. But it left the original bio_set_dev() in nvme_requeue_work().

Let's move the bio_set_dev() where we add the bio to the requeue_list and avoid the double setting in case of the failover path. And this makes the code more consistent.

---

v2: loop over all bios and reset them

 drivers/nvme/host/multipath.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/nvme/host/multipath.c +3 -5
index 127a17b4c13d..3334c6f23476 100644
@@ -302,6 +302,7 @@ static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
 	struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;
 	struct device *dev = disk_to_dev(head->disk);
 	struct nvme_ns *ns;
+	struct bio *b;
 	blk_qc_t ret = BLK_QC_T_NONE;
 	int srcu_idx;
 
@@ -324,6 +325,8 @@ static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
 		dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n");
 
 		spin_lock_irq(&head->requeue_lock);
+		for (b = bio; b; b = b->bi_next)
+			bio_set_dev(b, head->disk->part0);
 		bio_list_add(&head->requeue_list, bio);
 		spin_unlock_irq(&head->requeue_lock);
 	} else {
@@ -435,11 +438,6 @@ static void nvme_requeue_work(struct work_struct *work)
 		next = bio->bi_next;
 		bio->bi_next = NULL;
 
-		/*
-		 * Reset disk to the mpath node and resubmit to select a new
-		 * path.
-		 */
-		bio_set_dev(bio, head->disk->part0);
 		submit_bio_noacct(bio);
 	}
 }
Signature · 1 line
2.29.2
#1 lore raw

drivers/nvme/host/multipath.c static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio) · line 332

Quoted 13 lines · Daniel Wagner
drivers/nvme/host/multipath.c +3 -0
+	struct bio *b;
 	blk_qc_t ret = BLK_QC_T_NONE;
 	int srcu_idx;
@@ -324,6 +325,8 @@ static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
 		dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n");
 
 		spin_lock_irq(&head->requeue_lock);
+		for (b = bio; b; b = b->bi_next)
+			bio_set_dev(b, head->disk->part0);
 		bio_list_add(&head->requeue_list, bio);
 		spin_unlock_irq(&head->requeue_lock);
 	} else {

I can't see why we'd need this hunk. bio->bi_bdev should have never been changed to start with in this path.

drivers/nvme/host/multipath.c static void nvme_requeue_work(struct work_struct *work) · line 442

Quoted 11 lines
drivers/nvme/host/multipath.c +0 -5
@@ -435,11 +438,6 @@ static void nvme_requeue_work(struct work_struct *work)
 		next = bio->bi_next;
 		bio->bi_next = NULL;
 
-		/*
-		 * Reset disk to the mpath node and resubmit to select a new
-		 * path.
-		 */
-		bio_set_dev(bio, head->disk->part0);
 		submit_bio_noacct(bio);
 	}

This hunk looks fine.