Skip to contentSkip to conversation

Reattach device_handler for multipathing

PATCH In review Hannes Reinecke 2 participants 2 messages Apr 23, 2009 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reattach device_handler for multipathing

When specifying a different hardware handler via multipath features we should be able to override the built-in defaults.

---
 drivers/md/dm-mpath.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +12 -2
index 095f77b..e6611de 100644
@@ -592,9 +592,19 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
 	}
 
 	if (m->hw_handler_name) {
-		r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
-				   m->hw_handler_name);
+		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (r == -EBUSY) {
+			/*
+			 * Already attached to different hw_handler,
+			 * try to reattach with correct one.
+			 */
+			scsi_dh_detach(q);
+			r = scsi_dh_attach(q, m->hw_handler_name);
+		}
 		if (r < 0) {
+			ti->error = "error attaching hardware handler";
 			dm_put_device(ti, p->path.dev);
 			goto bad;
 		}
Signature · 1 line
1.5.3.2
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hannes Reinecke

When specifying a different hardware handler via multipath features we should be able to override the built-in defaults.

Quoted 30 lines
---
 drivers/md/dm-mpath.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +12 -2
index 095f77b..e6611de 100644
@@ -592,9 +592,19 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
 	}
 
 	if (m->hw_handler_name) {
-		r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
-				   m->hw_handler_name);
+		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (r == -EBUSY) {
+			/*
+			 * Already attached to different hw_handler,
+			 * try to reattach with correct one.
+			 */
+			scsi_dh_detach(q);
+			r = scsi_dh_attach(q, m->hw_handler_name);
+		}
 		if (r < 0) {
+			ti->error = "error attaching hardware handler";
 			dm_put_device(ti, p->path.dev);
 			goto bad;
 		}