Commit 6da71acc authored by Douglas Gilbert's avatar Douglas Gilbert Committed by Jaroslav Kysela

[PATCH] Report Luns for scsi devices 2.5.10

Here's a patch for SCSI REPORT LUN scanning, including Douglas Gilbert's
recent changes to support a short INQUIRY followed by a longer INQUIRY.

Please apply, or let me know if you think it needs any modifications.

It's against linux-2.5.4. It does _not_ change the size of the linux lun.

A description of the 8 byte LUN layout can be found on page 35 of:

ftp://ftp.t10.org/t10/drafts/scc2/scc2r04.pdf

The above is a draft, but matches the layout seen on most disk arrays
(including EMC, IBM, LSI, and Hitachi). Later drafts (post SCSI-3) have
this information in the SCSI Architectural Model.

Patch description:

Adds REPORT LUN scanning.

Adds Douglas Gilbert's INQUIRY modification so broken devices that cannot handlean INQUIRY
of more than 36 bytes can be black-listed, plus saving the INQUIRY
result in Scsi_Device.

Adds scan_scsis_target function, replacing code in scan_scsis and parts
of scan_scsis_single. This cleans up the scanning code, and removes a
really ugly for loop. It would be difficult to add REPORT LUN scanning
without this change.

Adds missing scsi_release_commandblocks().

No longer sets max_dev_lun out of bounds for BLIST_FORCELUN devices.

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

-- Patrick Mansfield
parent 557d426c
......@@ -145,6 +145,13 @@ CONFIG_SCSI_MULTI_LUN
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
......
......@@ -21,6 +21,7 @@ dep_tristate ' SCSI generic support' CONFIG_CHR_DEV_SG $CONFIG_SCSI
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
......
......@@ -158,6 +158,8 @@ const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] =
"Enclosure ",
};
static char * scsi_null_device_strs = "nullnullnullnull";
/*
* Function prototypes.
*/
......@@ -1831,6 +1833,8 @@ static int proc_scsi_gen_write(struct file * file, const char * buf,
HBA_ptr->host_queue = scd->next;
}
blk_cleanup_queue(&scd->request_queue);
if (scd->inquiry)
kfree(scd->inquiry);
kfree((char *) scd);
} else {
goto out;
......@@ -2129,6 +2133,8 @@ int scsi_unregister_host(Scsi_Host_Template * tpnt)
blk_cleanup_queue(&SDpnt->request_queue);
/* Next free up the Scsi_Device structures for this host */
shpnt->host_queue = SDpnt->next;
if (SDpnt->inquiry)
kfree(SDpnt->inquiry);
kfree((char *) SDpnt);
}
......@@ -2618,6 +2624,9 @@ Scsi_Device * scsi_get_host_dev(struct Scsi_Host * SHpnt)
return NULL;
memset(SDpnt, 0, sizeof(Scsi_Device));
SDpnt->vendor = scsi_null_device_strs;
SDpnt->model = scsi_null_device_strs;
SDpnt->rev = scsi_null_device_strs;
SDpnt->host = SHpnt;
SDpnt->id = SHpnt->this_id;
......@@ -2664,6 +2673,8 @@ void scsi_free_host_dev(Scsi_Device * SDpnt)
* it now.
*/
scsi_release_commandblocks(SDpnt);
if (SDpnt->inquiry)
kfree(SDpnt->inquiry);
kfree(SDpnt);
}
......
......@@ -575,7 +575,11 @@ struct scsi_device {
devfs_handle_t de; /* directory for the device */
char type;
char scsi_level;
char vendor[8], model[16], rev[4];
unsigned char inquiry_len; /* valid bytes in 'inquiry' */
unsigned char * inquiry; /* INQUIRY response data */
char * vendor; /* [back_compat] point into 'inquiry' ... */
char * model; /* ... after scan; point to static string */
char * rev; /* ... "nullnullnullnull" before scan */
unsigned char current_tag; /* current tag */
unsigned char sync_min_period; /* Not less than this period */
unsigned char sync_max_offset; /* Not greater than this offset */
......
This diff is collapsed.
......@@ -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
......@@ -130,6 +131,7 @@
#define TYPE_DISK 0x00
#define TYPE_TAPE 0x01
#define TYPE_PRINTER 0x02
#define TYPE_PROCESSOR 0x03 /* HP scanners use this */
#define TYPE_WORM 0x04 /* Treated as ROM by our system */
#define TYPE_ROM 0x05
......@@ -163,6 +165,13 @@ struct ccs_modesel_head
u_char block_length_lo;
};
/*
* ScsiLun: 8 byte LUN.
*/
typedef struct scsi_lun {
u8 scsi_lun[8];
} ScsiLun;
/*
* MESSAGE CODES
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment