From 80e71a6f963001907b1265fb4999ea1582940acb Mon Sep 17 00:00:00 2001 From: mav Date: Thu, 25 Jun 2015 07:08:46 +0000 Subject: [PATCH] MFC r284641: Fix REPORT LUNS command output for the case when same LUN mapped to same port several times. While it is unusual configuration, it is not illegal. git-svn-id: svn://svn.freebsd.org/base/stable/10@284795 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/cam/ctl/ctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 7321f1463..47f0273e6 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9452,11 +9452,16 @@ ctl_report_luns(struct ctl_scsiio *ctsio) well_known = 0; cdb = (struct scsi_report_luns *)ctsio->cdb; + port = ctl_io_port(&ctsio->io_hdr); CTL_DEBUG_PRINT(("ctl_report_luns\n")); mtx_lock(&softc->ctl_lock); - num_luns = softc->num_luns; + num_luns = 0; + for (targ_lun_id = 0; targ_lun_id < CTL_MAX_LUNS; targ_lun_id++) { + if (ctl_lun_map_from_port(port, targ_lun_id) < CTL_MAX_LUNS) + num_luns++; + } mtx_unlock(&softc->ctl_lock); switch (cdb->select_report) { @@ -9499,7 +9504,6 @@ ctl_report_luns(struct ctl_scsiio *ctsio) request_lun = (struct ctl_lun *) ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - port = ctl_io_port(&ctsio->io_hdr); lun_datalen = sizeof(*lun_data) + (num_luns * sizeof(struct scsi_report_luns_lundata)); -- 2.45.0