Try to automatically scan and attach luns for modern storage
authorPeter Avalos <pavalos@dragonflybsd.org>
Wed, 28 Nov 2007 22:37:05 +0000 (22:37 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Wed, 28 Nov 2007 22:37:05 +0000 (22:37 +0000)
which has luns in the 0..1000 range, not 0..7.

Obtained-from: FreeBSD

sys/bus/cam/cam_xpt.c

index 086402f..a4f75b9 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/cam_xpt.c,v 1.80.2.18 2002/12/09 17:31:55 gibbs Exp $
- * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.48 2007/11/28 22:27:57 pavalos Exp $
+ * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.49 2007/11/28 22:37:05 pavalos Exp $
  */
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -200,10 +200,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
@@ -5126,7 +5136,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
                        crit_enter();
                        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);
                        }
@@ -5142,8 +5152,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++;
                        }
                }