summaryrefslogtreecommitdiffstats
path: root/sys/cam/ctl/ctl_tpc_local.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cam/ctl/ctl_tpc_local.c')
-rw-r--r--sys/cam/ctl/ctl_tpc_local.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/sys/cam/ctl/ctl_tpc_local.c b/sys/cam/ctl/ctl_tpc_local.c
index 63360fe..a254418 100644
--- a/sys/cam/ctl/ctl_tpc_local.c
+++ b/sys/cam/ctl/ctl_tpc_local.c
@@ -314,48 +314,30 @@ tpcl_resolve(struct ctl_softc *softc, int init_port,
struct scsi_ec_cscd_id *cscdid;
struct ctl_port *port;
struct ctl_lun *lun;
- uint64_t lunid = UINT64_MAX, l;
- int i;
+ uint64_t lunid = UINT64_MAX;
if (cscd->type_code != EC_CSCD_ID)
return (lunid);
cscdid = (struct scsi_ec_cscd_id *)cscd;
mtx_lock(&softc->ctl_lock);
- if (init_port >= 0) {
+ if (init_port >= 0)
port = softc->ctl_ports[ctl_port_idx(init_port)];
- if (port == NULL || port->lun_map == NULL)
- init_port = -1;
- }
- if (init_port < 0) {
- STAILQ_FOREACH(lun, &softc->lun_list, links) {
- if (lun->lun_devid == NULL)
- continue;
- if (scsi_devid_match(lun->lun_devid->data,
- lun->lun_devid->len, &cscdid->codeset,
- cscdid->length + 4) == 0) {
- lunid = lun->lun;
- if (ss && lun->be_lun)
- *ss = lun->be_lun->blocksize;
- break;
- }
- }
- } else {
- for (i = 0; i < CTL_MAX_LUNS; i++) {
- l = port->lun_map(port->targ_lun_arg, i);
- if (l >= CTL_MAX_LUNS)
- continue;
- lun = softc->ctl_luns[l];
- if (lun == NULL || lun->lun_devid == NULL)
- continue;
- if (scsi_devid_match(lun->lun_devid->data,
- lun->lun_devid->len, &cscdid->codeset,
- cscdid->length + 4) == 0) {
- lunid = lun->lun;
- if (ss && lun->be_lun)
- *ss = lun->be_lun->blocksize;
- break;
- }
+ else
+ port = NULL;
+ STAILQ_FOREACH(lun, &softc->lun_list, links) {
+ if (port != NULL &&
+ ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+ continue;
+ if (lun->lun_devid == NULL)
+ continue;
+ if (scsi_devid_match(lun->lun_devid->data,
+ lun->lun_devid->len, &cscdid->codeset,
+ cscdid->length + 4) == 0) {
+ lunid = lun->lun;
+ if (ss && lun->be_lun)
+ *ss = lun->be_lun->blocksize;
+ break;
}
}
mtx_unlock(&softc->ctl_lock);
OpenPOWER on IntegriCloud