1. 26 Jan, 2020 1 commit
  2. 10 Jan, 2020 1 commit
  3. 27 Nov, 2019 1 commit
  4. 07 Nov, 2019 1 commit
  5. 25 Oct, 2019 1 commit
  6. 23 Oct, 2019 1 commit
    • Arnd Bergmann's avatar
      scsi: sd: enable compat ioctls for sed-opal · 142b2ac8
      Arnd Bergmann authored
      The sed_ioctl() function is written to be compatible between
      32-bit and 64-bit processes, however compat mode is only
      wired up for nvme, not for sd.
      
      Add the missing call to sed_ioctl() in sd_compat_ioctl().
      
      Fixes: d80210f2
      
       ("sd: add support for TCG OPAL self encrypting disks")
      Cc: linux-scsi@vger.kernel.org
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      142b2ac8
  7. 01 Oct, 2019 2 commits
  8. 18 Sep, 2019 1 commit
  9. 07 Sep, 2019 1 commit
  10. 05 Aug, 2019 1 commit
  11. 18 Jun, 2019 2 commits
    • Bart Van Assche's avatar
      scsi: sd: Inline sd_probe_part2() · 82a54da6
      Bart Van Assche authored
      
      
      Make sd_probe() easier to read by inlining sd_probe_part2(). This patch
      does not change any functionality.
      
      [mkp: applied by hand]
      
      Cc: Lee Duncan <lduncan@suse.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      82a54da6
    • Bart Van Assche's avatar
      scsi: sd: Rely on the driver core for asynchronous probing · f049cf1a
      Bart Van Assche authored
      As explained during the 2018 LSF/MM session about increasing SCSI disk
      probing concurrency, the problems with the current probing approach are as
      follows:
      
       - The driver core is unaware of asynchronous SCSI LUN probing.
         wait_for_device_probe() waits for all asynchronous probes except
         asynchronous SCSI disk probes.
      
       - There is unnecessary serialization between sd_probe() and sd_remove().
         This can lead to a deadlock.
      
      Hence this patch that modifies the sd driver such that it uses the driver
      core framework for asynchronous probing. The async domain and
      get_device()/put_device() pairs that became superfluous due to this change
      are removed.
      
      This patch does not affect the time needed for loading the scsi_debug
      kernel module with parameters delay=0 and max_luns=256.
      
      This patch depends on commit ef0ff683
      
       ("driver core: Probe devices
      asynchronously instead of the driver") that went upstream in kernel version
      v5.1-rc1.
      
      Cc: Lee Duncan <lduncan@suse.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f049cf1a
  12. 21 May, 2019 2 commits
  13. 20 May, 2019 1 commit
    • Martin K. Petersen's avatar
      Revert "scsi: sd: Keep disk read-only when re-reading partition" · 8acf608e
      Martin K. Petersen authored
      This reverts commit 20bd1d02.
      
      This patch introduced regressions for devices that come online in
      read-only state and subsequently switch to read-write.
      
      Given how the partition code is currently implemented it is not
      possible to persist the read-only flag across a device revalidate
      call. This may need to get addressed in the future since it is common
      for user applications to proactively call BLKRRPART.
      
      Reverting this commit will re-introduce a regression where a
      device-initiated revalidate event will cause the admin state to be
      forgotten. A separate patch will address this issue.
      
      Fixes: 20bd1d02
      
       ("scsi: sd: Keep disk read-only when re-reading partition")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      8acf608e
  14. 29 Apr, 2019 2 commits
  15. 12 Apr, 2019 1 commit
    • Martin Wilck's avatar
      block: disk_events: introduce event flags · c92e2f04
      Martin Wilck authored
      Currently, an empty disk->events field tells the block layer not to
      forward media change events to user space. This was done in commit
      7c88a168
      
       ("block: don't propagate unlisted DISK_EVENTs to userland")
      in order to avoid events from "fringe" drivers to be forwarded to user
      space. By doing so, the block layer lost the information which events
      were supported by a particular block device, and most importantly,
      whether or not a given device supports media change events at all.
      
      Prepare for not interpreting the "events" field this way in the future
      any more. This is done by adding an additional field "event_flags" to
      struct gendisk, and two flag bits that can be set to have the device
      treated like one that had the "events" field set to a non-zero value
      before. This applies only to the sd and sr drivers, which are changed to
      set the new flags.
      
      The new flags are DISK_EVENT_FLAG_POLL to enforce polling of the device
      for synchronous events, and DISK_EVENT_FLAG_UEVENT to tell the
      blocklayer to generate udev events from kernel events.
      
      In order to add the event_flags field to struct gendisk, the events
      field is converted to an "unsigned short"; it doesn't need to hold
      values bigger than 2 anyway.
      
      This patch doesn't change behavior.
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      c92e2f04
  16. 06 Apr, 2019 1 commit
    • Christoph Hellwig's avatar
      block: remove CONFIG_LBDAF · 72deb455
      Christoph Hellwig authored
      
      
      Currently support for 64-bit sector_t and blkcnt_t is optional on 32-bit
      architectures.  These types are required to support block device and/or
      file sizes larger than 2 TiB, and have generally defaulted to on for
      a long time.  Enabling the option only increases the i386 tinyconfig
      size by 145 bytes, and many data structures already always use
      64-bit values for their in-core and on-disk data structures anyway,
      so there should not be a large change in dynamic memory usage either.
      
      Dropping this option removes a somewhat weird non-default config that
      has cause various bugs or compiler warnings when actually used.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      72deb455
  17. 28 Mar, 2019 4 commits
    • Martin K. Petersen's avatar
      scsi: sd: Quiesce warning if device does not report optimal I/O size · 1d5de5bd
      Martin K. Petersen authored
      Commit a83da8a4 ("scsi: sd: Optimal I/O size should be a multiple
      of physical block size") split one conditional into several separate
      statements in an effort to provide more accurate warning messages when
      a device reports a nonsensical value. However, this reorganization
      accidentally dropped the precondition of the reported value being
      larger than zero. This lead to a warning getting emitted on devices
      that do not report an optimal I/O size at all.
      
      Remain silent if a device does not report an optimal I/O size.
      
      Fixes: a83da8a4
      
       ("scsi: sd: Optimal I/O size should be a multiple of physical block size")
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarHussam Al-Tayeb <ht990332@gmx.com>
      Tested-by: default avatarHussam Al-Tayeb <ht990332@gmx.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      1d5de5bd
    • Bart Van Assche's avatar
      scsi: sd: Fix a race between closing an sd device and sd I/O · c14a5726
      Bart Van Assche authored
      
      
      The scsi_end_request() function calls scsi_cmd_to_driver() indirectly and
      hence needs the disk->private_data pointer. Avoid that that pointer is
      cleared before all affected I/O requests have finished. This patch avoids
      that the following crash occurs:
      
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      Call trace:
       scsi_mq_uninit_cmd+0x1c/0x30
       scsi_end_request+0x7c/0x1b8
       scsi_io_completion+0x464/0x668
       scsi_finish_command+0xbc/0x160
       scsi_eh_flush_done_q+0x10c/0x170
       sas_scsi_recover_host+0x84c/0xa98 [libsas]
       scsi_error_handler+0x140/0x5b0
       kthread+0x100/0x12c
       ret_from_fork+0x10/0x18
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Jason Yan <yanaijie@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reported-by: default avatarJason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c14a5726
    • Bart Van Assche's avatar
      scsi: sd: Inline sd_probe_part2() · d16ece57
      Bart Van Assche authored
      
      
      Make sd_probe() easier to read by inlining sd_probe_part2(). This patch
      does not change any functionality.
      
      Cc: Lee Duncan <lduncan@suse.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      d16ece57
    • Bart Van Assche's avatar
      scsi: sd: Rely on the driver core for asynchronous probing · 21e6ba3f
      Bart Van Assche authored
      As explained during the 2018 LSF/MM session about increasing SCSI disk
      probing concurrency, the problems with the current probing approach are as
      follows:
      
      - The driver core is unaware of asynchronous SCSI LUN probing.
        wait_for_device_probe() waits for all asynchronous probes except
        asynchronous SCSI disk probes.
      
      - There is unnecessary serialization between sd_probe() and sd_remove().
        This can lead to a deadlock.
      
      Hence this patch that modifies the sd driver such that it uses the driver
      core framework for asynchronous probing. The async domains and
      get_device()/put_device() pairs that became superfluous due to this change
      are removed.
      
      This patch does not affect the time needed for loading the scsi_debug
      kernel module with parameters delay=0 and max_luns=256.
      
      This patch depends on commit ef0ff683
      
       ("driver core: Probe devices
      asynchronously instead of the driver") that went upstream in kernel version
      v5.1-rc1.
      
      Cc: Lee Duncan <lduncan@suse.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      21e6ba3f
  18. 26 Feb, 2019 1 commit
  19. 13 Feb, 2019 1 commit
    • James Bottomley's avatar
      scsi: sd: fix entropy gathering for most rotational disks · e4a05698
      James Bottomley authored
      
      
      The problem is that the default for MQ is not to gather entropy, whereas
      the default for the legacy queue was always to gather it.  The original
      attempt to fix entropy gathering for rotational disks under MQ added an
      else branch in sd_read_block_characteristics().  Unfortunately, the entire
      check isn't reached if the device has no characteristics VPD page.  Since
      this page was only introduced in SBC-3 and its optional anyway, most less
      expensive rotational disks don't have one, meaning they all stopped
      gathering entropy when we made MQ the default.  In a wholly unrelated
      change, openssl and openssh won't function until the random number
      generator is initialised, meaning lots of people have been seeing large
      delays before they could log into systems with default MQ kernels due to
      this lack of entropy, because it now can take tens of minutes to initialise
      the kernel random number generator.
      
      The fix is to set the non-rotational and add-randomness flags
      unconditionally early on in the disk initialization path, so they can be
      reset only if the device actually reports being non-rotational via the VPD
      page.
      Reported-by: default avatarMikael Pettersson <mikpelinux@gmail.com>
      Fixes: 83e32a59
      
       ("scsi: sd: Contribute to randomness when running rotational device")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
      Reviewed-by: default avatarJens Axboe <axboe@kernel.dk>
      Reviewed-by: default avatarXuewei Zhang <xueweiz@google.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e4a05698
  20. 12 Feb, 2019 1 commit
  21. 06 Feb, 2019 1 commit
  22. 05 Feb, 2019 1 commit
  23. 29 Jan, 2019 1 commit
  24. 23 Jan, 2019 6 commits
  25. 09 Jan, 2019 2 commits
    • John Garry's avatar
      scsi: sd: Make protection lookup tables static and relocate functions · 082c2cd2
      John Garry authored
      
      
      Currently the protection lookup tables in sd_prot_flag_mask() and
      sd_prot_op() are declared as non-static. As such, they will be rebuilt for
      each respective function call.
      
      Optimise by making them static.
      
      This saves ~100B object code for sd.c:
      
      Before:
         text	   data	    bss	    dec	    hex	filename
        25403	   1024	     16	  26443	   674b	drivers/scsi/sd.o
      
      After:
        text	   data	    bss	    dec	    hex	filename
        25299	   1024	     16	  26339	   66e3	drivers/scsi/sd.o
      
      In addition, since those same functions are declared in sd.h, but each are
      only referenced in sd.c, relocate them to that same c file.
      
      The inline specifier is dropped also, since gcc should be able to make the
      decision to inline.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      082c2cd2
    • Ivan Mironov's avatar
      scsi: sd: Fix cache_type_store() · 44759979
      Ivan Mironov authored
      
      
      Changing of caching mode via /sys/devices/.../scsi_disk/.../cache_type may
      fail if device responds to MODE SENSE command with DPOFUA flag set, and
      then checks this flag to be not set on MODE SELECT command.
      
      In this scenario, when trying to change cache_type, write always fails:
      
      	# echo "none" >cache_type
      	bash: echo: write error: Invalid argument
      
      And following appears in dmesg:
      
      	[13007.865745] sd 1:0:1:0: [sda] Sense Key : Illegal Request [current]
      	[13007.865753] sd 1:0:1:0: [sda] Add. Sense: Invalid field in parameter list
      
      From SBC-4 r15, 6.5.1 "Mode pages overview", description of DEVICE-SPECIFIC
      PARAMETER field in the mode parameter header:
      	...
      	The write protect (WP) bit for mode data sent with a MODE SELECT
      	command shall be ignored by the device server.
      	...
      	The DPOFUA bit is reserved for mode data sent with a MODE SELECT
      	command.
      	...
      
      The remaining bits in the DEVICE-SPECIFIC PARAMETER byte are also reserved
      and shall be set to zero.
      
      [mkp: shuffled commentary to commit description]
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarIvan Mironov <mironov.ivan@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      44759979
  26. 13 Dec, 2018 1 commit
    • Jens Axboe's avatar
      scsi: sd: use mempool for discard special page · 61cce6f6
      Jens Axboe authored
      
      
      When boxes are run near (or to) OOM, we have a problem with the discard
      page allocation in sd. If we fail allocating the special page, we return
      busy, and it'll get retried. But since ordering is honored for dispatch
      requests, we can keep retrying this same IO and failing. Behind that IO
      could be requests that want to free memory, but they never get the
      chance. This means you get repeated spews of traces like this:
      
      [1201401.625972] Call Trace:
      [1201401.631748]  dump_stack+0x4d/0x65
      [1201401.639445]  warn_alloc+0xec/0x190
      [1201401.647335]  __alloc_pages_slowpath+0xe84/0xf30
      [1201401.657722]  ? get_page_from_freelist+0x11b/0xb10
      [1201401.668475]  ? __alloc_pages_slowpath+0x2e/0xf30
      [1201401.679054]  __alloc_pages_nodemask+0x1f9/0x210
      [1201401.689424]  alloc_pages_current+0x8c/0x110
      [1201401.699025]  sd_setup_write_same16_cmnd+0x51/0x150
      [1201401.709987]  sd_init_command+0x49c/0xb70
      [1201401.719029]  scsi_setup_cmnd+0x9c/0x160
      [1201401.727877]  scsi_queue_rq+0x4d9/0x610
      [1201401.736535]  blk_mq_dispatch_rq_list+0x19a/0x360
      [1201401.747113]  blk_mq_sched_dispatch_requests+0xff/0x190
      [1201401.758844]  __blk_mq_run_hw_queue+0x95/0xa0
      [1201401.768653]  blk_mq_run_work_fn+0x2c/0x30
      [1201401.777886]  process_one_work+0x14b/0x400
      [1201401.787119]  worker_thread+0x4b/0x470
      [1201401.795586]  kthread+0x110/0x150
      [1201401.803089]  ? rescuer_thread+0x320/0x320
      [1201401.812322]  ? kthread_park+0x90/0x90
      [1201401.820787]  ? do_syscall_64+0x53/0x150
      [1201401.829635]  ret_from_fork+0x29/0x40
      
      Ensure that the discard page allocation has a mempool backing, so we
      know we can make progress.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      61cce6f6
  27. 10 Nov, 2018 1 commit