1. 27 7月, 2008 4 次提交
    • A
      [SCSI] extend the last_sector_bug flag to cover more sectors · 2b142900
      Alan Jenkins 提交于
      The last_sector_bug flag was added to work around a bug in certain usb
      cardreaders, where they would crash if a multiple sector read included the
      last sector. The original implementation avoids this by e.g. splitting an 8
      sector read which includes the last sector into a 7 sector read, and a single
      sector read for the last sector.  The flag is enabled for all USB devices.
      
      This revealed a second bug in other usb cardreaders, which crash when they
      get a multiple sector read which stops 1 sector short of the last sector.
      Affected hardware includes the Kingston "MobileLite" external USB cardreader
      and the internal USB cardreader on the Asus EeePC.
      
      Extend the last_sector_bug workaround to ensure that any access which touches
      the last 8 hardware sectors of the device is a single sector long.  Requests
      are shrunk as necessary to meet this constraint.
      
      This gives us a safety margin against potential unknown or future bugs
      affecting multi-sector access to the end of the device.  The two known bugs
      only affect the last 2 sectors.  However, they suggest that these devices
      are prone to fencepost errors and that multi-sector access to the end of the
      device is not well tested.  Popular OS's use multi-sector accesses, but they
      rarely read the last few sectors.  Linux (with udev & vol_id) automatically
      reads sectors from the end of the device on insertion.  It is assumed that
      single sector accesses are more thoroughly tested during development.
      Signed-off-by: NAlan Jenkins <alan-jenkins@tuffmail.co.uk>
      Tested-by: NAlan Jenkins <alan-jenkins@tuffmail.co.uk>
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      2b142900
    • M
      [SCSI] sd: Support for SCSI disk (SBC) Data Integrity Field · af55ff67
      Martin K. Petersen 提交于
      Support for controllers and disks that implement DIF protection
      information:
      
       - During command preparation the RDPROTECT/WRPROTECT must be set
         correctly if the target has DIF enabled.
      
       - READ(6) and WRITE(6) are not supported when DIF is on.
      
       - The controller must be told how to handle the I/O via the
         protection operation field in scsi_cmnd.
      
       - Refactor the I/O completion code that extracts failed LBA from the
         returned sense data and handle DIF failures correctly.
      
       - sd_dif.c implements the functions required to prepare and complete
         requests with protection information attached.
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      af55ff67
    • M
      [SCSI] sd: Identify DIF protection type and application tag ownership · e0597d70
      Martin K. Petersen 提交于
      If a disk is formatted with protection information (Inquiry bit
      PROTECT=1) it is required to support Read Capacity(16).  Force use of
      the 16-bit command in this case and extract the P_TYPE field which
      indicates whether the disk is formatted using DIF Type 1, 2 or 3.
      
      The ATO (App Tag Own) bit in the Control Mode Page indicates whether
      the storage device or the initiator own the contents of the
      DIF application tag.
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      e0597d70
    • T
      [SCSI] sd: update index allocation and use ida instead of idr · f27bac27
      Tejun Heo 提交于
      Update index allocation as follows.
      
      * sd_index_idr is used only for ID allocation and mapping
        functionality is not used.  Use more memory efficient ida instead.
      
      * idr and ida have their own locks inside them and don't need them for
        operation.  Drop it.
      
      * index wasn't freed if probing failed after index allocation.  fix
        it.
      
      * ida allocation should be repeated if it fails with -EAGAIN.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      f27bac27
  2. 14 7月, 2008 1 次提交
    • S
      scsi: sd: optionally set power condition in START STOP UNIT · d2886ea3
      Stefan Richter 提交于
      Adds a new scsi_device flag, start_stop_pwr_cond:  If enabled, the sd
      driver will not send plain START STOP UNIT commands but ones with the
      power condition field set to 3 (standby) or 1 (active) respectively.
      
      Some FireWire disk firmwares do not stop the motor if power condition is
      zero.  Or worse, they become unresponsive after a START STOP UNIT with
      power condition = 0 and start = 0.
      
      http://lkml.org/lkml/2008/4/29/704
      
      This patch only adds the necessary code to sd_mod but doesn't activate
      it.  Follow-up patches to the FireWire drivers will add detection of
      affected devices and enable the code for them.
      
      I did not add power condition values to scsi_error.c::scsi_eh_try_stu()
      for now.  The three firmwares which suffer from above mentioned problems
      do not need START STOP UNIT in the error handler, and they are not
      adversely affected by START STOP UNIT with power condition = 0 and start
      = 1 (like scsi_eh_try_stu() sends it if scsi_device.allow_restart is
      enabled).
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      Tested-by: NTino Keitel <tino.keitel@gmx.de>
      d2886ea3
  3. 12 7月, 2008 2 次提交
  4. 29 4月, 2008 1 次提交
  5. 20 4月, 2008 1 次提交
  6. 20 3月, 2008 1 次提交
  7. 24 2月, 2008 1 次提交
    • R
      PM: Introduce PM_EVENT_HIBERNATE callback state · 3a2d5b70
      Rafael J. Wysocki 提交于
      During the last step of hibernation in the "platform" mode (with the
      help of ACPI) we use the suspend code, including the devices'
      ->suspend() methods, to prepare the system for entering the ACPI S4
      system sleep state.
      
      But at least for some devices the operations performed by the
      ->suspend() callback in that case must be different from its operations
      during regular suspend.
      
      For this reason, introduce the new PM event type PM_EVENT_HIBERNATE and
      pass it to the device drivers' ->suspend() methods during the last phase
      of hibernation, so that they can distinguish this case and handle it as
      appropriate.  Modify the drivers that handle PM_EVENT_SUSPEND in a
      special way and need to handle PM_EVENT_HIBERNATE in the same way.
      
      These changes are necessary to fix a hibernation regression related
      to the i915 driver (ref. http://lkml.org/lkml/2008/2/22/488).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Tested-by: NJeff Chua <jeff.chua.linux@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3a2d5b70
  8. 08 2月, 2008 1 次提交
  9. 31 1月, 2008 1 次提交
    • B
      [SCSI] implement scsi_data_buffer · 30b0c37b
      Boaz Harrosh 提交于
      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: NBoaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      30b0c37b
  10. 24 1月, 2008 1 次提交
  11. 12 1月, 2008 2 次提交
    • J
      [SCSI] sd,sr: add early detection of medium not present · 001aac25
      James Bottomley 提交于
      The current scsi_test_unit_ready() is updated to return sense code
      information (in struct scsi_sense_hdr).  The sd and sr drivers are
      changed to interpret the sense code return asc 0x3a as no media and
      adjust the device status accordingly.
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      001aac25
    • K
      [SCSI] sr,sd: send media state change modification events · 285e9670
      Kay Sievers 提交于
      This will send for a card reader slot (remove/add media):
        UEVENT[1187091572.155884] change   /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
        UEVENT[1187091572.162314] remove   /block/sdb/sdb1 (block)
        UEVENT[1187091572.172464] add      /block/sdb/sdb1 (block)
        UEVENT[1187091572.175408] change   /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
      
      and for a DVD drive (add/eject media):
        UEVENT[1187091590.189159] change   /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
        UEVENT[1187091590.957124] add      /module/isofs (module)
        UEVENT[1187091604.468207] change   /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
      
      Userspace gets events, even for unpartitioned media. This unifies
      the event handling for asynchronoous events (AN) and events caused by
      perodical polling the device from userspace.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      
      [jejb: modified for new event API]
      Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      285e9670
  12. 07 1月, 2008 1 次提交
    • L
      Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done"" · 7b3d9545
      Linus Torvalds 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      7b3d9545
  13. 03 1月, 2008 1 次提交
  14. 20 10月, 2007 1 次提交
  15. 16 10月, 2007 1 次提交
  16. 13 10月, 2007 2 次提交
    • M
      [SCSI] Get rid of scsi_cmnd->done · 6f5391c2
      Matthew Wilcox 提交于
      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: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NMatthew Wilcox <willy@linux.intel.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
      6f5391c2
    • J
      [SCSI] move ULD attachment into the prep function · 7f9a6bc4
      James Bottomley 提交于
      One of the intents of the block prep function was to allow ULDs to use
      it for preprocessing.  The original SCSI model was to have a single prep
      function and add a pointer indirect filter to build the necessary
      commands.  This patch reverses that, does away with the init_command
      field of the scsi_driver structure and makes ULDs attach directly to the
      prep function instead.  The value is really that it allows us to begin
      to separate the ULDs from the SCSI mid layer (as long as they don't use
      any core functions---which is hard at the moment---a ULD doesn't even
      need SCSI to bind).
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
      7f9a6bc4
  17. 04 8月, 2007 1 次提交
  18. 24 7月, 2007 1 次提交
  19. 16 7月, 2007 1 次提交
  20. 24 5月, 2007 1 次提交
  21. 23 5月, 2007 1 次提交
  22. 18 4月, 2007 1 次提交
    • M
      [SCSI] modalias for scsi devices · d7b8bcb0
      Michael Tokarev 提交于
      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: NMichael Tokarev <mjt@tls.msk.ru>
      Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
      d7b8bcb0
  23. 21 3月, 2007 3 次提交
  24. 12 3月, 2007 3 次提交
  25. 17 2月, 2007 1 次提交
  26. 15 2月, 2007 1 次提交
    • T
      [PATCH] remove many unneeded #includes of sched.h · cd354f1a
      Tim Schmielau 提交于
      After Al Viro (finally) succeeded in removing the sched.h #include in module.h
      recently, it makes sense again to remove other superfluous sched.h includes.
      There are quite a lot of files which include it but don't actually need
      anything defined in there.  Presumably these includes were once needed for
      macros that used to live in sched.h, but moved to other header files in the
      course of cleaning it up.
      
      To ease the pain, this time I did not fiddle with any header files and only
      removed #includes from .c-files, which tend to cause less trouble.
      
      Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
      arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
      allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
      configs in arch/arm/configs on arm.  I also checked that no new warnings were
      introduced by the patch (actually, some warnings are removed that were emitted
      by unnecessarily included header files).
      Signed-off-by: NTim Schmielau <tim@physik3.uni-rostock.de>
      Acked-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cd354f1a
  27. 03 2月, 2007 1 次提交
    • N
      [SCSI] sd: udev accessing an uninitialized scsi_disk field results in a crash · 017f2e37
      Nagendra Singh Tomar 提交于
      	sd_probe() calls class_device_add() even before initializing the
      sdkp->device variable. class_device_add() eventually results in the user mode
      udev program to be called. udev program can read the the allow_restart
      attribute of the newly created scsi device. This is resulting in a crash as
      the show function for allow_restart (i.e sd_show_allow_restart) returns the
      attribute value by reading the sdkp->device->allow_restart variable. As the
      sdkp->device is not initialized before calling the user mode hotplug helper,
      this results in a crash.
      	The patch below solves it by calling class_device_add() only after the
      necessary fields in the scsi_disk structure are initialized properly.
      Signed-off-by: NNagendra Singh Tomar <nagendra_tomar@adaptec.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
      017f2e37
  28. 09 12月, 2006 1 次提交
  29. 16 11月, 2006 2 次提交