History log of /drivers/scsi/scsi_sysfs.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2944369144548432f3a5ffce7a2926bfb4ce4f0a 12-Aug-2011 Vikas Chaudhary <vikas.chaudhary@qlogic.com> [SCSI] scsi: Added support for adapter and firmware reset

Added new sysfs attr 'host_reset' in scsi_sysfs.c to
perform adapter or firmware reset as suggested by
Mike Christie here:
http://marc.info/?l=linux-scsi&m=127359347111167&w=2

user/application can write "adapter" or "firmware" on
this attr and it will call newly added function hook
in scsi_host_template to call LDD adapter or firmware
reset implementation.

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
/drivers/scsi/scsi_sysfs.c
e73e079bf128d68284efedeba1fbbc18d78610f9 25-May-2011 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] Fix oops caused by queue refcounting failure

In certain circumstances, we can get an oops from a torn down device.
Most notably this is from CD roms trying to call scsi_ioctl. The root
cause of the problem is the fact that after scsi_remove_device() has
been called, the queue is fully torn down. This is actually wrong
since the queue can be used until the sdev release function is called.
Therefore, we add an extra reference to the queue which is released in
sdev->release, so the queue always exists.

Reported-by: Parag Warudkar <parag.lkml@gmail.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <jbottomley@parallels.com>
/drivers/scsi/scsi_sysfs.c
86cbfb5607d4b81b1a993ff689bbd2addd5d3a9b 22-Apr-2011 James Bottomley <James.Bottomley@suse.de> [SCSI] put stricter guards on queue dead checks

SCSI uses request_queue->queuedata == NULL as a signal that the queue
is dying. We set this state in the sdev release function. However,
this allows a small window where we release the last reference but
haven't quite got to this stage yet and so something will try to take
a reference in scsi_request_fn and oops. It's very rare, but we had a
report here, so we're pushing this as a bug fix

The actual fix is to set request_queue->queuedata to NULL in
scsi_remove_device() before we drop the reference. This causes
correct automatic rejects from scsi_request_fn as people who hold
additional references try to submit work and prevents anything from
getting a new reference to the sdev that way.

Cc: stable@kernel.org
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
aa33860158114d0df3c7997bc1dd41c0168e1c2a 11-Feb-2011 Rafael J. Wysocki <rjw@sisk.pl> PM: Remove CONFIG_PM_OPS

After redefining CONFIG_PM to depend on (CONFIG_PM_SLEEP ||
CONFIG_PM_RUNTIME) the CONFIG_PM_OPS option is redundant and can be
replaced with CONFIG_PM.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
/drivers/scsi/scsi_sysfs.c
008d23e4852d78bb2618f2035f8b2110b6a6b968 13-Jan-2011 Linus Torvalds <torvalds@linux-foundation.org> Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (43 commits)
Documentation/trace/events.txt: Remove obsolete sched_signal_send.
writeback: fix global_dirty_limits comment runtime -> real-time
ppc: fix comment typo singal -> signal
drivers: fix comment typo diable -> disable.
m68k: fix comment typo diable -> disable.
wireless: comment typo fix diable -> disable.
media: comment typo fix diable -> disable.
remove doc for obsolete dynamic-printk kernel-parameter
remove extraneous 'is' from Documentation/iostats.txt
Fix spelling milisec -> ms in snd_ps3 module parameter description
Fix spelling mistakes in comments
Revert conflicting V4L changes
i7core_edac: fix typos in comments
mm/rmap.c: fix comment
sound, ca0106: Fix assignment to 'channel'.
hrtimer: fix a typo in comment
init/Kconfig: fix typo
anon_inodes: fix wrong function name in comment
fix comment typos concerning "consistent"
poll: fix a typo in comment
...

Fix up trivial conflicts in:
- drivers/net/wireless/iwlwifi/iwl-core.c (moved to iwl-legacy.c)
- fs/ext4/ext4.h

Also fix missed 'diabled' typo in drivers/net/bnx2x/bnx2x.h while at it.
41511704b678f7b101a76e58d6c6b7bbe2a9ad70 15-Nov-2010 Alan Stern <stern@rowland.harvard.edu> [SCSI] eliminate an unnecessary local variable from scsi_remove_target()

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
4b7bd364700d9ac8372eff48832062b936d0793b 22-Dec-2010 Jiri Kosina <jkosina@suse.cz> Merge branch 'master' into for-next

Conflicts:
MAINTAINERS
arch/arm/mach-omap2/pm24xx.c
drivers/scsi/bfa/bfa_fcpim.c

Needed to update to apply fixes for which the old branch was too
outdated.
73d8c34f3d78ccf90a431c221df10377affce650 15-Nov-2010 Alan Stern <stern@rowland.harvard.edu> SCSI: improve two error messages

This trivial patch (as1338) makes two uninformative error messages in
scsi_sysfs_add_sdev() more explicit.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
/drivers/scsi/scsi_sysfs.c
546ae796bfac6399e30da4b5af2cf7a6d0f8a4ec 06-Oct-2010 Christof Schmitt <christof.schmitt@de.ibm.com> [SCSI] Fix race when removing SCSI devices

Removing SCSI devices through
echo 1 > /sys/bus/scsi/devices/ ... /delete

while the FC transport class removes the SCSI target can lead to an
oops:

Unable to handle kernel pointer dereference at virtual kernel address 00000000b6815000
Oops: 0011 [#1] PREEMPT SMP DEBUG_PAGEALLOC
Modules linked in: sunrpc qeth_l3 binfmt_misc dm_multipath scsi_dh dm_mod ipv6 qeth ccwgroup [last unloaded: scsi_wait_scan]
CPU: 1 Not tainted 2.6.35.5-45.x.20100924-s390xdefault #1
Process fc_wq_0 (pid: 861, task: 00000000b7331240, ksp: 00000000b735bac0)
Krnl PSW : 0704200180000000 00000000003ff6e4 (__scsi_remove_device+0x24/0xd0)
R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:2 PM:0 EA:3
Krnl GPRS: 0000000000000001 0000000000000000 00000000b6815000 00000000bc24a8c0
00000000003ff7c8 000000000056dbb8 0000000000000002 0000000000835d80
ffffffff00000000 0000000000001000 00000000b6815000 00000000bc24a7f0
00000000b68151a0 00000000b6815000 00000000b735bc20 00000000b735bbf8
Krnl Code: 00000000003ff6d6: a7840001 brc 8,3ff6d8
00000000003ff6da: a7fbffd8 aghi %r15,-40
00000000003ff6de: e3e0f0980024 stg %r14,152(%r15)
>00000000003ff6e4: e31021200004 lg %r1,288(%r2)
00000000003ff6ea: a71f0000 cghi %r1,0
00000000003ff6ee: a7a40011 brc 10,3ff710
00000000003ff6f2: a7390003 lghi %r3,3
00000000003ff6f6: c0e5ffffc8b1 brasl %r14,3f8858
Call Trace:
([<0000000000001000>] 0x1000)
[<00000000003ff7d2>] scsi_remove_device+0x42/0x54
[<00000000003ff8ba>] __scsi_remove_target+0xca/0xfc
[<00000000003ff99a>] __remove_child+0x3a/0x48
[<00000000003e3246>] device_for_each_child+0x72/0xbc
[<00000000003ff93a>] scsi_remove_target+0x4e/0x74
[<0000000000406586>] fc_rport_final_delete+0xb2/0x23c
[<000000000015d080>] worker_thread+0x200/0x344
[<000000000016330c>] kthread+0xa0/0xa8
[<0000000000106c1a>] kernel_thread_starter+0x6/0xc
[<0000000000106c14>] kernel_thread_starter+0x0/0xc
INFO: lockdep is turned off.
Last Breaking-Event-Address:
[<00000000003ff7cc>] scsi_remove_device+0x3c/0x54

The function __scsi_remove_target iterates through the SCSI devices on
the host, but it drops the host_lock before calling
scsi_remove_device. When the SCSI device is deleted from another
thread, the pointer to the SCSI device in scsi_remove_device can
become invalid. Fix this by getting a reference to the SCSI device
before dropping the host_lock to keep the SCSI device alive for the
call to scsi_remove_device.

Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
13f05c8d8e98bbdce89158bfdb2e380940695a88 10-Sep-2010 Martin K. Petersen <martin.petersen@oracle.com> block/scsi: Provide a limit on the number of integrity segments

Some controllers have a hardware limit on the number of protection
information scatter-gather list segments they can handle.

Introduce a max_integrity_segments limit in the block layer and provide
a new scsi_host_template setting that allows HBA drivers to provide a
value suitable for the hardware.

Add support for honoring the integrity segment limit when merging both
bios and requests.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@carl.home.kernel.dk>
/drivers/scsi/scsi_sysfs.c
e6da54d84f9286edbe4c92ff5023ff481ce2a5c9 05-Aug-2010 Alan Stern <stern@rowland.harvard.edu> SCSI: remove fake "address-of" expression

Fake "address-of" expressions that evaluate to NULL generally confuse
readers and can provoke compiler warnings. This patch (as1411) removes
one such fake expression, using an "#ifdef" in its place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/drivers/scsi/scsi_sysfs.c
bc4f24014de58f045f169742701a6598884d93db 17-Jun-2010 Alan Stern <stern@rowland.harvard.edu> [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>
/drivers/scsi/scsi_sysfs.c
db5bd1e0b505c54ff492172ce4abc245cf6cd639 17-Jun-2010 Alan Stern <stern@rowland.harvard.edu> [SCSI] convert to the new PM framework

This patch (as1397b) converts the SCSI midlayer to use the new PM
callbacks (struct dev_pm_ops). A new source file, scsi_pm.c, is
created to hold the new callback routines, and the existing
suspend/resume code is moved there.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
160e7f671344e40b86663a8913e175a3bb5d7f84 14-Apr-2010 Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com> [SCSI] fix sdev_rw_attr macro for scsi device sysfs entries

This patch fixes sdev_rw_attr() macro for scsi device sysfs entries.
It seems there is no such function snscanf in the current linux kernel,
so it fails to compile scsi driver when someone try to add a new rw entry.
This has been unfixed for a long time probably because current scsi device
has no rw entries.

# grep snscanf . -rn
./drivers/scsi/scsi_sysfs.c:489: snscanf (buf, 20, format_string, &sdev->field); \

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
1821438a9b6a8454281ec2e151014709f641d2d5 18-Mar-2010 Alan Stern <stern@rowland.harvard.edu> [SCSI] don't reap targets upon device_add failure

This patch (as1358) fixes a bug in the error pathway of
scsi_target_add(). If registration fails, the target should not be
reaped. The reaping occurs later, when scanning is finished and all
the child devices are removed. The current code leaves an unbalanced
value in starget->reap_ref.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
/drivers/scsi/scsi_sysfs.c
06a79b82b2a3e4bebb9a20638ca208c780e9e507 27-Feb-2010 Linus Torvalds <torvalds@linux-foundation.org> Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
PM / Hibernate: Fix preallocating of memory
PM / Hibernate: Remove swsusp.c finally
PM / Hibernate: Remove trailing space in message
PM: Allow SCSI devices to suspend/resume asynchronously
PM: Allow USB devices to suspend/resume asynchronously
USB: implement non-tree resume ordering constraints for PCI host controllers
PM: Allow PCI devices to suspend/resume asynchronously
PM / Hibernate: Swap, remove useless check from swsusp_read()
PM / Hibernate: Really deprecate deprecated user ioctls
PM: Allow device drivers to use dpm_wait()
PM: Start asynchronous resume threads upfront
PM: Add facility for advanced testing of async suspend/resume
PM: Add a switch for disabling/enabling asynchronous suspend/resume
PM: Asynchronous suspend and resume of devices
PM: Add parent information to timing messages
PM: Document device power attributes in sysfs
PM / Runtime: Add sysfs switch for disabling device run-time PM
4cb077d93a57fb8bb64c277ec4ce637823cd76f4 08-Feb-2010 Rafael J. Wysocki <rjw@sisk.pl> PM: Allow SCSI devices to suspend/resume asynchronously

Set power.async_suspend for all SCSI devices, targets and hosts, so
that they can be suspended and resumed in parallel with the main
suspend/resume thread and possibly with other devices they don't
depend on in a known way (i.e. devices which are not their parents or
children).

The power.async_suspend flag is also set for devices that don't have
suspend or resume callbacks, because otherwise they would make the
main suspend/resume thread wait for their "asynchronous" children
(during suspend) or parents (during resume), effectively negating the
possible gains from executing these devices' suspend and resume
callbacks asynchronously.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
/drivers/scsi/scsi_sysfs.c
ee37e09d81a4acf328f68189af12f116401f8c0f 12-Feb-2010 Alan Stern <stern@rowland.harvard.edu> [SCSI] fix duplicate removal on error path in scsi_sysfs_add_sdev

This patch (as1335) fixes a bug in scsi_sysfs_add_sdev(). Its callers
always remove the device if anything goes wrong, so it should never
remove the device.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
382f51fe2f2276344d8a21447656778cdf6583b6 10-Dec-2009 Linus Torvalds <torvalds@linux-foundation.org> Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (222 commits)
[SCSI] zfcp: Remove flag ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
[SCSI] zfcp: Activate fc4s attributes for zfcp in FC transport class
[SCSI] zfcp: Block scsi_eh thread for rport state BLOCKED
[SCSI] zfcp: Update FSF error reporting
[SCSI] zfcp: Improve ELS ADISC handling
[SCSI] zfcp: Simplify handling of ct and els requests
[SCSI] zfcp: Remove ZFCP_DID_MASK
[SCSI] zfcp: Move WKA port to zfcp FC code
[SCSI] zfcp: Use common code definitions for FC CT structs
[SCSI] zfcp: Use common code definitions for FC ELS structs
[SCSI] zfcp: Update FCP protocol related code
[SCSI] zfcp: Dont fail SCSI commands when transitioning to blocked fc_rport
[SCSI] zfcp: Assign scheduled work to driver queue
[SCSI] zfcp: Remove STATUS_COMMON_REMOVE flag as it is not required anymore
[SCSI] zfcp: Implement module unloading
[SCSI] zfcp: Merge trace code for fsf requests in one function
[SCSI] zfcp: Access ports and units with container_of in sysfs code
[SCSI] zfcp: Remove suspend callback
[SCSI] zfcp: Remove global config_mutex
[SCSI] zfcp: Replace local reference counting with common kref
...
4a84067dbfce436b81779e585bf712b02ceee552 23-Oct-2009 Vasu Dev <vasu.dev@intel.com> [SCSI] add queue_depth ramp up code

Current FC HBA queue_depth ramp up code depends on last queue
full time. The sdev already has last_queue_full_time field to
track last queue full time but stored value is truncated by
last four bits.

So this patch updates last_queue_full_time without truncating
last 4 bits to store full value and then updates its only
current usages in scsi_track_queue_full to ignore last four bits
to keep current usages same while also use this field
in added ramp up code.

Adds scsi_handle_queue_ramp_up to ramp up queue_depth on
successful completion of IO. The scsi_handle_queue_ramp_up will
do ramp up on all luns of a target, just same as ramp down done
on all luns on a target.

The ramp up is skipped in case the change_queue_depth is not
supported by LLD or already reached to added max_queue_depth.

Updates added max_queue_depth on every new update to default
queue_depth value.

The ramp up is also skipped if lapsed time since either last
queue ramp up or down is less than LLD specified
queue_ramp_up_period.

Adds queue_ramp_up_period to sysfs but only if change_queue_depth
is supported since ramp up and queue_ramp_up_period is needed only
in case change_queue_depth is supported first.

Initializes queue_ramp_up_period to 120HZ jiffies as initial
default value, it is same as used in existing lpfc and qla2xxx.

-v2
Combined all ramp code into this single patch.

-v3
Moves max_queue_depth initialization after slave_configure is
called from after slave_alloc calling done. Also adjusted
max_queue_depth check to skip ramp up if current queue_depth
is >= max_queue_depth.

-v4
Changes sdev->queue_ramp_up_period unit to ms when using sysfs i/f
to store or show its value.

Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Tested-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Tested-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
e881a172dac4d9ea3b2a1540041d872963c269bd 16-Oct-2009 Mike Christie <michaelc@cs.wisc.edu> [SCSI] modify change_queue_depth to take in reason why it is being called

This patch modifies scsi_host_template->change_queue_depth so that
it takes an argument indicating why it is being called. This will be
used so that if a LLD needs to do some extra processing when
handling queue fulls or later ramp ups, it can do so.

This is a simple port of the drivers setting a change_queue_depth
callback. In the patch I just have these LLDs adjust the queue depth
if the user was requesting it.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>

[Vasu.Dev: v2
Also converted pmcraid_change_queue_depth and then verified
all modules compile using "make allmodconfig" for any new build
warnings on X86_64.

Updated original description after combing two original
patches from Mike to make this patch git bisectable.]
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
[jejb: fixed up 53c700]
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
860dc73608a091e0b325218acc2701709d5f221a 19-Nov-2009 James Bottomley <James.Bottomley@suse.de> [SCSI] fix async scan add/remove race resulting in an oops

Async scanning introduced a very wide window where the SCSI device is
up and running but has not yet been added to sysfs. We delay the
adding until all scans have completed to retain the same ordering as
sync scanning.

This delay in visibility causes an oops if a device is removed before
we make it visible because the SCSI removal routines have an inbuilt
assumption that if a device is in SDEV_RUNNING state, it must be
visible (which is not necessarily true in the async scanning case).

Fix this by introducing an additional is_visible flag which we can use
to condition the tear down so we do the right thing for running but
not yet made visible.

Reported-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
37e6ba00720c2786330dec2a9a5081e9e049422f 02-Oct-2009 James Bottomley <James.Bottomley@suse.de> [SCSI] fix memory leak in initialization

The root cause of the problem is the fact that dev_set_name() now
allocates storage instead of using the original array within the kobj.
That means that the SCSI assumption that if you haven't made the
containing object or any sub objects visible, you can just destroy it
(and its component devices) lock stock and barrel becomes false.

Fix this by doing the get of sdev_dev at parent time and thus do an
extra put of it in scsi_destroy_sdev() (and all other destruction
without add paths).

Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
/drivers/scsi/scsi_sysfs.c
a4dbd6740df0872cdf0a86841f75beec8381964d 24-Jun-2009 David Brownell <dbrownell@users.sourceforge.net> driver model: constify attribute groups

Let attribute group vectors be declared "const". We'd
like to let most attribute metadata live in read-only
sections... this is a start.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/scsi/scsi_sysfs.c
b391277a56b9eaaff4474339c703e574ed7fab5b 18-Jun-2009 Hannes Reinecke <hare@suse.de> sd, sr: fix Driver 'sd' needs updating message

If a SCSI ULD driver sets blk_queue_prep_rq(), it should clean it
up itself on remove(), and not from the bus callbacks. This
removes the need to hook into bus->remove(), which should not
be used at the same time as driver->remove().

[jejb: fix sdkp initialisation problem due to mismerge]
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
59d3270326fcba29226c28df27cb43fefd8c58d0 10-Jan-2009 Randy Dunlap <randy.dunlap@oracle.com> [SCSI] scsi_sysfs: delete extra kernel-doc

Warning(linux-2.6.28-git13//drivers/scsi/scsi_sysfs.c:1049): Excess function parameter 'dev' description in 'scsi_sysfs_add_host'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
71610f55fa4db63dbf5385929a47c9fb2451f332 03-Dec-2008 Kay Sievers <kay.sievers@vrfy.org> [SCSI] struct device - replace bus_id with dev_name(), dev_set_name()

[jejb: limit ioctl to returning 20 characters to avoid overrun
on long device names and add a few more conversions]
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
ef5bef357cdf49f3a386c7102dbf3be5f7e5c913 10-Oct-2008 Linus Torvalds <torvalds@linux-foundation.org> Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (37 commits)
[SCSI] zfcp: fix double dbf id usage
[SCSI] zfcp: wait on SCSI work to be finished before proceeding with init dev
[SCSI] zfcp: fix erp list usage without using locks
[SCSI] zfcp: prevent fc_remote_port_delete calls for unregistered rport
[SCSI] zfcp: fix deadlock caused by shared work queue tasks
[SCSI] zfcp: put threshold data in hba trace
[SCSI] zfcp: Simplify zfcp data structures
[SCSI] zfcp: Simplify get_adapter_by_busid
[SCSI] zfcp: remove all typedefs and replace them with standards
[SCSI] zfcp: attach and release SAN nameserver port on demand
[SCSI] zfcp: remove unused references, declarations and flags
[SCSI] zfcp: Update message with input from review
[SCSI] zfcp: add queue_full sysfs attribute
[SCSI] scsi_dh: suppress comparison warning
[SCSI] scsi_dh: add Dell product information into rdac device handler
[SCSI] qla2xxx: remove the unused SCSI_QLOGIC_FC_FIRMWARE option
[SCSI] qla2xxx: fix printk format warnings
[SCSI] qla2xxx: Update version number to 8.02.01-k8.
[SCSI] qla2xxx: Ignore payload reserved-bits during RSCN processing.
[SCSI] qla2xxx: Additional residual-count corrections during UNDERRUN handling.
...
242f9dcb8ba6f68fcd217a119a7648a4f69290e9 14-Sep-2008 Jens Axboe <jens.axboe@oracle.com> block: unify request timeout handling

Right now SCSI and others do their own command timeout handling.
Move those bits to the block layer.

Instead of having a timer per command, we try to be a bit more clever
and simply have one per-queue. This avoids the overhead of having to
tear down and setup a timer for each command, so it will result in a lot
less timer fiddling.

Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/scsi/scsi_sysfs.c
6f4267e3bd1211b3d09130e626b0b3d885077610 22-Aug-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] Update the SCSI state model to allow blocking in the created state

Brian King <brking@linux.vnet.ibm.com> reported that fibre channel
devices can oops during scanning if their ports block (because the
device goes from CREATED -> BLOCK -> RUNNING rather than CREATED ->
BLOCK -> CREATED).

Fix this by adding a new state: CREATED_BLOCK which can only transition
back to CREATED and disallow the CREATED -> BLOCK transition. Now both
the created and blocked states that the mid-layer recognises can include
CREATED_BLOCK.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
4469f9878059f1707f021512e6b34252c4096ee7 17-Jul-2008 Martin K. Petersen <martin.petersen@oracle.com> [SCSI] Host protection capabilities

Controllers that support protection information must indicate this to
the SCSI midlayer so that the ULD can prepare scsi_cmnds accordingly.

This patch implements a host mask and various types of protection:

- DIF Type 1-3 (between HBA and disk)
- DIX Type 0-3 (between OS and HBA)

The patch also allows the HBA to set the guard type to something
different than the T10-mandated CRC.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
a6a8d9f87eb8510a8f53672ea87703f62185d75f 01-May-2008 Chandra Seetharaman <sekharan@us.ibm.com> [SCSI] scsi_dh: add infrastructure for SCSI Device Handlers

Some of the storage devices (that can be accessed through multiple paths),
do need some special handling for
1. Activating the passive path of the storage access.
2. Decode and handle the special sense codes returned by the devices.
3. Handle the I/Os being sent to the passive path, especially
during the device probe time.
when accessed through multiple paths.

As of today this special device handling is done at the dm-multipath
layer using dm-handlers. That works well for (1); for (2) to be handled
at dm layer, scsi sense information need to be exported from SCSI to dm-layer,
which is not very attractive; (3) cannot be done at all at the dm layer.

Device handler has been moved to SCSI mainly to handle (2) and (3) properly.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
1f42ea7bc0ddfadebd9e1c5362b41b53902dbcb1 22-May-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] fix intermittent oops in scsi_bus_uevent

Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
> BUG: unable to handle kernel paging request at e6f17fac
> IP: [<c02604d6>] scsi_bus_uevent+0x1/0x17
> *pde = 2714b163 *pte = 26f17160
> Oops: 0000 [#1] DEBUG_PAGEALLOC
> last sysfs file:
>
> Pid: 1, comm: swapper Not tainted (2.6.26-rc2-next-20080516skw #30)
> EIP: 0060:[<c02604d6>] EFLAGS: 00010282 CPU: 0
> EIP is at scsi_bus_uevent+0x1/0x17
> EAX: e6f18014 EBX: e6f18014 ECX: c02604d5 EDX: e7173000
> ESI: e7173000 EDI: e7173000 EBP: e7851ca0 ESP: e7851c90
> DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068

The problem is caused by:

commit b0ed43360fdca227048d88a08290365cb681c1a8
Author: Hannes Reinecke <hare@suse.de>
Date: Tue Mar 18 14:32:28 2008 +0100

[SCSI] add scsi_host and scsi_target to scsi_bus

which added scsi_bus_type to the struct scsi_target device. This
causes both the scsi_device and scsi_target to fire scsi_bus_uevents.
However, the actualy scsi_bus_uevent() call assumes blindly that it's
a struct scsi_device. Check for this and return immediately if it
isn't.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
97f46ae45c70857e459b7f8df1fc2807e7bd90a9 18-Apr-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> [SCSI] bsg: add release callback support

This patch adds release callback support, which is called when a bsg
device goes away. bsg_register_queue() takes a pointer to a callback
function. This feature is useful for stuff like sas_host that can't
use the release callback in struct device.

If a caller doesn't need bsg's release callback, it can call
bsg_register_queue() with NULL pointer (e.g. scsi devices can use
release callback in struct device so they don't need bsg's callback).

With this patch, bsg uses kref for refcounts on bsg devices instead of
get/put_device in fops->open/release. bsg calls put_device and the
caller's release callback (if it was registered) in kref_put's
release.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
643eb2d932c97a0583381629d632d486934cf7ee 23-Mar-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] rework scsi_target allocation

The current target allocation code registeres each possible target
with sysfs; it will be deleted again if no useable LUN on this target
was found. This results in a string of 'target add/target remove' uevents.

Based on a patch by Hannes Reinecke <hare@suse.de> this patch reworks
the target allocation code so that only uevents for existing targets
are sent. The sysfs registration is split off from the existing
scsi_target_alloc() into a in a new scsi_add_target() function, which
should be called whenever an existing target is found. Only then a
uevent is sent, so we'll be generating events for existing targets
only.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
f7120a4f75168df3c02efacd10403a4ba0bcb29d 18-Mar-2008 Hannes Reinecke <hare@suse.de> [SCSI] use default attributes for scsi_host

This patch removes the unused sysfs attibute overwriting logic for
the scsi host attibutes, and plugs them into the driver core default
attribute creation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
b0ed43360fdca227048d88a08290365cb681c1a8 18-Mar-2008 Hannes Reinecke <hare@suse.de> [SCSI] add scsi_host and scsi_target to scsi_bus

This patch implements scsi_host and scsi_target device types
and adds both to the scsi_bus.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
ee959b00c335d7780136c5abda37809191fe52c3 22-Feb-2008 Tony Jones <tonyj@suse.de> SCSI: convert struct class_device to struct device

It's big, but there doesn't seem to be a way to split it up smaller...

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/scsi/scsi_sysfs.c
0feed274d2dfa2162d2c37c254eede96926d3717 26-Mar-2008 James Bottomley <James.Bottomley@HansenPartnership.com> Revert "[SCSI] fix bsg queue oops with iscsi logout"

This reverts commit 4b6f5b3a993cbe34b4280f252bccc76967c185c8.

bsg takes a reference to the underlying generic device, so it's
impossible to unregister bsg in the device release routine.

Acked-by: FUJITA Tomonori <tomof@acm.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
4b6f5b3a993cbe34b4280f252bccc76967c185c8 11-Mar-2008 Mike Christie <michaelc@cs.wisc.edu> [SCSI] fix bsg queue oops with iscsi logout

Delay bsg unregistration, because we want to wait until all the request/cmds
have released their reference.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
d52b3815a52456dcf1a45fbc344e23bb643b2bda 05-Jan-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] add missing transport configure points for target and host

While trying to convert the SPI transport class to attribute groups, I
discovered that we don't actually have any transport configure points
for either the target or the host. This patch adds these missing
transport class triggers. The host one is simply done after the add,
the target one tries to be more clever and add it after devices may have
been placed on the target (so the device configure will have set up the
target parameters).

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
751bf4d7865e4ced406be93b04c7436d866d3684 02-Jan-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] scsi_sysfs: restore prep_fn when ULD is removed

A recent bug report:

http://bugzilla.kernel.org/show_bug.cgi?id=9674

Was caused because the ULDs now set their own prep functions, but
don't necessarily reset the prep function back to the SCSI default
when they are removed. This leads to panics if commands are sent to
the device after the module is removed because the prep_fn is still
pointing to the old module code. The fix for this is to implement a
bus remove method that resets the prep_fn pointer correctly before
calling the ULD specific driver remove method.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
/drivers/scsi/scsi_sysfs.c
a341cd0f6a0fde1f85fec9aa8f81f824ea4a3f92 29-Oct-2007 Jeff Garzik <jeff@garzik.org> SCSI: add asynchronous event notification API

Originally based on a patch by Kristen Carlson Accardi @ Intel.
Copious input from James Bottomley.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
/drivers/scsi/scsi_sysfs.c
7a39ac3f25bef018862a991d754aff681c019127 26-Sep-2007 James Bottomley <James.Bottomley@steeleye.com> [SCSI] make supported_mode default to initiator.

if shost->supported mode is zero (i.e. MODE_UNKNOWN) show it as
initiator (it's obviously an unconverted driver that won't do target).

Acked-by: FUJITA Tomonori <tomof@acm.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
df3d80f5a5c74168be42788364d13cf6c83c7b9c 15-Oct-2007 Linus Torvalds <torvalds@woody.linux-foundation.org> Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (207 commits)
[SCSI] gdth: fix CONFIG_ISA build failure
[SCSI] esp_scsi: remove __dev{init,exit}
[SCSI] gdth: !use_sg cleanup and use of scsi accessors
[SCSI] gdth: Move members from SCp to gdth_cmndinfo, stage 2
[SCSI] gdth: Setup proper per-command private data
[SCSI] gdth: Remove gdth_ctr_tab[]
[SCSI] gdth: switch to modern scsi host registration
[SCSI] gdth: gdth_interrupt() gdth_get_status() & gdth_wait() fixes
[SCSI] gdth: clean up host private data
[SCSI] gdth: Remove virt hosts
[SCSI] gdth: Reorder scsi_host_template intitializers
[SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
[SCSI] gdth: Remove 2.4.x support, in-kernel changelog
[SCSI] gdth: split out pci probing
[SCSI] gdth: split out eisa probing
[SCSI] gdth: split out isa probing
gdth: Make one abuse of scsi_cmnd less obvious
[SCSI] NCR5380: Use scsi_eh API for REQUEST_SENSE invocation
[SCSI] usb storage: use scsi_eh API in REQUEST_SENSE execution
[SCSI] scsi_error: Refactoring scsi_error to facilitate in synchronous REQUEST_SENSE
...
7eff2e7a8b65c25920207324e56611150eb1cd9a 14-Aug-2007 Kay Sievers <kay.sievers@vrfy.org> Driver core: change add_uevent_var to use a struct

This changes the uevent buffer functions to use a struct instead of a
long list of parameters. It does no longer require the caller to do the
proper buffer termination and size accounting, which is currently wrong
in some places. It fixes a known bug where parts of the uevent
environment are overwritten because of wrong index calculations.

Many thanks to Mathieu Desnoyers for finding bugs and improving the
error handling.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/scsi/scsi_sysfs.c
13ba9bcbfd6741e4c01ac5a505888b7b3a6d99da 26-Sep-2007 Kay Sievers <kay.sievers@vrfy.org> [SCSI] fix scsi_is_sdev_device() after switch to default sdev attributes

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
bfd129445f23c037d9a440ebfa4109e11c220301 11-Sep-2007 Kay Sievers <kay.sievers@vrfy.org> [SCSI] switch sdev sysfs attributes to default attributes

This removes the unused sysfs attribute overwriting logic for most of
the attributes, and plugs them into the driver core default attribute
creation.

Without this patch, at the time of the events for the SCSI LUN's, there
will be no sysfs files, because their creation is delayed until the sd
driver has spun up the disks, which might take several seconds. It is the
last WAIT_FOR_SYSFS rule in the default udev setup which can be removed
with this change.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
5dc2b89e124251662f580f4ba3c9f6195d1eaff6 31-Aug-2007 FUJITA Tomonori <tomof@acm.org> [SCSI] add supported_mode and active_mode attributes to the host

This adds supported_mode and active_mode attributes to
/sys/class/sys_host/hostX/ for specifying the mode that a lld supports
and the currently activated mode. The output format is similar to fc
rport roles:

luce:/sys/class/scsi_host/host0$ cat supported_mode
Initiator
luce:/sys/class/scsi_host/host0$ cat active_mode
Initiator

The mode values uses bitmap since we would support dual-mode llds in
the future like this:

luce:/sys/class/scsi_host/host0$ cat supported_mode
Initiator, Target

The supported_mode attribute looks at a scsi_host_template and the
active_mode attribute looks at a scsi_host. We would add a hook to a
scsi_host_template to change the active_mode attribute
dynamically. But now there is no hook since no lld supports that
feature.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
39dca558a5b52b63e49bc234a7e887be092aa690 21-Jul-2007 James Bottomley <James.Bottomley@steeleye.com> [SCSI] bsg: make class backlinks

Currently, bsg doesn't make class backlinks (a process whereby you'd get
a link to bsg in the device directory in the same way you get one for
sg). This is because the bsg device is uninitialised, so the class
device has nothing it can attach to. The fix is to make the bsg device
point to the cdevice of the entity creating the bsg, necessitating
changing the bsg_register_queue() prototype into a form that takes the
generic device.

Acked-by: FUJITA Tomonori <tomof@acm.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
80ed71ce1a3369521c693ebf30abb9cfe1dc7e66 19-Jul-2007 James Bottomley <James.Bottomley@steeleye.com> [SCSI] bsg: separate bsg and SCSI (so SCSI can be modular)

This patch moves the bsg registration into SCSI so that bsg no longer
has a dependency on the scsi_interface_register API.

This can be viewed as a temporary expedient until we can get universal
bsg binding sorted out properly. Also use the sdev bus_id as the
generic bsg name (to avoid clashes with the queue name).

Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
44818efbad185eea75adad0e8cab97650a7370ab 09-Jul-2007 Adrian Bunk <bunk@stusta.de> [SCSI] small cleanups

This patch contains the following cleanups:
- make needlessly global functions static
- every file should #include the headers containing the prototypes for
it's global functions

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
1dfcda06a67d6ad6f890dbd1bab84be5f17ef46d 21-Mar-2007 Tejun Heo <htejun@gmail.com> [SCSI] kill scsi host template suspend/resume

With libata converted to use sdev->manage_start_stop for suspend and
resume, sht->suspend/resume() has no user left and low level
suspend/ressume should be taken care of by low level driver's
suspend/resume callbacks (e.g. PCI or PCMCIA driver callbacks). This
patch removes sht->suspend/resume() callbacks.

This change is suggested by Christoph Hellwig.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
4f7a307dc6e4d8bfeb56f7cf7231b08cb845687c 05-May-2007 Linus Torvalds <torvalds@woody.linux-foundation.org> Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (87 commits)
[SCSI] fusion: fix domain validation loops
[SCSI] qla2xxx: fix regression on sparc64
[SCSI] modalias for scsi devices
[SCSI] sg: cap reserved_size values at max_sectors
[SCSI] BusLogic: stop using check_region
[SCSI] tgt: fix rdma transfer bugs
[SCSI] aacraid: fix aacraid not finding device
[SCSI] aacraid: Correct SMC products in aacraid.txt
[SCSI] scsi_error.c: Add EH Start Unit retry
[SCSI] aacraid: [Fastboot] Panics for AACRAID driver during 'insmod' for kexec test.
[SCSI] ipr: Driver version to 2.3.2
[SCSI] ipr: Faster sg list fetch
[SCSI] ipr: Return better qc_issue errors
[SCSI] ipr: Disrupt device error
[SCSI] ipr: Improve async error logging level control
[SCSI] ipr: PCI unblock config access fix
[SCSI] ipr: Fix for oops following SATA request sense
[SCSI] ipr: Log error for SAS dual path switch
[SCSI] ipr: Enable logging of debug error data for all devices
[SCSI] ipr: Add new PCI-E IDs to device table
...
d7b8bcb0a0819315a51cae620ff7ae0c1704c069 27-Oct-2006 Michael Tokarev <mjt@tls.msk.ru> [SCSI] modalias for scsi devices

The following patch adds support for sysfs/uevent modalias
attribute for scsi devices (like disks, tapes, cdroms etc),
based on whatever current sd.c, sr.c, st.c and osst.c drivers
supports.

The modalias format is like this:

scsi:type-0x04

(for TYPE_WORM, handled by sr.c now).

Several comments.

o This hexadecimal type value is because all TYPE_XXX constants
in include/scsi/scsi.h are given in hex, but __stringify() will
not convert them to decimal (so it will NOT be scsi:type-4).
Since it does not really matter in which format it is, while
both modalias in module and modalias attribute match each other,
I descided to go for that 0x%02x format (and added a comment in
include/scsi/scsi.h to keep them that way), instead of changing
them all to decimal.

o There was no .uevent routine for SCSI bus. It might be a good
idea to add some more ueven environment variables in there.

o osst.c driver handles tapes too, like st.c, but only SOME tapes.
With this setup, hotplug scripts (or whatever is used by the
user) will try to load both st and osst modules for all SCSI
tapes found, because both modules have scsi:type-0x01 alias).
It is not harmful, but one extra module is no good either.
It is possible to solve this, by exporting more info in
modalias attribute, including vendor and device identification
strings, so that modalias becomes something like
scsi:type-0x12:vendor-Adaptec LTD:device-OnStream Tape Drive
and having that, match for all 3 attributes, not only device
type. But oh well, vendor and device strings may be large,
and they do contain spaces and whatnot.
So I left them for now, awaiting for comments first.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
c3c94c5a2fb43a654e777f509d5032b0db8ed09f 20-Mar-2007 Tejun Heo <htejun@gmail.com> [SCSI] sd: implement START/STOP management

Implement SBC START/STOP management. sdev->mange_start_stop is added.
When it's set to one, sd STOPs the device on suspend and shutdown and
STARTs it on resume. sdev->manage_start_stop defaults is in sdev
instead of scsi_disk cdev to allow ->slave_config() override the
default configuration but is exported under scsi_disk sysfs node as
sdev->allow_restart is.

When manage_start_stop is zero (the default value), this patch doesn't
introduce any behavior change.

Signed-off-by: Tejun Heo <htejun@gmail.com>

Rejections fixed and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
d9a9cdfb078d755e648d53ec25b7370f84ee5729 15-Mar-2007 Alan Stern <stern@rowland.harvard.edu> [PATCH] sysfs and driver core: add callback helper, used by SCSI and S390

This patch (as868) adds a helper routine for device drivers that need
to set up a callback to perform some action in a different process's
context. This is intended for use by attribute methods that want to
unregister themselves or their parent device. Attribute method calls
are mutually exclusive with unregistration, so such actions cannot be
taken directly.

Two attribute methods are converted to use the new helper routine: one
for SCSI device deletion and one for System/390 ccwgroup devices.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/drivers/scsi/scsi_sysfs.c
7c9d6f16f50d3aeb780e4f103a1ba8b35d9ae803 08-Jan-2007 Alan Stern <stern@rowland.harvard.edu> [SCSI] SCSI core: better initialization for sdev->scsi_level

This patch will affect the CDB in INQUIRY commands sent to LUNs above 0
when LUN-0 reports a scsi_level of 0; the LUN bits will no longer be set
in the second byte of the CDB. This is as it should be. Nevertheless,
it's possible that some wacky device might be adversely affected. I doubt
anyone will complain...

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
65f27f38446e1976cc98fd3004b110fedcddd189 22-Nov-2006 David Howells <dhowells@redhat.com> WorkStruct: Pass the work_struct pointer instead of context data

Pass the work_struct pointer to the work function rather than context data.
The work function can use container_of() to work out the data.

For the cases where the container of the work_struct may go away the moment the
pending bit is cleared, it is made possible to defer the release of the
structure by deferring the clearing of the pending bit.

To make this work, an extra flag is introduced into the management side of the
work_struct. This governs auto-release of the structure upon execution.

Ordinarily, the work queue executor would release the work_struct for further
scheduling or deallocation by clearing the pending bit prior to jumping to the
work function. This means that, unless the driver makes some guarantee itself
that the work_struct won't go away, the work function may not access anything
else in the work_struct or its container lest they be deallocated.. This is a
problem if the auxiliary data is taken away (as done by the last patch).

However, if the pending bit is *not* cleared before jumping to the work
function, then the work function *may* access the work_struct and its container
with no problems. But then the work function must itself release the
work_struct by calling work_release().

In most cases, automatic release is fine, so this is the default. Special
initiators exist for the non-auto-release case (ending in _NAR).


Signed-Off-By: David Howells <dhowells@redhat.com>
/drivers/scsi/scsi_sysfs.c
ed632da84c51a39fd9c982991e0f26120a035761 16-Oct-2006 James Bottomley <James.Bottomley@steeleye.com> [SCSI] add can_queue to host parameters

Debugging TCQ issues has shown me this is a very useful parameter to be
able to view. Add it to he host class parameters.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
6ab3d5624e172c553004ecc862bfeac16d9d68b7 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de> Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
/drivers/scsi/scsi_sysfs.c
6391a11375de5e2bb1eb8481e54619761dc65d9f 09-Jun-2006 Tobias Klauser <tklauser@nuerscht.ch> [SCSI] drivers/scsi: Use ARRAY_SIZE macro

Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of the macro.

Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
082776e4be791736c32baf818e50f501a7f83819 23-Mar-2006 Nigel Cunningham <ncunningham@cyclades.com> [PATCH] Make libata not powerdown drivers on PM_EVENT_FREEZE.

At the moment libata doesn't pass pm_message_t down ata_device_suspend.
This causes drives to be powered down when we just want a freeze,
causing unnecessary wear and tear. This patch gets pm_message_t passed
down so that it can be used to determine whether to power down the
drive.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

drivers/scsi/libata-core.c | 5 +++--
drivers/scsi/libata-scsi.c | 4 ++--
drivers/scsi/scsi_sysfs.c | 2 +-
include/linux/libata.h | 4 ++--
include/scsi/scsi_host.h | 2 +-
5 files changed, 9 insertions(+), 8 deletions(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/scsi/scsi_sysfs.c
ffedb4522571ac170f941678d138a31bc0884ab4 23-Feb-2006 James Bottomley <James.Bottomley@steeleye.com> [SCSI] fix scsi process problems and clean up the target reap issues

In order to use the new execute_in_process_context() API, you have to
provide it with the work storage, which I do in SCSI in scsi_device and
scsi_target, but which also means that we can no longer queue up the
target reaps, so instead I moved the target to a state model which
allows target_alloc to detect if we've received a dying target and wait
for it to be gone. Hopefully, this should also solve the target
namespace race.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
65110b2168950a19cc78b5027ed18cb811fbdae8 14-Feb-2006 James Bottomley <James.Bottomley@steeleye.com> [SCSI] fix wrong context bugs in SCSI

There's a bug in releasing scsi_device where the release function
actually frees the block queue. However, the block queue release
calls flush_work(), which requires process context (the scsi_device
structure may release from irq context). Update the release function
to invoke via the execute_in_process_context() API.

Also clean up the scsi_target structure releasing via this API.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
e02f3f59225d8c3b2a0ad0dc941a09865e27da61 13-Jan-2006 Christoph Hellwig <hch@lst.de> [SCSI] remove target parent limitiation

When James Smart fixed the issue of the userspace scan atributes
crashing the system with the FC transport class he added a patch to
let the transport class check if the parent is valid for a given
transport class.

When adding support for the integrated raid of fusion sas devices
we ran into a problem with that, as it didn't allow adding virtual
raid volumes without the transport class knowing about it.

So this patch adds a user_scan attribute instead, that takes over from
scsi_scan_host_selected if the transport class sets it and thus lets
the transport class control the user-initiated scanning. As this
plugs the hole about user-initiated scanning the target_parent hook
goes away and we rely on callers of the scanning routines to do
something sensible.

For SAS this meant I had to switch from a spinlock to a mutex to
synchronize the topology linked lists, in FC they were completely
unsynchronized which seems wrong.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
0b9506723826c68b50fa33e345700ddcac1bed36 11-Jan-2006 Arjan van de Ven <arjan@infradead.org> [SCSI] turn most scsi semaphores into mutexes

the scsi layer is using semaphores in a mutex way, this patch converts
these into using mutexes instead

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
9b847548663ef1039dd49f0eb4463d001e596bc3 06-Jan-2006 Jens Axboe <axboe@suse.de> [PATCH] Suspend support for libata

This patch adds suspend patch to libata, and ata_piix in particular. For
most low level drivers, they should just need to add the 4 hooks to
work. As I can only test ata_piix, I didn't enable it for more
though.

Suspend support is the single most important feature on a notebook, and
most new notebooks have sata drives. It's quite embarrassing that we
_still_ do not support this. Right now, it's perfectly possible to
suspend the drive in mid-transfer.

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/scsi/scsi_sysfs.c
0ad78200baf1f85a21e6b26c225717ad80980d8f 28-Nov-2005 Arjan van de Ven <arjan@infradead.org> [SCSI] Mark some core scsi data structures const

patch below marks a few scsi core datastructures as const, so that they end up
in the .rodata section and don't cacheline share with things that get dirtied

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
df133c212ef82b9c7e80fca7b1f87dad8a05de3c 06-Nov-2005 James Bottomley <James.Bottomley@steeleye.com> [SCSI] Fix transport class oops

There's an oops that sometimes shows up with SCSI transport classes in
sysfs_hash_and_remove. The problem is that now, because of the class to
device and vice versa symlinks, all classes have to be removed from
visibility *before* the device is removed from visibility.

The transport class trigger points violate this, so bring them back into
conformance.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
939647ee308e0ad924e776657704c7bedd498664 18-Sep-2005 James Bottomley <James.Bottomley@steeleye.com> [SCSI] fix oops on usb storage device disconnect

We fix the oops by enforcing the host state model. There have also
been two extra states added: SHOST_CANCEL_RECOVERY and
SHOST_DEL_RECOVERY so we can take the model through host removal while
the recovery thread is active.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
a64358db1253b35d508a411e80a3ad23b859ec88 26-Jul-2005 Alan Stern <stern@rowland.harvard.edu> [SCSI] SCSI scanning and removal fixes

This patch (as545) fixes the list traversals in __scsi_remove_target and
scsi_forget_host. In each case the existing code list_for_each_entry_safe
in an _unsafe_ manner, because the list was not protected from outside
modification while the iteration was running.

The new scsi_forget_host routine takes the moderately controversial step
of iterating over devices for removal rather than iterating over targets.
This makes more sense to me because the current scheme treats targets as
second-class citizens, created and removed on demand, rather than as
objects corresponding to actual hardware. (Also I couldn't figure out any
safe way to iterate over the target list, since it's not so easy to tell
when a target has already been removed.)

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
541950027f8b7c96a639bc16e48930c590f1b98a 16-Sep-2005 Alan Stern <stern@rowland.harvard.edu> [SCSI] fix use after potential free in scsi_remove_device

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
903f4fed858a7b56b260cbd55d174fe54d188fb7 26-Jul-2005 Alan Stern <stern@rowland.harvard.edu> [SCSI] fix callers of scsi_remove_device() who already hold the scan muted

This patch (as544) adds a private entry point to scsi_remove_device, for
use when callers already own the scan_mutex. The appropriate callers are
modified to use the new entry point.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
d3301874083874f8a0ac88aa1bb7da6b62df34d2 16-Jun-2005 Mike Anderson <andmike@us.ibm.com> [SCSI] host state model update: replace old host bitmap state

Migrate the current SCSI host state model to a model like SCSI
device is using.

Signed-off-by: Mike Anderson <andmike@us.ibm.com>

Rejections fixed up and

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
52c1da39534fb382c061de58b65f678ad74b59f5 24-Jun-2005 Adrian Bunk <bunk@stusta.de> [PATCH] make various thing static

Another rollup of patches which give various symbols static scope

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/scsi/scsi_sysfs.c
10523b3b82456e416cbaffcc24ea2246980aa746 17-May-2005 Yani Ioannou <yani.ioannou@gmail.com> [PATCH] Driver Core: drivers/s390/net/qeth_sys.c - drivers/usb/gadget/pxa2xx_udc.c: update device attribute callbacks

Signed-off-by: Yani Ioannou <yani.ioannou@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/scsi/scsi_sysfs.c
20b1e674230b642be662c5975923a0160ab9cbdc 25-Mar-2005 mochel@digitalimplant.org <mochel@digitalimplant.org> [PATCH] Use device_for_each_child() to unregister devices in scsi_remove_target().

Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/scsi/scsi_sysfs.c
===================================================================
/drivers/scsi/scsi_sysfs.c
c2a9331c62216e222a08de8dd58559367fef0af6 12-Apr-2005 <jejb@titanic.il.steeleye.com> updates for CFQ oops fix

- add a comment to the device structure that the device_busy field
is now protected by the request_queue->queue_lock
- null out sdev->request_queue after the queue is released to trap
any (and there shouldn't be any) use after the queue is freed.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
/drivers/scsi/scsi_sysfs.c
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
/drivers/scsi/scsi_sysfs.c