Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread Hannes Reinecke
On 04/06/2013 11:08 AM, James Bottomley wrote: On Fri, 2013-03-15 at 10:46 +0100, Hannes Reinecke wrote: SAM advertises the use of a Well-known LUN (W_LUN) for scanning. As this avoids exposing LUN 0 (which might be a valid LUN) for all initiators it is the preferred method for LUN scanning on

Re: [OT] LDD3 Query

2013-04-07 Thread Vijay Chauhan
Hi, On Sat, Apr 6, 2013 at 5:23 AM, Greg KH gre...@linuxfoundation.org wrote: On Fri, Apr 05, 2013 at 12:17:54PM +0530, Vijay Chauhan wrote: Hi, I am new to Linux Device Driver and reading LDD3. It mentions that the disadvantage of dynamic major number allocation is that you can’t

Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread James Bottomley
On Sun, 2013-04-07 at 15:31 +0200, Hannes Reinecke wrote: On 04/06/2013 11:08 AM, James Bottomley wrote: On Fri, 2013-03-15 at 10:46 +0100, Hannes Reinecke wrote: SAM advertises the use of a Well-known LUN (W_LUN) for scanning. As this avoids exposing LUN 0 (which might be a valid LUN) for

[PATCH v10 0/9] More device removal fixes

2013-04-07 Thread Bart Van Assche
Fix a few issues that can be triggered by removing a device: - Fix a race between starved list processing and device removal. - Avoid that a SCSI LLD callback can get invoked after scsi_remove_host() finished. - Speed up device removal by stopping error handling as soon as the SHOST_DEL or

[PATCH v10 1/9] Fix race between starved list processing and device removal

2013-04-07 Thread Bart Van Assche
scsi_run_queue() examines all SCSI devices that are present on the starved list. Since scsi_run_queue() unlocks the SCSI host lock before running a queue a SCSI device can get removed after it has been removed from the starved list and before its queue is run. Protect against that race condition

[PATCH v10 2/9] Remove get_device() / put_device() pair from scsi_request_fn()

2013-04-07 Thread Bart Van Assche
Now that all scsi_request_fn() callers hold a reference on the SCSI device that function is invoked for and since blk_cleanup_queue() waits until scsi_request_fn() has finished it is safe to remove the get_device() / put_device() pair from scsi_request_fn(). Signed-off-by: Bart Van Assche

[PATCH v10 3/9] Avoid calling __scsi_remove_device() twice

2013-04-07 Thread Bart Van Assche
SCSI devices are added to the shost-__devices list from inside scsi_alloc_sdev(). If something goes wrong during LUN scanning, e.g. a transport layer failure occurs, then __scsi_remove_device() can get invoked by the LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK or SDEV_BLOCKED.

[PATCH v10 4/9] Disallow changing the device state via sysfs into deleted

2013-04-07 Thread Bart Van Assche
Changing the state of a SCSI device via sysfs into cancel or deleted prevents removal of these devices by scsi_remove_host(). Hence do not allow this. Also, introduce the symbolic name INVALID_SDEV_STATE, representing a value different from any valid SCSI device state. Update

[PATCH v10 5/9] Avoid saving/restoring interrupt state inside scsi_remove_host()

2013-04-07 Thread Bart Van Assche
Since it is not allowed to invoke scsi_remove_host() with interrupts disabled, avoid saving and restoring the interrupt state inside scsi_remove_host(). This patch does not change the functionality of the function scsi_remove_host(). Signed-off-by: Bart Van Assche bvanass...@acm.org Acked-by:

[PATCH v10 6/9] Make scsi_remove_host() wait until error handling finished

2013-04-07 Thread Bart Van Assche
A SCSI LLD may start cleaning up host resources as soon as scsi_remove_host() returns. These host resources may be needed by the LLD in an implementation of one of the eh_* functions. So if one of the eh_* functions is in progress when scsi_remove_host() is invoked, wait until the eh_* function

[PATCH v10 7/9] Avoid that scsi_device_set_state() triggers a race

2013-04-07 Thread Bart Van Assche
Make concurrent invocations of scsi_device_set_state() safe. Signed-off-by: Bart Van Assche bvanass...@acm.org Acked-by: Hannes Reinecke h...@suse.de Cc: James Bottomley jbottom...@parallels.com Cc: Tejun Heo t...@kernel.org Cc: Mike Christie micha...@cs.wisc.edu --- drivers/scsi/scsi_error.c |

[PATCH v10 8/9] Save and restore host_scribble during error handling

2013-04-07 Thread Bart Van Assche
A SCSI LLD may overwrite host_scribble in its queuecommand() implementation. Several drivers need that field to process requests and aborts correctly. Hence this field must be saved by scsi_eh_prep_cmnd() and must be restored by scsi_eh_restore_cmnd(). Signed-off-by: Bart Van Assche

[PATCH v10 9/9] Avoid reenabling I/O after the transport became offline

2013-04-07 Thread Bart Van Assche
Disallow the SDEV_TRANSPORT_OFFLINE to SDEV_CANCEL transition such that no I/O is sent to devices for which the transport is offline. Notes: - Functions like sd_shutdown() use scsi_execute_req() and hence set the REQ_PREEMPT flag. Such requests are passed to the LLD queuecommand callback in

Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread Douglas Gilbert
On 13-04-07 10:49 AM, James Bottomley wrote: On Sun, 2013-04-07 at 15:31 +0200, Hannes Reinecke wrote: On 04/06/2013 11:08 AM, James Bottomley wrote: On Fri, 2013-03-15 at 10:46 +0100, Hannes Reinecke wrote: SAM advertises the use of a Well-known LUN (W_LUN) for scanning. As this avoids

Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread James Bottomley
On Sun, 2013-04-07 at 11:59 -0400, Douglas Gilbert wrote: On 13-04-07 10:49 AM, James Bottomley wrote: On Sun, 2013-04-07 at 15:31 +0200, Hannes Reinecke wrote: On 04/06/2013 11:08 AM, James Bottomley wrote: On Fri, 2013-03-15 at 10:46 +0100, Hannes Reinecke wrote: SAM advertises the use

Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread Douglas Gilbert
On 13-04-07 12:15 PM, James Bottomley wrote: On Sun, 2013-04-07 at 11:59 -0400, Douglas Gilbert wrote: On 13-04-07 10:49 AM, James Bottomley wrote: On Sun, 2013-04-07 at 15:31 +0200, Hannes Reinecke wrote: On 04/06/2013 11:08 AM, James Bottomley wrote: On Fri, 2013-03-15 at 10:46 +0100,

Re: [PATCH][RFC] scsi: Use W_LUN for scanning

2013-04-07 Thread James Bottomley
On Sun, 2013-04-07 at 12:34 -0400, Douglas Gilbert wrote: On 13-04-07 12:15 PM, James Bottomley wrote: No specs apply that I can see. SPC-3 Section 8.3 Access Controls spc4r36f.pdf section 8.3.1.2 [Overview] Access controls are handled in the SCSI target device by an access controls