1. 24 Nov, 2014 1 commit
  2. 12 Nov, 2014 1 commit
    • Christoph Hellwig's avatar
      scsi: add new scsi-command flag for tagged commands · 125c99bc
      Christoph Hellwig authored
      Currently scsi piggy backs on the block layer to define the concept
      of a tagged command.  But we want to be able to have block-level host-wide
      tags assigned even for untagged commands like the initial INQUIRY, so add
      a new SCSI-level flag for commands that are tagged at the scsi level, so
      that even commands without that set can have tags assigned to them.  Note
      that this alredy is the case for the blk-mq code path, and this just lets
      the old path catch up with it.
      We also set this flag based upon sdev->simple_tags instead of the block
      queue flag, so that it is entirely independent of the block layer tagging,
      and thus always correct even if a driver doesn't use block level tagging
      Also remove the old blk_rq_tagged; it was only used by SCSI drivers, and
      removing it forces them to look for the proper replacement.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
  3. 30 Sep, 2014 1 commit
  4. 17 Jul, 2014 1 commit
  5. 03 Jul, 2014 1 commit
  6. 11 Jun, 2014 1 commit
  7. 19 May, 2014 1 commit
  8. 27 Mar, 2014 1 commit
  9. 15 Mar, 2014 1 commit
  10. 19 Dec, 2013 1 commit
    • Hannes Reinecke's avatar
      [SCSI] improved eh timeout handler · e494f6a7
      Hannes Reinecke authored
      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: default avatarHannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
  11. 09 Oct, 2012 1 commit
  12. 08 Jul, 2012 1 commit
    • Mark Rustad's avatar
      [SCSI] Fix NULL dereferences in scsi_cmd_to_driver · 222a806a
      Mark Rustad authored
      Avoid crashing if the private_data pointer happens to be NULL. This has
      been seen sometimes when a host reset happens, notably when there are
      many LUNs:
      host3: Assigned Port ID 0c1601
      scsi host3: libfc: Host reset succeeded on port (0c1601)
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000350
      IP: [<ffffffff81352bb8>] scsi_send_eh_cmnd+0x58/0x3a0
      Process scsi_eh_3 (pid: 4144, threadinfo ffff88030920c000, task ffff880326b160c0)
       000000010372e6ba 0000000000000282 000027100920dca0 ffffffffa0038ee0
       0000000000000000 0000000000030003 ffff88030920dc80 ffff88030920dc80
       00000002000e0000 0000000a00004000 ffff8803242f7760 ffff88031326ed80
      Call Trace:
       [<ffffffff8105b590>] ? lock_timer_base+0x70/0x70
       [<ffffffff81352fbe>] scsi_eh_tur+0x3e/0xc0
       [<ffffffff81353a36>] scsi_eh_test_devices+0x76/0x170
       [<ffffffff81354125>] scsi_eh_host_reset+0x85/0x160
       [<ffffffff81354291>] scsi_eh_ready_devs+0x91/0x110
       [<ffffffff813543fd>] scsi_unjam_host+0xed/0x1f0
       [<ffffffff813546a8>] scsi_error_handler+0x1a8/0x200
       [<ffffffff81354500>] ? scsi_unjam_host+0x1f0/0x1f0
       [<ffffffff8106ec3e>] kthread+0x9e/0xb0
       [<ffffffff81509264>] kernel_thread_helper+0x4/0x10
       [<ffffffff8106eba0>] ? kthread_freezable_should_stop+0x70/0x70
       [<ffffffff81509260>] ? gs_change+0x13/0x13
      Code: 25 28 00 00 00 48 89 45 c8 31 c0 48 8b 87 80 00 00 00 48 8d b5 60 ff ff ff 89 d1 48 89 fb 41 89 d6 4c 89 fa 48 8b 80 b8 00 00 00
       <48> 8b 80 50 03 00 00 48 8b 00 48 89 85 38 ff ff ff 48 8b 07 4c
      RIP  [<ffffffff81352bb8>] scsi_send_eh_cmnd+0x58/0x3a0
       RSP <ffff88030920dc50>
      CR2: 0000000000000350
      Signed-off-by: default avatarMark Rustad <mark.d.rustad@intel.com>
      Tested-by: default avatarMarcus Dennis <marcusx.e.dennis@intel.com>
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
  13. 15 Apr, 2012 1 commit
  14. 19 Feb, 2012 2 commits
    • Martin K. Petersen's avatar
      [SCSI] Handle disk devices which can not process medium access commands · 18a4d0a2
      Martin K. Petersen authored
      We have experienced several devices which fail in a fashion we do not
      currently handle gracefully in SCSI. After a failure these devices will
      respond to the SCSI primary command set (INQUIRY, TEST UNIT READY, etc.)
      but any command accessing the storage medium will time out.
      The following patch adds an callback that can be used by upper level
      drivers to inspect the results of an error handling command. This in
      turn has been used to implement additional checking in the SCSI disk
      If a medium access command fails twice but TEST UNIT READY succeeds both
      times in the subsequent error handling we will offline the device. The
      maximum number of failed commands required to take a device offline can
      be tweaked in sysfs.
      Also add a new error flag to scsi_debug which allows this scenario to be
      easily reproduced.
      [jejb: fix up integer parsing to use kstrtouint]
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
    • Moger, Babu's avatar
      [SCSI] Correctly set the scsi host/msg/status bytes · 3384db9e
      Moger, Babu authored
      Resubmitting as my previous post had format issues and did not go llinux-scsi.
      This patch changes the function to set_msg_byte, set_host_byte and
      set_driver_byte to correctly set the corresponding bytes appropriately.
      It will reset the original setting and correctly set it to the new value.  The
      previous OR operation does not always set it back to new value. Look at patch
      2/2 for an example.
      Signed-off-by: default avatarBabu Moger <babu.moger@netapp.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
  15. 02 Oct, 2009 1 commit
  16. 11 May, 2009 1 commit
    • Tejun Heo's avatar
      block: convert to pos and nr_sectors accessors · 83096ebf
      Tejun Heo authored
      With recent cleanups, there is no place where low level driver
      directly manipulates request fields.  This means that the 'hard'
      request fields always equal the !hard fields.  Convert all
      rq->sectors, nr_sectors and current_nr_sectors references to
      While at it, drop superflous blk_rq_pos() < 0 test in swim.c.
      [ Impact: use pos and nr_sectors accessors ]
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
      Tested-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Tested-by: default avatarAdrian McMenamin <adrian@mcmen.demon.co.uk>
      Acked-by: default avatarAdrian McMenamin <adrian@mcmen.demon.co.uk>
      Acked-by: default avatarMike Miller <mike.miller@hp.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Cc: Borislav Petkov <petkovbb@googlemail.com>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Cc: Eric Moore <Eric.Moore@lsi.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Paul Clements <paul.clements@steeleye.com>
      Cc: Tim Waugh <tim@cyberelk.net>
      Cc: Jeff Garzik <jgarzik@pobox.com>
      Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Alex Dubov <oakad@yahoo.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Dario Ballabio <ballabio_dario@emc.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: unsik Kim <donari75@gmail.com>
      Cc: Laurent Vivier <Laurent@lvivier.info>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
  17. 12 Mar, 2009 1 commit
  18. 09 Oct, 2008 1 commit
  19. 26 Jul, 2008 2 commits
    • Martin K. Petersen's avatar
      [SCSI] Support devices with protection information · 7027ad72
      Martin K. Petersen authored
      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)
       - Accessor function for checking whether a device has protection
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
    • Martin K. Petersen's avatar
      [SCSI] Command protection operation · db007fc5
      Martin K. Petersen authored
      Controllers that support DMA of protection information must be told
      explicitly how to handle the I/O.  The controller has no knowledge of
      the protection capabilities of the target device so this information
      must be passed in the scsi_cmnd.
       - The protection operation tells the HBA whether to generate, strip or
         verify protection information.
       - The protection type tells the HBA which layout the target is
         formatted with.  This is necessary because the controller must be
         able to correctly interpret the included protection information in
         order to verify it.
       - When a scsi_cmnd is reused for error handling the protection
         operation must be cleared and saved while error handling is in
       - prot_op and prot_type are placed in an existing hole in scsi_cmnd
         and don't cause the structure to grow.
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
  20. 12 Jul, 2008 1 commit
  21. 02 May, 2008 2 commits
    • Boaz Harrosh's avatar
      [SCSI] add support for variable length extended commands · db4742dd
      Boaz Harrosh authored
      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: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
    • Boaz Harrosh's avatar
      [SCSI] Let scsi_cmnd->cmnd use request->cmd buffer · 64a87b24
      Boaz Harrosh authored
       - struct scsi_cmnd had a 16 bytes command buffer of its own.
         This is an unnecessary duplication and copy of request's
         cmd. It is probably left overs from the time that scsi_cmnd
         could function without a request attached. So clean that up.
       - Once above is done, few places, apart from scsi-ml, needed
         adjustments due to changing the data type of scsi_cmnd->cmnd.
       - Lots of drivers still use MAX_COMMAND_SIZE. So I have left
         that #define but equate it to BLK_MAX_CDB. The way I see it
         and is reflected in the patch below is.
         MAX_COMMAND_SIZE - means: The longest fixed-length (*) SCSI CDB
                            as per the SCSI standard and is not related
                            to the implementation.
         BLK_MAX_CDB.     - The allocated space at the request level
       - I have audit all ISA drivers and made sure none use ->cmnd in a DMA
         Operation. Same audit was done by Andi Kleen.
      (*)fixed-length here means commands that their size can be determined
         by their opcode and the CDB does not carry a length specifier, (unlike
         the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly
         true and the SCSI standard also defines extended commands and
         vendor specific commands that can be bigger than 16 bytes. The kernel
         will support these using the same infrastructure used for VARLEN CDB's.
         So in effect MAX_COMMAND_SIZE means the maximum size command
         scsi-ml supports without specifying a cmd_len by ULD's
      Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
  22. 07 Apr, 2008 2 commits
  23. 30 Jan, 2008 3 commits
    • Boaz Harrosh's avatar
      [SCSI] bidirectional command support · 6f9a35e2
      Boaz Harrosh authored
      At the block level bidi request uses req->next_rq pointer for a second
      bidi_read request.
      At Scsi-midlayer a second scsi_data_buffer structure is used for the
      bidi_read part. This bidi scsi_data_buffer is put on
      request->next_rq->special. Struct scsi_cmnd is not changed.
      - Define scsi_bidi_cmnd() to return true if it is a bidi request and a
        second sgtable was allocated.
      - Define scsi_in()/scsi_out() to return the in or out scsi_data_buffer
        from this command This API is to isolate users from the mechanics of
      - Define scsi_end_bidi_request() to do what scsi_end_request() does but
        for a bidi request. This is necessary because bidi commands are a bit
        tricky here. (See comments in body)
      - scsi_release_buffers() will also release the bidi_read scsi_data_buffer
      - scsi_io_completion() on bidi commands will now call
        scsi_end_bidi_request() and return.
      - The previous work done in scsi_init_io() is now done in a new
        scsi_init_sgtable() (which is 99% identical to old scsi_init_io())
        The new scsi_init_io() will call the above twice if needed also for
        the bidi_read command. Only at this point is a command bidi.
      - In scsi_error.c at scsi_eh_prep/restore_cmnd() make sure bidi-lld is not
        confused by a get-sense command that looks like bidi. This is done
        by puting NULL at request->next_rq, and restoring.
      [jejb: update to sg_table and resolve conflicts
      also update to blk-end-request and resolve conflicts]
      Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
    • Boaz Harrosh's avatar
      [SCSI] implement scsi_data_buffer · 30b0c37b
      Boaz Harrosh authored
      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
      - 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
      - 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
        * 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: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
    • Boaz Harrosh's avatar
      [SCSI] tgt: use scsi_init_io instead of scsi_alloc_sgtable · bb52d82f
      Boaz Harrosh authored
      If we export scsi_init_io()/scsi_release_buffers() instead of
      scsi_{alloc,free}_sgtable() from scsi_lib than tgt code is much more
      insulated from scsi_lib changes. As a bonus it will also gain bidi
      capability when it comes.
      [jejb: rebase on to sg_table and fix up rejections]
      Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Acked-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
  24. 28 Jan, 2008 1 commit
  25. 23 Jan, 2008 1 commit
  26. 06 Jan, 2008 1 commit
    • Linus Torvalds's avatar
      Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done"" · 7b3d9545
      Linus Torvalds authored
      This reverts commit ac40532e, which gets
      us back the original cleanup of 6f5391c2.
      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
      6f5391c2 is applied or not):
        " 1. Start with an empty drive.
          2. pktsetup 0 /dev/scd0
          3. Insert a CD containing an isofs filesystem.
          4. mount /dev/pktcdvd/0 /mnt/tmp
          5. umount /mnt/tmp
          6. Press the eject button.
          7. Insert a DVD containing a non-writable filesystem.
          8. mount /dev/scd0 /mnt/tmp
          9. find /mnt/tmp -type f -print0 | xargs -0 sha1sum >/dev/null
          10. If the DVD contains data beyond the physical size of a CD, you
              get I/O errors in the terminal, and dmesg reports lots of
              "attempt to access beyond end of device" errors."
      which in turn is because the nested open after the media change won't
      cause the size to be set properly (because the original open still holds
      the block device, and we only do the bd_set_size() when we don't have
      other people holding the device open).
      The proper fix for that is probably to just do something like
      	bdev->bd_inode->i_size = (loff_t)get_capacity(disk)<<9;
      in fs/block_dev.c:do_open() even for the cases where we're not the
      original opener (but *not* call bd_set_size(), since that will also
      change the block size of the device).
      Cc: Peter Osterlund <petero2@telia.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Matthew Wilcox <matthew@wil.cx>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  27. 02 Jan, 2008 1 commit
  28. 16 Oct, 2007 4 commits
  29. 12 Oct, 2007 2 commits
  30. 26 May, 2007 1 commit