This is a somewhat imperfect means to try and bring FreeBSD forward in

its ability to automatically scan and attach luns for modern storage
which has luns in the 0..1000 range, not 0..7.

The correct thing would be to do REPORT LUNS for devices whose LUN0
version shows a version >= SCSI3, but lacking that we should be able
to search higher than LUN 7 if we're >= SCSI3 with no ill effects.

This change keeps all of the QUIRK_HILUNS quirks, obeys the QUIRK_NOLUNS,
and introduces a QUIRK_NOHILUNS which will keep searches above LUN 7
happening for devices that report >= SCSI3 compliance. I doubt the latter
will be needed, but you never know.

This allowed me to randomly scan and attach  > 500 disks at a time in
a situation where quirking for QUIRK_HILUNS wasn't practical (the
vendor id and product id changes of the virtualization changes
constantly).

Reviewed by:	ken@freebsd.org, scottl@freebsd.org, gibbs@freebsd.org
MFC after:	2 weeks
This commit is contained in:
mjacob 2005-01-22 22:46:45 +00:00
parent 96960d4e34
commit 2ae6a1b3d3

View File

@ -199,10 +199,20 @@ struct xpt_quirk_entry {
#define CAM_QUIRK_NOLUNS 0x01
#define CAM_QUIRK_NOSERIAL 0x02
#define CAM_QUIRK_HILUNS 0x04
#define CAM_QUIRK_NOHILUNS 0x08
u_int mintags;
u_int maxtags;
};
#define CAM_SCSI2_MAXLUN 8
/*
* If we're not quirked to search <= the first 8 luns
* and we are either quirked to search above lun 8,
* or we're > SCSI-2, we can look for luns above lun 8.
*/
#define CAN_SRCH_HI(dv) \
(((dv->quirk->quirks & CAM_QUIRK_NOHILUNS) == 0) \
&& ((dv->quirk->quirks & CAM_QUIRK_HILUNS) \
|| SID_ANSI_REV(&dv->inq_data) > SCSI_REV_2))
typedef enum {
XPT_FLAG_OPEN = 0x01
@ -5294,7 +5304,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
s = splcam();
device = TAILQ_FIRST(&target->ed_entries);
if (device != NULL) {
phl = device->quirk->quirks & CAM_QUIRK_HILUNS;
phl = CAN_SRCH_HI(device);
if (device->lun_id == 0)
device = TAILQ_NEXT(device, links);
}
@ -5310,8 +5320,8 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
if ((device->quirk->quirks & CAM_QUIRK_NOLUNS) == 0) {
/* Try the next lun */
if (lun_id < (CAM_SCSI2_MAXLUN-1) ||
(device->quirk->quirks & CAM_QUIRK_HILUNS))
if (lun_id < (CAM_SCSI2_MAXLUN-1)
|| CAN_SRCH_HI(device))
lun_id++;
}
}