Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
scsi_scan.c File Reference
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/spinlock.h>
#include <linux/async.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_driver.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_eh.h>
#include "scsi_priv.h"
#include "scsi_logging.h"

Go to the source code of this file.

Data Structures

struct  async_scan_data
 

Macros

#define ALLOC_FAILURE_MSG
 
#define SCSI_TIMEOUT   (2*HZ)
 
#define SCSI_UID_SER_NUM   'S'
 
#define SCSI_UID_UNKNOWN   'Z'
 
#define SCSI_SCAN_NO_RESPONSE   0
 
#define SCSI_SCAN_TARGET_PRESENT   1
 
#define SCSI_SCAN_LUN_PRESENT   2
 
#define MAX_SCSI_LUNS   512
 
#define SCSI_SCAN_TYPE_DEFAULT   "sync"
 

Functions

 module_param_named (max_luns, max_scsi_luns, uint, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (max_luns,"last scsi LUN (should be between 1 and 2^32-1)")
 
 module_param_string (scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO)
 
 MODULE_PARM_DESC (scan,"sync, async or none")
 
 module_param_named (max_report_luns, max_scsi_report_luns, uint, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (max_report_luns,"REPORT LUNS maximum number of LUNS received (should be"" between 1 and 16384)")
 
 module_param_named (inq_timeout, scsi_inq_timeout, uint, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (inq_timeout,"Timeout (in seconds) waiting for devices to answer INQUIRY."" Default is 20. Some devices may need more; most need less.")
 
int scsi_complete_async_scans (void)
 
int scsi_is_target_device (const struct device *dev)
 
 EXPORT_SYMBOL (scsi_is_target_device)
 
void scsi_target_reap (struct scsi_target *starget)
 
int scsilun_to_int (struct scsi_lun *scsilun)
 
 EXPORT_SYMBOL (scsilun_to_int)
 
void int_to_scsilun (unsigned int lun, struct scsi_lun *scsilun)
 
 EXPORT_SYMBOL (int_to_scsilun)
 
struct scsi_device__scsi_add_device (struct Scsi_Host *shost, uint channel, uint id, uint lun, void *hostdata)
 
 EXPORT_SYMBOL (__scsi_add_device)
 
int scsi_add_device (struct Scsi_Host *host, uint channel, uint target, uint lun)
 
 EXPORT_SYMBOL (scsi_add_device)
 
void scsi_rescan_device (struct device *dev)
 
 EXPORT_SYMBOL (scsi_rescan_device)
 
void scsi_scan_target (struct device *parent, unsigned int channel, unsigned int id, unsigned int lun, int rescan)
 
 EXPORT_SYMBOL (scsi_scan_target)
 
int scsi_scan_host_selected (struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun, int rescan)
 
void scsi_scan_host (struct Scsi_Host *shost)
 
 EXPORT_SYMBOL (scsi_scan_host)
 
void scsi_forget_host (struct Scsi_Host *shost)
 
struct scsi_devicescsi_get_host_dev (struct Scsi_Host *shost)
 
 EXPORT_SYMBOL (scsi_get_host_dev)
 
void scsi_free_host_dev (struct scsi_device *sdev)
 
 EXPORT_SYMBOL (scsi_free_host_dev)
 

Macro Definition Documentation

#define ALLOC_FAILURE_MSG
Value:
KERN_ERR "%s: Allocation failure during" \
" SCSI scanning, some SCSI devices might not be configured\n"

Definition at line 50 of file scsi_scan.c.

#define MAX_SCSI_LUNS   512

Definition at line 82 of file scsi_scan.c.

#define SCSI_SCAN_LUN_PRESENT   2

Definition at line 78 of file scsi_scan.c.

#define SCSI_SCAN_NO_RESPONSE   0

Definition at line 76 of file scsi_scan.c.

#define SCSI_SCAN_TARGET_PRESENT   1

Definition at line 77 of file scsi_scan.c.

#define SCSI_SCAN_TYPE_DEFAULT   "sync"

Definition at line 97 of file scsi_scan.c.

#define SCSI_TIMEOUT   (2*HZ)

Definition at line 56 of file scsi_scan.c.

#define SCSI_UID_SER_NUM   'S'

Definition at line 61 of file scsi_scan.c.

#define SCSI_UID_UNKNOWN   'Z'

Definition at line 62 of file scsi_scan.c.

Function Documentation

struct scsi_device* __scsi_add_device ( struct Scsi_Host shost,
uint  channel,
uint  id,
uint  lun,
void hostdata 
)
read

Definition at line 1505 of file scsi_scan.c.

EXPORT_SYMBOL ( scsi_is_target_device  )
EXPORT_SYMBOL ( scsilun_to_int  )
EXPORT_SYMBOL ( int_to_scsilun  )
EXPORT_SYMBOL ( __scsi_add_device  )
EXPORT_SYMBOL ( scsi_add_device  )
EXPORT_SYMBOL ( scsi_rescan_device  )
EXPORT_SYMBOL ( scsi_scan_target  )
EXPORT_SYMBOL ( scsi_scan_host  )
EXPORT_SYMBOL ( scsi_get_host_dev  )
EXPORT_SYMBOL ( scsi_free_host_dev  )
void int_to_scsilun ( unsigned int  lun,
struct scsi_lun scsilun 
)

int_to_scsilun - reverts an int into a scsi_lun : integer to be reverted : struct scsi_lun to be set.

Description: Reverts the functionality of the scsilun_to_int, which packed an 8-byte lun value into an int. This routine unpacks the int back into the lun value. Note: the scsilun_to_int() routine does not truly handle all 8bytes of the lun value. This functions restores only as much as was set by the routine.

Notes: Given an integer : 0x0b030a04, this function returns a scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00

Definition at line 1271 of file scsi_scan.c.

module_param_named ( max_luns  ,
max_scsi_luns  ,
uint  ,
S_IRUGO S_IWUSR 
)
module_param_named ( max_report_luns  ,
max_scsi_report_luns  ,
uint  ,
S_IRUGO S_IWUSR 
)
module_param_named ( inq_timeout  ,
scsi_inq_timeout  ,
uint  ,
S_IRUGO S_IWUSR 
)
module_param_string ( scan  ,
scsi_scan_type  ,
sizeof(scsi_scan_type)  ,
S_IRUGO   
)
MODULE_PARM_DESC ( max_luns  ,
"last scsi LUN (should be between 1 and 2^32-1)"   
)
MODULE_PARM_DESC ( scan  ,
sync,
async or none  
)
MODULE_PARM_DESC ( max_report_luns  ,
"REPORT LUNS maximum number of LUNS received (should be"" between 1 and 16384)"   
)
MODULE_PARM_DESC ( inq_timeout  ,
"Timeout (in seconds) waiting for devices to answer INQUIRY."" Default is 20. Some devices may need more; most need less."   
)
int scsi_add_device ( struct Scsi_Host host,
uint  channel,
uint  target,
uint  lun 
)

Definition at line 1537 of file scsi_scan.c.

int scsi_complete_async_scans ( void  )

scsi_complete_async_scans - Wait for asynchronous scans to complete

When this function returns, any host which started scanning before this function was called will have finished its scan. Hosts which started scanning after this function was called may or may not have finished.

Definition at line 144 of file scsi_scan.c.

void scsi_forget_host ( struct Scsi_Host shost)

Definition at line 1884 of file scsi_scan.c.

void scsi_free_host_dev ( struct scsi_device sdev)

scsi_free_host_dev - Free a scsi_device that points to the host adapter itself : Host device to be freed

Lock status: None assumed.

Returns: Nothing

Definition at line 1950 of file scsi_scan.c.

struct scsi_device* scsi_get_host_dev ( struct Scsi_Host shost)
read

scsi_get_host_dev - Create a scsi_device that points to the host adapter itself : Host that needs a scsi_device

Lock status: None assumed.

Returns: The scsi_device or NULL

Notes: Attach a single scsi_device to the Scsi_Host - this should be made to look like a "pseudo-device" that points to the HA itself.

Note - this device is not accessible from any high-level drivers (including generics), which is probably not optimal. We can add hooks later to attach.

Definition at line 1918 of file scsi_scan.c.

int scsi_is_target_device ( const struct device dev)

Definition at line 346 of file scsi_scan.c.

void scsi_rescan_device ( struct device dev)

Definition at line 1550 of file scsi_scan.c.

void scsi_scan_host ( struct Scsi_Host shost)

scsi_scan_host - scan the given adapter : adapter to scan

Definition at line 1859 of file scsi_scan.c.

int scsi_scan_host_selected ( struct Scsi_Host shost,
unsigned int  channel,
unsigned int  id,
unsigned int  lun,
int  rescan 
)

Definition at line 1683 of file scsi_scan.c.

void scsi_scan_target ( struct device parent,
unsigned int  channel,
unsigned int  id,
unsigned int  lun,
int  rescan 
)

scsi_scan_target - scan a target id, possibly including all LUNs on the target. : host to scan : channel to scan : target id to scan : Specific LUN to scan or SCAN_WILD_CARD : passed to LUN scanning routines

Description: Scan the target id on , , and . Scan at least LUN 0, and possibly all LUNs on the target id.

First try a REPORT LUN scan, if that does not scan the target, do a sequential scan of LUNs on the target id.

Definition at line 1632 of file scsi_scan.c.

void scsi_target_reap ( struct scsi_target starget)

scsi_target_reap - check to see if target is in use and destroy if not : target to be checked

This is used after removing a LUN or doing a last put of the target it checks atomically that nothing is using the target and removes it if so.

Definition at line 475 of file scsi_scan.c.

int scsilun_to_int ( struct scsi_lun scsilun)

scsilun_to_int - convert a scsi_lun to an int : struct scsi_lun to be converted.

Description: Convert from a struct scsi_lun to a four byte host byte-ordered integer, and return the result. The caller must check for truncation before using this function.

Notes: The struct scsi_lun is assumed to be four levels, with each level effectively containing a SCSI byte-ordered (big endian) short; the addressing bits of each level are ignored (the highest two bits). For a description of the LUN format, post SCSI-3 see the SCSI Architecture Model, for SCSI-3 see the SCSI Controller Commands.

Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns the integer: 0x0b030a04

Definition at line 1240 of file scsi_scan.c.