Skip to contentSkip to conversation

2.5.3-pre5 SCSI REPORT LUN scanning

PATCH New Patrick Mansfield 1 participant 1 message Jan 29, 2002 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.3-pre5 SCSI REPORT LUN scanning

Hi all -

Here's a patch for SCSI REPORT LUN scanning.

It's against linux-2.5.3-pre5.

In addition to the SCSI REPORT LUN support, it includes:

A new scan_scsis_target function based on code in scan_scsis, and parts of scan_scsis_single. Adding this function cleans up the scanning code, and removes a really ugly for loop. It would be difficult to cleanly add REPORT LUN scanning without such a function.

Adds missing scsi_release_commandblocks() calls.

Does not set max_dev_lun out of bounds for BLIST_FORCELUN devices.

It also fixes scanning past LUN 7 for SCSI-3 devices (the patch in 2.4.17 for that fix will not apply correctly against this code).

I tested this code on a x86 system with a fastt 200 (LSI Triton, IBM 3542); this device is not very interesting, since the firmware I have on it always gives back LUNs 0 - 31 in the REPORT LUNS result, even when I don't have LUNs configured there.

I previously tested similar code in a 2.4.x kernel against a Hitachi DF400, and an EMC Symmetrix box; the code failed when run with an Emulex adapter and driver.

I have not tested going past LUN 255, or a with the fastt configured to appear as a sparse LUN configuration. Good test points would be to go past LUN 255, and then past LUN 2^16 (if any such devices exist, and any adapter drivers support it), and to test on a big-endian machine (past LUN 255; current linux lun is in host-order, but the SCSI 8 byte LUN is comparable to 4 short big-endian integers).

Sequential scanning should be compatible with the current code.

Any suggestions, comments, flames?

Thanks.

-- Patrick Mansfield

drivers/scsi/Config.help +7 -0
diff -urN -X dontdiff linux-2.5.3-pre5/drivers/scsi/Config.help linux-2.5.3-pre5-repluns/drivers/scsi/Config.help
@@ -145,6 +145,13 @@
   so most people can say N here and should in fact do so, because it
   is safer.
 
+CONFIG_SCSI_REPORT_LUNS
+  If you want to build with SCSI REPORT LUNS support in the kernel, say Y here.
+  The REPORT LUNS command is useful for devices (such as disk arrays) with
+  large numbers of LUNs where the LUN values are not contiguous (sparse LUN).
+  REPORT LUNS scanning is done only for SCSI-3 devices. Most users can safely
+  answer N here.
+
 CONFIG_SCSI_CONSTANTS
   The error messages regarding your SCSI hardware will be easier to
   understand if you say Y here; it will enlarge your kernel by about
drivers/scsi/Config.in +1 -0
diff -urN -X dontdiff linux-2.5.3-pre5/drivers/scsi/Config.in linux-2.5.3-pre5-repluns/drivers/scsi/Config.in
@@ -21,6 +21,7 @@
 comment 'Some SCSI devices (e.g. CD jukebox) support multiple LUNs'
 
 bool '  Probe all LUNs on each SCSI device' CONFIG_SCSI_MULTI_LUN
+bool '  Build with SCSI REPORT LUNS support' CONFIG_SCSI_REPORT_LUNS
   
 bool '  Verbose SCSI error reporting (kernel size +=12K)' CONFIG_SCSI_CONSTANTS
 bool '  SCSI logging facility' CONFIG_SCSI_LOGGING
drivers/scsi/scsi_scan.c +501 -106

771 lines not on this page · raw message

include/scsi/scsi.h +11 -0
diff -urN -X dontdiff linux-2.5.3-pre5/include/scsi/scsi.h linux-2.5.3-pre5-repluns/include/scsi/scsi.h
@@ -78,6 +78,7 @@
 #define MODE_SENSE_10         0x5a
 #define PERSISTENT_RESERVE_IN 0x5e
 #define PERSISTENT_RESERVE_OUT 0x5f
+#define REPORT_LUNS           0xa0
 #define MOVE_MEDIUM           0xa5
 #define READ_12               0xa8
 #define WRITE_12              0xaa
@@ -162,6 +163,16 @@
     u_char  block_length_med;
     u_char  block_length_lo;
 };
+
+/*
+ * ScsiLun: 8 byte lun. This is represented as four shorts, in order
+ * to make the conversion to an integer (4 or 8 byte) simpler. Per
+ * the SCSI spec, it is really 4 LUN levels, and each level is 2
+ * bytes long.
+ */
+typedef struct scsi_lun {
+	u16 scsi_lun[4];
+} ScsiLun;
 
 /*
  *  MESSAGE CODES