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
     

16 Sep, 2010

1 commit

  • Fix two bugs in the VPD page wrapper:

    - Don't return failure if the user asked for page 0

    - The end of buffer check failed to account for the page header size
    and consequently didn't work

    Signed-off-by: Martin K. Petersen
    Cc: Stable Tree
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

01 May, 2010

1 commit


02 Mar, 2010

1 commit


19 Jan, 2010

1 commit


05 Dec, 2009

1 commit

  • 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
    Tested-by: Christof Schmitt
    Tested-by: Giridhar Malavali
    Signed-off-by: James Bottomley

    Vasu Dev
     

02 Oct, 2009

1 commit


23 Aug, 2009

1 commit

  • Universally, SCSI functions assume the lengths fed in are those of the buffer
    to DMA data to, not the lengths of the data minus the header.
    scsi_vpd_inquiry() assumed the latter and got it wrong, so fix up all the
    functions to use the correct assumption (and fix a bug where INQUIRY in SCSI-2
    dcannot go over 255).

    [jejb: Matthew posted an identical version of this at the same time I did]
    Signed-off-by: Matthew Wilcox
    Signed-off-by: James Bottomley

    James Bottomley
     

09 Jun, 2009

1 commit


03 Apr, 2009

1 commit


13 Mar, 2009

1 commit

  • Based on prior work by Martin Petersen and James Bottomley, this patch
    adds a generic helper for retrieving VPD pages from SCSI devices.

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

    Matthew Wilcox
     

14 Jan, 2009

1 commit

  • __scsi_device_lookup_by_target() will always return
    the first sdev with a matching LUN, regardless of
    the state. However, when this sdev is in SDEV_DEL
    scsi_device_lookup_by_target() will ignore this
    device and so any valid device on the list after
    the deleted device will never be found.
    So we have to modify __scsi_device_lookup_by_target()
    to skip any device in SDEV_DEL.

    Signed-off-by: Hannes Reinecke
    Signed-off-by: James Bottomley

    Hannes Reinecke
     

03 Jan, 2009

1 commit


13 Oct, 2008

1 commit

  • SCSI-ml manages the queueing limits for the device and host, but
    does not do so at the target level. However something something similar
    can come in userful when a driver is transitioning a transport object to
    the the blocked state, becuase at that time we do not want to queue
    io and we do not want the queuecommand to be called again.

    The patch adds code similar to the exisiting SCSI_ML_*BUSY handlers.
    You can now return SCSI_MLQUEUE_TARGET_BUSY when we hit
    a transport level queueing issue like the hw cannot allocate some
    resource at the iscsi session/connection level, or the target has temporarily
    closed or shrunk the queueing window, or if we are transitioning
    to the blocked state.

    bnx2i, when they rework their firmware according to netdev
    developers requests, will also need to be able to limit queueing at this
    level. bnx2i will hook into libiscsi, but will allocate a scsi host per
    netdevice/hba, so unlike pure software iscsi/iser which is allocating
    a host per session, it cannot set the scsi_host->can_queue and return
    SCSI_MLQUEUE_HOST_BUSY to reflect queueing limits on the transport.

    The iscsi class/driver can also set a scsi_target->can_queue value which
    reflects the max commands the driver/class can support. For iscsi this
    reflects the number of commands we can support for each session due to
    session/connection hw limits, driver limits, and to also reflect the
    session/targets's queueing window.

    Changes:
    v1 - initial patch.
    v2 - Fix scsi_run_queue handling of multiple blocked targets.
    Previously we would break from the main loop if a device was added back on
    the starved list. We now run over the list and check if any target is
    blocked.
    v3 - Rediff for scsi-misc.

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

    Mike Christie
     

11 Oct, 2008

1 commit

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

    Linus Torvalds
     

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
     

04 Oct, 2008

1 commit


27 Jul, 2008

2 commits

  • Implement support for DMA of protection information for devices that
    are data integrity capable.

    - Add support for mapping an extra scatter-gather list containing
    the protection information.

    - Allocate protection scsi_data_buffer if host is DIX (integrity DMA)
    capable.

    - Accessor function for checking whether a device has protection
    enabled.

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

    Martin K. Petersen
     
  • Currently qla4xxx and stex pass in their can_queue values into
    scsi_activate_tcq because they wanted the tag map that large.
    The problem with this is that it ends up also setting the queue
    depth to that large value. All we want to do this in this case
    is set the device queue depth and the other device settings.
    We do not need to touch the tag map sizing because the drivers
    had setup that map according to their can_queue limits when the
    shared map was created.

    The scsi mid layer in request_fn will then handle the case where we
    have more requests than available tags when it checks the host
    queue ready function.

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

    Mike Christie
     

05 Jun, 2008

1 commit

  • USB sometimes doesn't return an error but instead returns a residue
    value indicating part (or all) of the command wasn't completed. So if
    the driver _done() error processing indicates the command was fully
    processed, subtract off the residue so that this USB error gets
    propagated.

    Cc: Alan Stern
    Signed-off-by: James Bottomley

    James Bottomley
     

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
     

30 Apr, 2008

1 commit

  • commit:

    commit 542bd1377a963070bc4a03ff7d2690ddf3920596
    Author: James Bottomley
    Date: Mon Apr 21 10:57:20 2008 -0500

    [SCSI] fix SLUB WARN_ON

    Fixed another problem in free list handling by moving list allocation
    from scsi_host_alloc() to scsi_add_host(). Unfortunately it
    introduced a new failure mode in that hosts can pass straight from
    alloc to put without going through add, leaving the free list
    uninitialised.

    Fix by checking shost->cmd_pool on the release path to see if it got
    initialised.

    Signed-off-by: Alan D. Brunelle
    Signed-off-by: James Bottomley

    Alan D. Brunelle
     

21 Apr, 2008

1 commit

  • blk_rq_map_user adjusts bi_size of the last bio. It breaks the rule
    that req->data_len (the true data length) is equal to sum(bio). It
    broke the scsi command completion code.

    commit e97a294ef6938512b655b1abf17656cf2b26f709 was introduced to fix
    the above issue. However, the partial completion code doesn't work
    with it. The commit is also a layer violation (scsi mid-layer should
    not know about the block layer's padding).

    This patch moves the padding adjustment to blk_rq_map_sg (suggested by
    James). The padding works like the drain buffer. This patch breaks the
    rule that req->data_len is equal to sum(sg), however, the drain buffer
    already broke it. So this patch just restores the rule that
    req->data_len is equal to sub(bio) without breaking anything new.

    Now when a low level driver needs padding, blk_rq_map_user and
    blk_rq_map_user_iov guarantee there's enough room for padding.
    blk_rq_map_sg can safely extend the last entry of a scatter list.

    blk_rq_map_sg must extend the last entry of a scatter list only for a
    request that got through bio_copy_user_iov. This patches introduces
    new REQ_COPY_USER flag.

    Signed-off-by: FUJITA Tomonori
    Cc: Tejun Heo
    Cc: Mike Christie
    Cc: James Bottomley
    Signed-off-by: Jens Axboe

    FUJITA Tomonori
     

08 Apr, 2008

2 commits


07 Apr, 2008

1 commit

  • Since 2.6.25-rc7, I've been seeing an occasional livelock on one x86_64
    machine, copying kernel trees to tmpfs, paging out to swap.

    Signature: 6000 pages under writeback but never getting written; most
    tasks of interest trying to reclaim, but each get_swap_bio waiting for a
    bio in mempool_alloc's io_schedule_timeout(5*HZ); every five seconds an
    atomic page allocation failure report from kblockd failing to allocate a
    sense_buffer in __scsi_get_command.

    __scsi_get_command has a (one item) free_list to protect against this,
    but rc1's [SCSI] use dynamically allocated sense buffer
    de25deb18016f66dcdede165d07654559bb332bc upset that slightly. When it
    fails to allocate from the separate sense_slab, instead of giving up, it
    must fall back to the command free_list, which is sure to have a
    sense_buffer attached.

    Either my earlier -rc testing missed this, or there's some recent
    contributory factor. One very significant factor is SLUB, which merges
    slab caches when it can, and on 64-bit happens to merge both bio cache
    and sense_slab cache into kmalloc's 128-byte cache: so that under this
    swapping load, bios above are liable to gobble up all the slots needed
    for scsi_cmnd sense_buffers below.

    That's disturbing behaviour, and I tried a few things to fix it. Adding
    a no-op constructor to the sense_slab inhibits SLUB from merging it, and
    stops all the allocation failures I was seeing; but it's rather a hack,
    and perhaps in different configurations we have other caches on the
    swapout path which are ill-merged.

    Another alternative is to revert the separate sense_slab, using
    cache-line-aligned sense_buffer allocated beyond scsi_cmnd from the one
    kmem_cache; but that might waste more memory, and is only a way of
    diverting around the known problem.

    While I don't like seeing the allocation failures, and hate the idea of
    all those bios piled up above a scsi host working one by one, it does
    seem to emerge fairly soon with the livelock fix. So lacking better
    ideas, stick with that one clear fix for now.

    Signed-off-by: Hugh Dickins
    Cc: James Bottomley
    Cc: Andrew Morton
    Cc: FUJITA Tomonori
    Cc: Jens Axboe
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Peter Zijlstra
    Cc: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     

05 Mar, 2008

1 commit


08 Feb, 2008

1 commit


31 Jan, 2008

1 commit

  • In preparation for bidi we abstract all IO members of scsi_cmnd,
    that will need to duplicate, into a substructure.

    - Group all IO members of scsi_cmnd into a scsi_data_buffer
    structure.
    - Adjust accessors to new members.
    - scsi_{alloc,free}_sgtable receive a scsi_data_buffer instead of
    scsi_cmnd. And work on it.
    - Adjust scsi_init_io() and scsi_release_buffers() for above
    change.
    - Fix other parts of scsi_lib/scsi.c to members migration. Use
    accessors where appropriate.

    - fix Documentation about scsi_cmnd in scsi_host.h

    - scsi_error.c
    * Changed needed members of struct scsi_eh_save.
    * Careful considerations in scsi_eh_prep/restore_cmnd.

    - sd.c and sr.c
    * sd and sr would adjust IO size to align on device's block
    size so code needs to change once we move to scsi_data_buff
    implementation.
    * Convert code to use scsi_for_each_sg
    * Use data accessors where appropriate.

    - tgt: convert libsrp to use scsi_data_buffer

    - isd200: This driver still bangs on scsi_cmnd IO members,
    so need changing

    [jejb: rebased on top of sg_table patches fixed up conflicts
    and used the synergy to eliminate use_sg and sg_count]

    Signed-off-by: Boaz Harrosh
    Signed-off-by: FUJITA Tomonori
    Signed-off-by: James Bottomley

    Boaz Harrosh
     

24 Jan, 2008

2 commits

  • Only hosts which actually have ISA DMA requirements need sense buffers
    coming out of ZONE_DMA, so only use the __GFP_DMA flag for that case
    to avoid allocating this scarce resource if it's not necessary.

    [tomo: fixed slab leak in failure case]
    Acked-by: FUJITA Tomonori
    Signed-off-by: James Bottomley

    James Bottomley
     
  • This removes static array sense_buffer in scsi_cmnd and uses
    dynamically allocated sense_buffer (with GFP_DMA).

    The reason for doing this is that some architectures need cacheline
    aligned buffer for DMA:

    http://lkml.org/lkml/2007/11/19/2

    The problems are that scsi_eh_prep_cmnd puts scsi_cmnd::sense_buffer
    to sglist and some LLDs directly DMA to scsi_cmnd::sense_buffer. It's
    necessary to DMA to scsi_cmnd::sense_buffer safely. This patch solves
    these issues.

    __scsi_get_command allocates sense_buffer via kmem_cache_alloc and
    attaches it to a scsi_cmnd so everything just work as before.

    Signed-off-by: FUJITA Tomonori
    Signed-off-by: James Bottomley

    FUJITA Tomonori
     

12 Jan, 2008

3 commits


07 Jan, 2008

1 commit

  • This reverts commit ac40532ef0b8649e6f7f83859ea0de1c4ed08a19, which gets
    us back the original cleanup of 6f5391c283d7fdcf24bf40786ea79061919d1e1d.

    It turns out that the bug that was triggered by that commit was
    apparently not actually triggered by that commit at all, and just the
    testing conditions had changed enough to make it appear to be due to it.

    The real problem seems to have been found by Peter Osterlund:

    "pktcdvd sets it [block device size] when opening the /dev/pktcdvd
    device, but when the drive is later opened as /dev/scd0, there is
    nothing that sets it back. (Btw, 40944 is possible if the disk is a
    CDRW that was formatted with "cdrwtool -m 10236".)

    The problem is that pktcdvd opens the cd device in non-blocking mode
    when pktsetup is run, and doesn't close it again until pktsetup -d is
    run. The effect is that if you meanwhile open the cd device,
    blkdev.c:do_open() doesn't call bd_set_size() because
    bdev->bd_openers is non-zero."

    In particular, to repeat the bug (regardless of whether commit
    6f5391c283d7fdcf24bf40786ea79061919d1e1d is applied or not):

    " 1. Start with an empty drive.
    2. pktsetup 0 /dev/scd0
    3. Insert a CD containing an isofs filesystem.
    4. mount /dev/pktcdvd/0 /mnt/tmp
    5. umount /mnt/tmp
    6. Press the eject button.
    7. Insert a DVD containing a non-writable filesystem.
    8. mount /dev/scd0 /mnt/tmp
    9. find /mnt/tmp -type f -print0 | xargs -0 sha1sum >/dev/null
    10. If the DVD contains data beyond the physical size of a CD, you
    get I/O errors in the terminal, and dmesg reports lots of
    "attempt to access beyond end of device" errors."

    which in turn is because the nested open after the media change won't
    cause the size to be set properly (because the original open still holds
    the block device, and we only do the bd_set_size() when we don't have
    other people holding the device open).

    The proper fix for that is probably to just do something like

    bdev->bd_inode->i_size = (loff_t)get_capacity(disk)<
    Cc: James Bottomley
    Cc: Matthew Wilcox
    Cc: Ingo Molnar
    Cc: Andrew Morton
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

03 Jan, 2008

1 commit

  • This reverts commit 6f5391c283d7fdcf24bf40786ea79061919d1e1d ("[SCSI]
    Get rid of scsi_cmnd->done") that was supposed to be a cleanup commit,
    but apparently it causes regressions:

    Bug 9370 - v2.6.24-rc2-409-g9418d5d: attempt to access beyond end of device
    http://bugzilla.kernel.org/show_bug.cgi?id=9370

    this patch should be reintroduced in a more split-up form to make
    testing of it easier.

    Signed-off-by: Ingo Molnar
    Acked-by: Matthew Wilcox
    Cc: James Bottomley
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

11 Dec, 2007

1 commit

  • The esp_reset_cleanup() function is called with the host lock held and
    invokes starget_for_each_device() which wants to take it too. Here is a
    fix along the lines of shost_for_each_device()/__shost_for_each_device()
    adding a __starget_for_each_device() counterpart which assumes the lock
    has already been taken.

    Eventually, I think the driver should get modified so that more work is
    done as a softirq rather than in the interrupt context, but for now it
    fixes a bug that causes the spinlock debugger to fire.

    While at it, it fixes a small number of cosmetic problems with
    starget_for_each_device() too.

    Signed-off-by: Maciej W. Rozycki
    Acked-by: David S. Miller
    Cc: James Bottomley
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Maciej W. Rozycki
     

13 Oct, 2007

2 commits

  • The ULD ->done callback moves into the scsi_driver. By moving the call
    to scsi_io_completion() from scsi_blk_pc_done() to scsi_finish_command(),
    we can eliminate the latter entirely. By returning 'good_bytes' from
    the ->done callback (rather than invoking scsi_io_completion()), we can
    stop exporting scsi_io_completion().

    Also move the prototypes from sd.h to sd.c as they're all internal anyway.
    Rename sd_rw_intr to sd_done and rw_intr to sr_done.

    Inspired-by: Christoph Hellwig
    Signed-off-by: Matthew Wilcox
    Signed-off-by: James Bottomley

    Matthew Wilcox
     
  • The pid field is a duplicate of the serial_number field and has been
    scheduled for removal for a long time. A few drivers were still using
    it, so just change them to use serial_number instead.

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

    Matthew Wilcox
     

20 Jul, 2007

1 commit

  • Slab destructors were no longer supported after Christoph's
    c59def9f222d44bb7e2f0a559f2906191a0862d7 change. They've been
    BUGs for both slab and slub, and slob never supported them
    either.

    This rips out support for the dtor pointer from kmem_cache_create()
    completely and fixes up every single callsite in the kernel (there were
    about 224, not including the slab allocator definitions themselves,
    or the documentation references).

    Signed-off-by: Paul Mundt

    Paul Mundt