ib_srp: Avoid that LUN scanning creates duplicate devices
Subsystems (2)
PATCH 1/1 ib_srp: Avoid that LUN scanning creates duplicate devices
SCSI scanning of a channel:id:lun triplet in Linux works as follows (function scsi_scan_target() in drivers/scsi/scsi_scan.c):
- If lun == SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result.
- If lun != SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists.
So a SCSI driver must either take the channel and target id values in account in its quecommand() function or it should declare that it only supports one channel and one target id. Currently the ib_srp driver does neither. As a result scanning the SCSI bus via e.g. rescan-scsi-bus.sh causes many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that the ib_srp driver only supports one channel and one target id.
--- drivers/infiniband/ulp/srp/ib_srp.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +2 -0
@@ -2127,6 +2127,8 @@ static ssize_t srp_create_target(struct device *dev,return -ENOMEM ; target_host->transportt = ib_srp_transport_template; + target_host->max_channel =0 ; + target_host->max_id =1 ; target_host->max_lun =SRP_MAX_LUN ; target_host->max_cmd_len =sizeof ((struct srp_cmd *) (void *)0L )->cdb;
Signature · 6 lines
1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Bart Van Assche
SCSI scanning of a channel:id:lun triplet in Linux works as follows (function
scsi_scan_target()indrivers/scsi/scsi_scan.c):
- If lun ==SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result.
- If lun !=SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists.
Quoted 8 lines
So a SCSI driver must either take the channel and target id values in account in its
quecommand()function or it should declare that it only supports one channel and one target id. Currently theib_srpdriver does neither. As a result scanning the SCSI bus via e.g.rescan-scsi-bus.shcauses many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that theib_srpdriver only supports one channel and one target id.
Looks good. We should probably consider chosing sane defaults at least for max_channel, but for now this is the best fix.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Christoph Hellwig
Quoted 6 lines · Bart Van Assche
SCSI scanning of a channel:id:lun triplet in Linux works as follows (function
scsi_scan_target()indrivers/scsi/scsi_scan.c):
- If lun ==SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result.
- If lun !=SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists.Quoted 8 lines
So a SCSI driver must either take the channel and target id values in account in its
quecommand()function or it should declare that it only supports one channel and one target id. Currently theib_srpdriver does neither. As a result scanning the SCSI bus via e.g.rescan-scsi-bus.shcauses many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that theib_srpdriver only supports one channel and one target id.
Quoted 2 lines
Looks good. We should probably consider chosing sane defaults at least for
max_channel, but for now this is the best fix.
The default for max_channel is already zero, so strictly speaking it is not necessary to set max_channel in srp_target_create(). I choose to set it anyway to make the intent clear that currently ib_srp only supports channel == 0 and id == 0.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Bart Van Assche
The default for
max_channelis already zero, so strictly speaking it is not necessary to setmax_channelinsrp_target_create(). I choose to set it anyway to make the intent clear that currentlyib_srponly supports channel == 0 and id == 0.
You're right. I'm not sure changing max_id is as easy - most SCSI drivers are still for old SPI HBAs, so we'd need to update them all. Eventually we should do it, though as most modern topologies don't need the traditional sequential target scanning at all. In fact we shouldn't be using scsi_scan_host for them to start with.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Dillow
Acked-byQuoted 15 lines · Bart Van Assche
SCSI scanning of a channel:id:lun triplet in Linux works as follows (function
scsi_scan_target()indrivers/scsi/scsi_scan.c):
- If lun ==SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result.
- If lun !=SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists.
So a SCSI driver must either take the channel and target id values in account in itsquecommand()function or it should declare that it only supports one channel and one target id. Currently theib_srpdriver does neither. As a result scanning the SCSI bus via e.g.rescan-scsi-bus.shcauses many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that theib_srpdriver only supports one channel and one target id.
Quoted 2 lines
Signed-off-by Bart Van Assche <[email protected]>Cc David Dillow <[email protected]>
Thanks for the additional detail in the commit message.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 16 lines · David Dillow
Quoted 15 lines · Bart Van Assche
SCSI scanning of a channel:id:lun triplet in Linux works as follows (function
scsi_scan_target()indrivers/scsi/scsi_scan.c):
- If lun ==SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result.
- If lun !=SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists. So a SCSI driver must either take the channel and target id values in account in itsquecommand()function or it should declare that it only supports one channel and one target id. Currently theib_srpdriver does neither. As a result scanning the SCSI bus via e.g.rescan-scsi-bus.shcauses many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that theib_srpdriver only supports one channel and one target id.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Bart Van Assche <[email protected]>Cc David Dillow <[email protected]>Thanks for the additional detail in the commit message.
Acked-by David Dillow <[email protected]>
Hi Dave,
Thanks for acking. Through which tree should this patch go in ?
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 15 lines · Bart Van Assche
Quoted 14 lines · David Dillow
Quoted 11 lines · Bart Van Assche
So a SCSI driver must either take the channel and target id values in account in its
quecommand()function or it should declare that it only supports one channel and one target id. Currently theib_srpdriver does neither. As a result scanning the SCSI bus via e.g.rescan-scsi-bus.shcauses many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that theib_srpdriver only supports one channel and one target id.Signed-off-by Bart Van Assche <[email protected]>Cc David Dillow <[email protected]>
Quoted 7 lines
Quoted 3 lines
Thanks for the additional detail in the commit message.
Acked-by David Dillow <[email protected]>Hi Dave,
Thanks for acking. Through which tree should this patch go in ?
I Ack'd thinking Roland would pick it up directly since has done that in the past for singe patches, but I'm fine with pulling it into my tree and pushing that way.
Roland?
Signature · 10 lines
Dave Dillow National Center for Computational Science Oak Ridge National Laboratory (865) 241-6602 office -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · David Dillow
I Ack'd thinking Roland would pick it up directly since has done that in the past for singe patches, but I'm fine with pulling it into my tree and pushing that way.
Roland?
I've had it in my for-next branch for a while now... since it wasn't a regression (AFAICT, we've been that way approximately forever), I was waiting for 3.1 to ask Linus to take it.
- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html