Reattach device handler for multipath devices
Subsystems (2)
PATCH 1/1 Reattach device handler for multipath devices
Hi James, Aladair,
when using multipath the daemon might have specified a different device handler than used by default. (Eg Clariion in ALUA mode).
For these cases we currently cannot setup a multipath map automatically as scsi_dh_attach() will fail. Instead we should be trying to reattach with the correct device handler and only return an error if that fails.
Please apply.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg)
Reattach device handler for multipath devices
The multipath daemon might have specified a different device_handler than the one a device is attached to by default.
So we should try to re-attach with the user-specified device_handler and only return an error if that fails.
Signed-off-by Hannes Reinecke <[email protected]
drivers/md/dm-mpath.c +12 -2
@@ -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; }
drivers/scsi/device_handler/scsi_dh.c +3 -6
@@ -504,12 +504,9 @@ void scsi_dh_detach(struct request_queue *q)if (!sdev)return ; -if (sdev->scsi_dh_data) { -/* if sdev is not on internal list, detach */ - scsi_dh = sdev->scsi_dh_data->scsi_dh; -if (!device_handler_match (scsi_dh, sdev)) -scsi_dh_handler_detach (sdev, scsi_dh); - } +if (sdev->scsi_dh_data) +scsi_dh_handler_detach (sdev, sdev->scsi_dh_data->scsi_dh); +put_device (&sdev->sdev_gendev); }EXPORT_SYMBOL_GPL (scsi_dh_detach);