30 Sep, 2014

1 commit


16 Sep, 2014

2 commits

  • The SCSI specification requires that the second Command Data Byte
    should contain the LUN value in its high-order bits if the recipient
    device reports SCSI level 2 or below. Nevertheless, some USB
    mass-storage devices use those bits for other purposes in
    vendor-specific commands. Currently Linux has no way to send such
    commands, because the SCSI stack always overwrites the LUN bits.

    Testing shows that Windows 7 and XP do not store the LUN bits in the
    CDB when sending commands to a USB device. This doesn't matter if the
    device uses the Bulk-Only or UAS transports (which virtually all
    modern USB mass-storage devices do), as these have a separate
    mechanism for sending the LUN value.

    Therefore this patch introduces a flag in the Scsi_Host structure to
    inform the SCSI midlayer that a transport does not require the LUN
    bits to be stored in the CDB, and it makes usb-storage set this flag
    for all devices using the Bulk-Only transport. (UAS is handled by a
    separate driver, but it doesn't really matter because no SCSI-2 or
    lower device is at all likely to use UAS.)

    The patch also cleans up the code responsible for storing the LUN
    value by adding a bitflag to the scsi_device structure. The test for
    whether to stick the LUN value in the CDB can be made when the device
    is probed, and stored for future use rather than being made over and
    over in the fast path.

    Signed-off-by: Alan Stern
    Reported-by: Tiziano Bacocco
    Acked-by: Martin K. Petersen
    Acked-by: James Bottomley
    Signed-off-by: Christoph Hellwig

    Alan Stern
     
  • Add a use_cmd_list flag in struct Scsi_Host to request keeping track of
    all outstanding commands per device.

    Default behaviour is not to keep track of cmd_list per sdev, as this may
    introduce lock contention. (overhead is more on multi-node NUMA.), and
    only enable it on the two drivers that need it.

    Signed-off-by: Kashyap Desai
    Reviewed-by: Martin K. Petersen
    Reviewed-by: Bart Van Assche
    Signed-off-by: Christoph Hellwig

    Kashyap.Desai@avagotech.com
     

26 Jul, 2014

2 commits

  • This patch adds support for an alternate I/O path in the scsi midlayer
    which uses the blk-mq infrastructure instead of the legacy request code.

    Use of blk-mq is fully transparent to drivers, although for now a host
    template field is provided to opt out of blk-mq usage in case any unforseen
    incompatibilities arise.

    In general replacing the legacy request code with blk-mq is a simple and
    mostly mechanical transformation. The biggest exception is the new code
    that deals with the fact the I/O submissions in blk-mq must happen from
    process context, which slightly complicates the I/O completion handler.
    The second biggest differences is that blk-mq is build around the concept
    of preallocated requests that also include driver specific data, which
    in SCSI context means the scsi_cmnd structure. This completely avoids
    dynamic memory allocations for the fast path through I/O submission.

    Due the preallocated requests the MQ code path exclusively uses the
    host-wide shared tag allocator instead of a per-LUN one. This only
    affects drivers actually using the block layer provided tag allocator
    instead of their own. Unlike the old path blk-mq always provides a tag,
    although drivers don't have to use it.

    For now the blk-mq path is disable by defauly and must be enabled using
    the "use_blk_mq" module parameter. Once the remaining work in the block
    layer to make blk-mq more suitable for slow devices is complete I hope
    to make it the default and eventually even remove the old code path.

    Based on the earlier scsi-mq prototype by Nicholas Bellinger.

    Thanks to Bart Van Assche and Robert Elliot for testing, benchmarking and
    various sugestions and code contributions.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Martin K. Petersen
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Webb Scales
    Acked-by: Jens Axboe
    Tested-by: Bart Van Assche
    Tested-by: Robert Elliott

    Christoph Hellwig
     
  • Seems like these counters are missing any sort of synchronization for
    updates, as a over 10 year old comment from me noted. Fix this by
    using atomic counters, and while we're at it also make sure they are
    in the same cacheline as the _busy counters and not needlessly stored
    to in every I/O completion.

    With the new model the _busy counters can temporarily go negative,
    so all the readers are updated to check for > 0 values. Longer
    term every successful I/O completion will reset the counters to zero,
    so the temporarily negative values will not cause any harm.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Martin K. Petersen
    Reviewed-by: Webb Scales
    Acked-by: Jens Axboe
    Tested-by: Bart Van Assche
    Tested-by: Robert Elliott

    Christoph Hellwig
     

25 Jul, 2014

1 commit

  • Avoid taking the host-wide host_lock to check the per-host queue limit.
    Instead we do an atomic_inc_return early on to grab our slot in the queue,
    and if necessary decrement it after finishing all checks.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Martin K. Petersen
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Webb Scales
    Acked-by: Jens Axboe
    Tested-by: Bart Van Assche
    Tested-by: Robert Elliott

    Christoph Hellwig
     

18 Jul, 2014

4 commits

  • Signed-off-by: Christoph Hellwig
    Reviewed-by: Paolo Bonzini
    Reviewed-by: Hannes Reinecke

    Christoph Hellwig
     
  • Now that the ibmvstgt driver as the only user of scsi_tgt is gone, the
    scsi_tgt kernel module, the CONFIG_SCSI_TGT, CONFIG_SCSI_SRP_TGT_ATTRS and
    CONFIG_SCSI_FC_TGT_ATTRS kbuild variable, the scsi_host_template
    transfer_response method are no longer needed.

    [hch: minor updates to the current tree, changelog update]

    Signed-off-by: Bart Van Assche
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Paolo Bonzini
    Reviewed-by: Hannes Reinecke

    Bart Van Assche
     
  • Now that we're using 64-bit LUNs internally we need to increase
    the size of max_luns to 64 bits, too.

    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Ewan Milne
    Signed-off-by: Christoph Hellwig

    Hannes Reinecke
     
  • max_sectors in struct Scsi_Host specifies maximum number of sectors
    allowed in a single SCSI command. The data type of max_sectors is
    unsigned short, so the maximum transfer length per SCSI command is
    limited to less than 256MB in 4096-bytes sector size. (0xffff * 4096)

    This commit increases the SCSI mid level's limitation for max_sectors
    upto the block layer's limitation for max_hw_sectors by extending the
    data type of max_sectors in struct Scsi_Host and scsi_host_template,
    so that SCSI lower level drivers can specify more than 0xffff.

    Signed-off-by: Akinobu Mita
    Reviewed-by: Martin K. Petersen
    Signed-off-by: Christoph Hellwig

    Akinobu Mita
     

27 Mar, 2014

1 commit

  • This allows drivers to specify the size of their per-command private
    data in the host template and then get extra memory allocated for
    each command instead of needing another allocation in ->queuecommand.

    With the current SCSI code that already does multiple allocations for
    each command this probably doesn't make a big performance impact, but
    it allows to clean up the drivers, and prepare them for using the
    blk-mq infrastructure where the common allocation will make a difference.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Paolo Bonzini
    Signed-off-by: James Bottomley

    Christoph Hellwig
     

19 Dec, 2013

1 commit

  • When a command runs into a timeout we need to send an 'ABORT TASK'
    TMF. This is typically done by the 'eh_abort_handler' LLDD callback.

    Conceptually, however, this function is a normal SCSI command, so
    there is no need to enter the error handler.

    This patch implements a new scsi_abort_command() function which
    invokes an asynchronous function scsi_eh_abort_handler() to
    abort the commands via the usual 'eh_abort_handler'.

    If abort succeeds the command is either retried or terminated,
    depending on the number of allowed retries. However, 'eh_eflags'
    records the abort, so if the retry would fail again the
    command is pushed onto the error handler without trying to
    abort it (again); it'll be cleared up from SCSI EH.

    [hare: smatch detected stray switch fixed]
    Signed-off-by: Hannes Reinecke
    Signed-off-by: James Bottomley

    Hannes Reinecke
     

29 Nov, 2013

1 commit

  • Some host adapters do not pass commands through to the target disk
    directly. Instead they provide an emulated target which may or may not
    accurately report its capabilities. In some cases the physical device
    characteristics are reported even when the host adapter is processing
    commands on the device's behalf. This can lead to adapter firmware hangs
    or excessive I/O errors.

    This patch disables WRITE SAME for devices connected to host adapters
    that provide an emulated target. Driver writers can disable WRITE SAME
    by setting the no_write_same flag in the host adapter template.

    [jejb: fix up rejections due to eh_deadline patch]
    Signed-off-by: Martin K. Petersen
    Cc: stable@kernel.org
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

25 Oct, 2013

2 commits

  • This patchs adds an 'eh_deadline' sysfs attribute to the scsi
    host which limits the overall runtime of the SCSI EH.
    The 'eh_deadline' value is stored in the now obsolete field
    'resetting'.
    When a command is failed the start time of the EH is stored
    in 'last_reset'. If the overall runtime of the SCSI EH is longer
    than last_reset + eh_deadline, the EH is short-circuited and
    falls through to issue a host reset only.

    [jejb: add comments in Scsi_Host about new fields]
    Signed-off-by: Hannes Reinecke
    Signed-off-by: James Bottomley

    Hannes Reinecke
     
  • Field is now unused, so this is dead code.

    [jejb: remove resetting and last_reset from Scsi_Host]
    Signed-off-by: Hannes Reinecke
    Signed-off-by: James Bottomley

    Hannes Reinecke
     

10 Apr, 2013

2 commits

  • all users converted to ->show_info()/->write_info()

    Signed-off-by: Al Viro

    Al Viro
     
  • It's still an obsolete interface; don't introduce those in new drivers.
    However, it's saner than the ->proc_info() and commits after this one
    will convert the existing ->proc_info() users to it.

    The read side is ->show_info(seq_file *, struct Scsi_Host *); use
    seq_... for generating contents.

    The write side is ->write_info(struct Scsi_Host *, char *, int).

    Again, this is driven by procfs needs; we are going to kill ->write_proc()
    and ->read_proc() and this is the main obstacle to burying that piece of
    shit.

    Signed-off-by: Al Viro

    Al Viro
     

24 Feb, 2013

1 commit


24 Sep, 2012

1 commit

  • We set the capacity to zero when we discovered a device formatted with
    an unknown DIF protection type. However, the read_capacity code would
    override the capacity and cause the device to be enabled regardless.

    Make sd_read_protection_type() return an error if the protection type is
    unknown. Also prevent duplicate printk lines when the device is being
    revalidated.

    Reported-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

09 Jan, 2012

1 commit

  • With previous change, now the ata port runtime suspend will happen as:

    disk suspend --> scsi target suspend --> scsi host suspend --> ata port
    suspend

    ata port(parent device) suspend need to schedule scsi EH which will resume
    scsi host(child device). Then the child device resume will in turn make
    parent device resume first. This is kind of recursive.

    This patch adds a new flag Scsi_Host::eh_noresume.
    ata port will set this flag to skip the runtime PM calls on scsi host.

    Acked-by: Alan Stern
    Signed-off-by: Lin Ming
    Signed-off-by: Jeff Garzik

    Lin Ming
     

29 Aug, 2011

1 commit

  • The problem is that if we are doing a scsi scan then the device goes
    into recovery then we will wait for the recovery to complete. It waits
    because scsi-ml will send inquiries or report luns and the queueing code
    will have been blocked due to the host not being ready. However, if we
    are in recovery and then a scan is started the scan will silently fail
    and some devices will not be added.

    It is easy to hit the problem where devices do not show up with
    FC where we are doing tests that disrupt the target controllers.
    When the controller is disruprted (reboot, or setting firmware, etc),
    and we cause the dev loss tmo to fire then devices will be removed
    Then when the problem has been fixed, the rport will be scanned and
    devices should be added back. But if we cause another disruption before
    scanning has started then devices will not get added back. If the problem
    is not started until the scan is started then the devices will be added
    back.

    This patch fixes that problem by not failing scans when the host
    is in recovery. We will let scsi-ml send the IO and let the queueing
    and scsi error handling deal with it like is done if we went into
    recovery while scanning.

    For recovery cases where the host is being torn down then with the
    patch we will still fail the scan since there is not point in scanning.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

27 Aug, 2011

1 commit

  • 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
    Reviewed-by: Mike Christie
    Signed-off-by: James Bottomley

    Vikas Chaudhary
     

31 Mar, 2011

1 commit


17 Nov, 2010

1 commit

  • Move the mid-layer's ->queuecommand() invocation from being locked
    with the host lock to being unlocked to facilitate speeding up the
    critical path for drivers who don't need this lock taken anyway.

    The patch below presents a simple SCSI host lock push-down as an
    equivalent transformation. No locking or other behavior should change
    with this patch. All existing bugs and locking orders are preserved.

    Additionally, add one parameter to queuecommand,
    struct Scsi_Host *
    and remove one parameter from queuecommand,
    void (*done)(struct scsi_cmnd *)

    Scsi_Host* is a convenient pointer that most host drivers need anyway,
    and 'done' is redundant to struct scsi_cmnd->scsi_done.

    Minimal code disturbance was attempted with this change. Most drivers
    needed only two one-line modifications for their host lock push-down.

    Signed-off-by: Jeff Garzik
    Acked-by: James Bottomley
    Signed-off-by: Linus Torvalds

    Jeff Garzik
     

11 Sep, 2010

1 commit

  • 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
    Signed-off-by: Jens Axboe

    Martin K. Petersen
     

03 Jun, 2010

1 commit

  • Implement sd_unlock_native_capacity() method which calls into
    hostt->unlock_native_capacity() if implemented. This will be invoked
    by block layer if partitions extend beyond the end of the device and
    can be used to implement, for example, on-demand ATA host protected
    area unlocking.

    Signed-off-by: Tejun Heo
    Cc: Ben Hutchings
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

10 Dec, 2009

1 commit

  • * 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
    ...

    Linus Torvalds
     

05 Dec, 2009

2 commits

  • Some of our virtual SCSI hosts don't have a proper bus parent at the
    top, which can be a problem for doing DMA on them

    This patch makes the host device cache a pointer to the physical bus
    device and provides an extra API for setting it (the normal API picks
    it up from the parent). This patch also modifies the qla2xxx and lpfc
    vport logic to use the new DMA host setting API.

    Acked-By: James Smart
    Cc: Stable Tree
    Signed-off-by: James Bottomley

    James Bottomley
     
  • 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

    [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
    [jejb: fixed up 53c700]
    Signed-off-by: James Bottomley

    Mike Christie
     

07 Nov, 2009

1 commit


02 Oct, 2009

1 commit

  • So far we have only issued DIF commands if CONFIG_BLK_DEV_INTEGRITY is
    enabled. However, communication between initiator and target should be
    independent of protection information DMA. There are DIF-only host
    adapters coming out that will be able to take advantage of this.

    Move the relevant DIF bits to sd.c.

    Signed-off-by: Martin K. Petersen
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

13 Jun, 2009

1 commit

  • Attached is the ELS/CT pass-thru patch for the FC Transport. The patch
    creates a generic framework that lays on top of bsg and the SGIO v4 ioctl
    in order to pass transaction requests to LLDD's.

    The interface supports the following operations:
    On an fc_host basis:
    Request login to the specified N_Port_ID, creating an fc_rport.
    Request logout of the specified N_Port_ID, deleting an fc_rport
    Send ELS request to specified N_Port_ID w/o requiring a login, and
    wait for ELS response.
    Send CT request to specified N_Port_ID and wait for CT response.
    Login is required, but LLDD is allowed to manage login and decide
    whether it stays in place after the request is satisfied.
    Vendor-Unique request. Allows a LLDD-specific request to be passed
    to the LLDD, and the passing of a response back to the application.
    On an fc_rport basis:
    Send ELS request to nport and wait for ELS response.
    Send CT request to nport and wait for CT response.

    The patch also exports several headers from include/scsi such that
    they can be available to user-space applications:
    include/scsi/scsi.h
    include/scsi/scsi_netlink.h
    include/scsi/scsi_netlink_fc.h
    include/scsi/scsi_bsg_fc.h

    For further information, refer to the last RFC:
    http://marc.info/?l=linux-scsi&m=123436574018579&w=2

    Note: Documentation is still spotty and will be added later.

    [bharrosh@panasas.com: update for new block API]
    Signed-off-by: James Smart
    Signed-off-by: James Bottomley

    James Smart
     

09 Oct, 2008

1 commit

  • 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
    Signed-off-by: Jens Axboe

    Jens Axboe
     

27 Jul, 2008

2 commits

  • 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
    Signed-off-by: James Bottomley

    Martin K. Petersen
     
  • Daniel Debonzi reports that he has managed to wrap host_no. Increasing
    the number of host numbers available to 32-bit from 16-bit allows the
    problem to be evaded for another hundred years.

    Signed-off-by: Matthew Wilcox
    Signed-off-by: James Bottomley

    Matthew Wilcox
     

22 Jul, 2008

1 commit


03 May, 2008

1 commit

  • Add support for variable-length, extended, and vendor specific
    CDBs to scsi-ml. It is now possible for initiators and ULD's
    to issue these types of commands. LLDs need not change much.
    All they need is to raise the .max_cmd_len to the longest command
    they support (see iscsi patch).

    - clean-up some code paths that did not expect commands to be
    larger than 16, and change cmd_len members' type to short as
    char is not enough.

    Signed-off-by: Boaz Harrosh
    Signed-off-by: Benny Halevy
    Signed-off-by: James Bottomley

    Boaz Harrosh
     

20 Apr, 2008

1 commit


08 Apr, 2008

1 commit

  • The problem is that serveral drivers are sending a target reset from the
    device reset handler, and if we have multiple devices a target reset gets
    sent for each device when only one would be sufficient. And if we do a target
    reset it affects all the commands on the target so the device reset handler
    code only cleaning up one devices's commands makes programming the driver a
    little more difficult than it should be.

    This patch adds a target reset handler, which drivers can use to send
    a target reset. If successful it cleans up the commands for a devices
    accessed through that starget.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

12 Feb, 2008

1 commit

  • Since the sg chaining patches went in, our current value of 255 for
    SG_ALL excites chaining on some drivers which cannot support it (and
    would thus oops). Redefine SG_ALL to mean no sg table size
    preference, but use the single allocation (non chained) limit. This
    also helps for drivers that use it to size an internal table.

    We'll do an opt in system later where truly chaining supporting
    drivers can define their sg_tablesize to be anything up to
    SCSI_MAX_SG_CHAIN_ELEMENTS.

    Signed-off-by: James Bottomley

    James Bottomley