2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _SCSI_PRIV_H
|
|
|
|
#define _SCSI_PRIV_H
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
2012-07-10 06:33:25 +04:00
|
|
|
#include <linux/async.h>
|
2012-05-18 08:56:57 +04:00
|
|
|
#include <scsi/scsi_device.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct request_queue;
|
2008-09-14 16:55:09 +04:00
|
|
|
struct request;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct scsi_cmnd;
|
|
|
|
struct scsi_device;
|
[SCSI] implement runtime Power Management
This patch (as1398b) adds runtime PM support to the SCSI layer. Only
the machanism is provided; use of it is up to the various high-level
drivers, and the patch doesn't change any of them. Except for sg --
the patch expicitly prevents a device from being runtime-suspended
while its sg device file is open.
The implementation is simplistic. In general, hosts and targets are
automatically suspended when all their children are asleep, but for
them the runtime-suspend code doesn't actually do anything. (A host's
runtime PM status is propagated up the device tree, though, so a
runtime-PM-aware lower-level driver could power down the host adapter
hardware at the appropriate times.) There are comments indicating
where a transport class might be notified or some other hooks added.
LUNs are runtime-suspended by calling the drivers' existing suspend
handlers (and likewise for runtime-resume). Somewhat arbitrarily, the
implementation delays for 100 ms before suspending an eligible LUN.
This is because there typically are occasions during bootup when the
same device file is opened and closed several times in quick
succession.
The way this all works is that the SCSI core increments a device's
PM-usage count when it is registered. If a high-level driver does
nothing then the device will not be eligible for runtime-suspend
because of the elevated usage count. If a high-level driver wants to
use runtime PM then it can call scsi_autopm_put_device() in its probe
routine to decrement the usage count and scsi_autopm_get_device() in
its remove routine to restore the original count.
Hosts, targets, and LUNs are not suspended while they are being probed
or removed, or while the error handler is running. In fact, a fairly
large part of the patch consists of code to make sure that things
aren't suspended at such times.
[jejb: fix up compile issues in PM config variations]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-06-17 18:41:42 +04:00
|
|
|
struct scsi_target;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct scsi_host_template;
|
|
|
|
struct Scsi_Host;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-19 01:30:09 +04:00
|
|
|
struct scsi_nl_hdr;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scsi Error Handler Flags
|
|
|
|
*/
|
|
|
|
#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
|
|
|
|
|
|
|
|
#define SCSI_SENSE_VALID(scmd) \
|
|
|
|
(((scmd)->sense_buffer[0] & 0x70) == 0x70)
|
|
|
|
|
|
|
|
/* hosts.c */
|
|
|
|
extern int scsi_init_hosts(void);
|
|
|
|
extern void scsi_exit_hosts(void);
|
|
|
|
|
|
|
|
/* scsi.c */
|
|
|
|
extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
|
|
|
|
extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
|
|
|
|
extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
|
|
|
|
#ifdef CONFIG_SCSI_LOGGING
|
|
|
|
void scsi_log_send(struct scsi_cmnd *cmd);
|
|
|
|
void scsi_log_completion(struct scsi_cmnd *cmd, int disposition);
|
|
|
|
#else
|
|
|
|
static inline void scsi_log_send(struct scsi_cmnd *cmd)
|
|
|
|
{ };
|
|
|
|
static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
|
|
|
|
{ };
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* scsi_devinfo.c */
|
2009-06-17 23:01:58 +04:00
|
|
|
|
|
|
|
/* list of keys for the lists */
|
|
|
|
enum {
|
|
|
|
SCSI_DEVINFO_GLOBAL = 0,
|
2009-06-17 23:05:05 +04:00
|
|
|
SCSI_DEVINFO_SPI,
|
2009-06-17 23:01:58 +04:00
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int scsi_get_device_flags(struct scsi_device *sdev,
|
2005-12-01 21:50:13 +03:00
|
|
|
const unsigned char *vendor,
|
|
|
|
const unsigned char *model);
|
2009-06-17 23:01:58 +04:00
|
|
|
extern int scsi_get_device_flags_keyed(struct scsi_device *sdev,
|
|
|
|
const unsigned char *vendor,
|
|
|
|
const unsigned char *model, int key);
|
|
|
|
extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor,
|
|
|
|
char *model, char *strflags,
|
|
|
|
int flags, int key);
|
2011-01-06 23:31:29 +03:00
|
|
|
extern int scsi_dev_info_list_del_keyed(char *vendor, char *model, int key);
|
2009-06-17 23:01:58 +04:00
|
|
|
extern int scsi_dev_info_add_list(int key, const char *name);
|
|
|
|
extern int scsi_dev_info_remove_list(int key);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int __init scsi_init_devinfo(void);
|
|
|
|
extern void scsi_exit_devinfo(void);
|
|
|
|
|
|
|
|
/* scsi_error.c */
|
2008-09-14 16:55:09 +04:00
|
|
|
extern enum blk_eh_timer_return scsi_times_out(struct request *req);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int scsi_error_handler(void *host);
|
|
|
|
extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
|
|
|
|
extern void scsi_eh_wakeup(struct Scsi_Host *shost);
|
|
|
|
extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
|
2007-01-27 01:08:49 +03:00
|
|
|
void scsi_eh_ready_devs(struct Scsi_Host *shost,
|
|
|
|
struct list_head *work_q,
|
|
|
|
struct list_head *done_q);
|
|
|
|
int scsi_eh_get_sense(struct list_head *work_q,
|
|
|
|
struct list_head *done_q);
|
2008-08-20 03:45:31 +04:00
|
|
|
int scsi_noretry_cmd(struct scsi_cmnd *scmd);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* scsi_lib.c */
|
|
|
|
extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
|
|
|
|
extern void scsi_device_unbusy(struct scsi_device *sdev);
|
2012-06-29 19:35:05 +04:00
|
|
|
extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void scsi_next_command(struct scsi_cmnd *cmd);
|
Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done""
This reverts commit ac40532ef0b8649e6f7f83859ea0de1c4ed08a19, which gets
us back the original cleanup of 6f5391c283d7fdcf24bf40786ea79061919d1e1d.
It turns out that the bug that was triggered by that commit was
apparently not actually triggered by that commit at all, and just the
testing conditions had changed enough to make it appear to be due to it.
The real problem seems to have been found by Peter Osterlund:
"pktcdvd sets it [block device size] when opening the /dev/pktcdvd
device, but when the drive is later opened as /dev/scd0, there is
nothing that sets it back. (Btw, 40944 is possible if the disk is a
CDRW that was formatted with "cdrwtool -m 10236".)
The problem is that pktcdvd opens the cd device in non-blocking mode
when pktsetup is run, and doesn't close it again until pktsetup -d is
run. The effect is that if you meanwhile open the cd device,
blkdev.c:do_open() doesn't call bd_set_size() because
bdev->bd_openers is non-zero."
In particular, to repeat the bug (regardless of whether commit
6f5391c283d7fdcf24bf40786ea79061919d1e1d is applied or not):
" 1. Start with an empty drive.
2. pktsetup 0 /dev/scd0
3. Insert a CD containing an isofs filesystem.
4. mount /dev/pktcdvd/0 /mnt/tmp
5. umount /mnt/tmp
6. Press the eject button.
7. Insert a DVD containing a non-writable filesystem.
8. mount /dev/scd0 /mnt/tmp
9. find /mnt/tmp -type f -print0 | xargs -0 sha1sum >/dev/null
10. If the DVD contains data beyond the physical size of a CD, you
get I/O errors in the terminal, and dmesg reports lots of
"attempt to access beyond end of device" errors."
which in turn is because the nested open after the media change won't
cause the size to be set properly (because the original open still holds
the block device, and we only do the bd_set_size() when we don't have
other people holding the device open).
The proper fix for that is probably to just do something like
bdev->bd_inode->i_size = (loff_t)get_capacity(disk)<<9;
in fs/block_dev.c:do_open() even for the cases where we're not the
original opener (but *not* call bd_set_size(), since that will also
change the block size of the device).
Cc: Peter Osterlund <petero2@telia.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-06 21:17:12 +03:00
|
|
|
extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void scsi_run_host_queues(struct Scsi_Host *shost);
|
|
|
|
extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
|
|
|
|
extern int scsi_init_queue(void);
|
|
|
|
extern void scsi_exit_queue(void);
|
2008-01-02 20:14:30 +03:00
|
|
|
struct request_queue;
|
|
|
|
struct request;
|
2008-07-18 01:08:48 +04:00
|
|
|
extern struct kmem_cache *scsi_sdb_cache;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* scsi_proc.c */
|
|
|
|
#ifdef CONFIG_SCSI_PROC_FS
|
|
|
|
extern void scsi_proc_hostdir_add(struct scsi_host_template *);
|
|
|
|
extern void scsi_proc_hostdir_rm(struct scsi_host_template *);
|
|
|
|
extern void scsi_proc_host_add(struct Scsi_Host *);
|
|
|
|
extern void scsi_proc_host_rm(struct Scsi_Host *);
|
|
|
|
extern int scsi_init_procfs(void);
|
|
|
|
extern void scsi_exit_procfs(void);
|
|
|
|
#else
|
|
|
|
# define scsi_proc_hostdir_add(sht) do { } while (0)
|
|
|
|
# define scsi_proc_hostdir_rm(sht) do { } while (0)
|
|
|
|
# define scsi_proc_host_add(shost) do { } while (0)
|
|
|
|
# define scsi_proc_host_rm(shost) do { } while (0)
|
|
|
|
# define scsi_init_procfs() (0)
|
|
|
|
# define scsi_exit_procfs() do { } while (0)
|
|
|
|
#endif /* CONFIG_PROC_FS */
|
|
|
|
|
|
|
|
/* scsi_scan.c */
|
[SCSI] scsi_pm: Fix bug in the SCSI power management handler
This patch (as1520) fixes a bug in the SCSI layer's power management
implementation.
LUN scanning can be carried out asynchronously in do_scan_async(), and
sd uses an asynchronous thread for the time-consuming parts of disk
probing in sd_probe_async(). Currently nothing coordinates these
async threads with system sleep transitions; they can and do attempt
to continue scanning/probing SCSI devices even after the host adapter
has been suspended. As one might expect, the outcome is not ideal.
This is what the "prepare" stage of system suspend was created for.
After the prepare callback has been called for a host, target, or
device, drivers are not allowed to register any children underneath
them. Currently the SCSI prepare callback is not implemented; this
patch rectifies that omission.
For SCSI hosts, the prepare routine calls scsi_complete_async_scans()
to wait until async scanning is finished. It might be slightly more
efficient to wait only until the host in question has been scanned,
but there's currently no way to do that. Besides, during a sleep
transition we will ultimately have to wait until all the host scanning
has finished anyway.
For SCSI devices, the prepare routine calls async_synchronize_full()
to wait until sd probing is finished. The routine does nothing for
SCSI targets, because asynchronous target scanning is done only as
part of host scanning.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@kernel.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-02-18 01:25:08 +04:00
|
|
|
extern int scsi_complete_async_scans(void);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
|
|
|
|
unsigned int, unsigned int, int);
|
|
|
|
extern void scsi_forget_host(struct Scsi_Host *);
|
|
|
|
extern void scsi_rescan_device(struct device *);
|
|
|
|
|
|
|
|
/* scsi_sysctl.c */
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
extern int scsi_init_sysctl(void);
|
|
|
|
extern void scsi_exit_sysctl(void);
|
|
|
|
#else
|
|
|
|
# define scsi_init_sysctl() (0)
|
|
|
|
# define scsi_exit_sysctl() do { } while (0)
|
|
|
|
#endif /* CONFIG_SYSCTL */
|
|
|
|
|
|
|
|
/* scsi_sysfs.c */
|
|
|
|
extern int scsi_sysfs_add_sdev(struct scsi_device *);
|
|
|
|
extern int scsi_sysfs_add_host(struct Scsi_Host *);
|
|
|
|
extern int scsi_sysfs_register(void);
|
|
|
|
extern void scsi_sysfs_unregister(void);
|
|
|
|
extern void scsi_sysfs_device_initialize(struct scsi_device *);
|
|
|
|
extern int scsi_sysfs_target_initialize(struct scsi_device *);
|
|
|
|
extern struct scsi_transport_template blank_transport_template;
|
2005-07-26 18:20:53 +04:00
|
|
|
extern void __scsi_remove_device(struct scsi_device *);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
extern struct bus_type scsi_bus_type;
|
2009-06-24 21:06:31 +04:00
|
|
|
extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
|
2005-04-17 02:20:36 +04:00
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-19 01:30:09 +04:00
|
|
|
/* scsi_netlink.c */
|
|
|
|
#ifdef CONFIG_SCSI_NETLINK
|
|
|
|
extern void scsi_netlink_init(void);
|
|
|
|
extern void scsi_netlink_exit(void);
|
|
|
|
extern struct sock *scsi_nl_sock;
|
|
|
|
#else
|
|
|
|
static inline void scsi_netlink_init(void) {}
|
|
|
|
static inline void scsi_netlink_exit(void) {}
|
|
|
|
#endif
|
|
|
|
|
2010-06-17 18:36:49 +04:00
|
|
|
/* scsi_pm.c */
|
2011-02-11 02:06:54 +03:00
|
|
|
#ifdef CONFIG_PM
|
2010-06-17 18:36:49 +04:00
|
|
|
extern const struct dev_pm_ops scsi_bus_pm_ops;
|
|
|
|
#endif
|
[SCSI] implement runtime Power Management
This patch (as1398b) adds runtime PM support to the SCSI layer. Only
the machanism is provided; use of it is up to the various high-level
drivers, and the patch doesn't change any of them. Except for sg --
the patch expicitly prevents a device from being runtime-suspended
while its sg device file is open.
The implementation is simplistic. In general, hosts and targets are
automatically suspended when all their children are asleep, but for
them the runtime-suspend code doesn't actually do anything. (A host's
runtime PM status is propagated up the device tree, though, so a
runtime-PM-aware lower-level driver could power down the host adapter
hardware at the appropriate times.) There are comments indicating
where a transport class might be notified or some other hooks added.
LUNs are runtime-suspended by calling the drivers' existing suspend
handlers (and likewise for runtime-resume). Somewhat arbitrarily, the
implementation delays for 100 ms before suspending an eligible LUN.
This is because there typically are occasions during bootup when the
same device file is opened and closed several times in quick
succession.
The way this all works is that the SCSI core increments a device's
PM-usage count when it is registered. If a high-level driver does
nothing then the device will not be eligible for runtime-suspend
because of the elevated usage count. If a high-level driver wants to
use runtime PM then it can call scsi_autopm_put_device() in its probe
routine to decrement the usage count and scsi_autopm_get_device() in
its remove routine to restore the original count.
Hosts, targets, and LUNs are not suspended while they are being probed
or removed, or while the error handler is running. In fact, a fairly
large part of the patch consists of code to make sure that things
aren't suspended at such times.
[jejb: fix up compile issues in PM config variations]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-06-17 18:41:42 +04:00
|
|
|
#ifdef CONFIG_PM_RUNTIME
|
|
|
|
extern void scsi_autopm_get_target(struct scsi_target *);
|
|
|
|
extern void scsi_autopm_put_target(struct scsi_target *);
|
|
|
|
extern int scsi_autopm_get_host(struct Scsi_Host *);
|
|
|
|
extern void scsi_autopm_put_host(struct Scsi_Host *);
|
|
|
|
#else
|
|
|
|
static inline void scsi_autopm_get_target(struct scsi_target *t) {}
|
|
|
|
static inline void scsi_autopm_put_target(struct scsi_target *t) {}
|
|
|
|
static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
|
|
|
|
static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
|
|
|
|
#endif /* CONFIG_PM_RUNTIME */
|
2010-06-17 18:36:49 +04:00
|
|
|
|
2012-07-10 06:33:25 +04:00
|
|
|
extern struct async_domain scsi_sd_probe_domain;
|
2012-03-23 04:05:11 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* internal scsi timeout functions: for use by mid-layer and transport
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
|
2006-05-17 00:13:36 +04:00
|
|
|
#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int scsi_internal_device_block(struct scsi_device *sdev);
|
2012-05-18 08:56:57 +04:00
|
|
|
extern int scsi_internal_device_unblock(struct scsi_device *sdev,
|
|
|
|
enum scsi_device_state new_state);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#endif /* _SCSI_PRIV_H */
|