1. 25 1月, 2021 1 次提交
    • C
      block: add a hard-readonly flag to struct gendisk · 52f019d4
      Christoph Hellwig 提交于
      Commit 20bd1d02 ("scsi: sd: Keep disk read-only when re-reading
      partition") addressed a long-standing problem with user read-only
      policy being overridden as a result of a device-initiated revalidate.
      The commit has since been reverted due to a regression that left some
      USB devices read-only indefinitely.
      
      To fix the underlying problems with revalidate we need to keep track
      of hardware state and user policy separately.
      
      The gendisk has been updated to reflect the current hardware state set
      by the device driver. This is done to allow returning the device to
      the hardware state once the user clears the BLKROSET flag.
      
      The resulting semantics are as follows:
      
       - If BLKROSET sets a given partition read-only, that partition will
         remain read-only even if the underlying storage stack initiates a
         revalidate. However, the BLKRRPART ioctl will cause the partition
         table to be dropped and any user policy on partitions will be lost.
      
       - If BLKROSET has not been set, both the whole disk device and any
         partitions will reflect the current write-protect state of the
         underlying device.
      
      Based on a patch from Martin K. Petersen <martin.petersen@oracle.com>.
      Reported-by: NOleksii Kurochko <olkuroch@cisco.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201221Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      52f019d4
  2. 10 12月, 2020 3 次提交
  3. 05 12月, 2020 2 次提交
  4. 02 12月, 2020 7 次提交
  5. 14 10月, 2020 1 次提交
  6. 09 10月, 2020 1 次提交
  7. 06 10月, 2020 1 次提交
  8. 25 9月, 2020 3 次提交
  9. 12 9月, 2020 1 次提交
  10. 04 9月, 2020 1 次提交
  11. 02 9月, 2020 4 次提交
  12. 01 9月, 2020 1 次提交
  13. 08 7月, 2020 1 次提交
  14. 03 7月, 2020 1 次提交
  15. 01 7月, 2020 8 次提交
  16. 29 6月, 2020 1 次提交
  17. 24 6月, 2020 3 次提交
    • L
      block: create the request_queue debugfs_dir on registration · 85e0cbbb
      Luis Chamberlain 提交于
      We were only creating the request_queue debugfs_dir only
      for make_request block drivers (multiqueue), but never for
      request-based block drivers. We did this as we were only
      creating non-blktrace additional debugfs files on that directory
      for make_request drivers. However, since blktrace *always* creates
      that directory anyway, we special-case the use of that directory
      on blktrace. Other than this being an eye-sore, this exposes
      request-based block drivers to the same debugfs fragile
      race that used to exist with make_request block drivers
      where if we start adding files onto that directory we can later
      run a race with a double removal of dentries on the directory
      if we don't deal with this carefully on blktrace.
      
      Instead, just simplify things by always creating the request_queue
      debugfs_dir on request_queue registration. Rename the mutex also to
      reflect the fact that this is used outside of the blktrace context.
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      85e0cbbb
    • L
      block: revert back to synchronous request_queue removal · e8c7d14a
      Luis Chamberlain 提交于
      Commit dc9edc44 ("block: Fix a blk_exit_rl() regression") merged on
      v4.12 moved the work behind blk_release_queue() into a workqueue after a
      splat floated around which indicated some work on blk_release_queue()
      could sleep in blk_exit_rl(). This splat would be possible when a driver
      called blk_put_queue() or blk_cleanup_queue() (which calls blk_put_queue()
      as its final call) from an atomic context.
      
      blk_put_queue() decrements the refcount for the request_queue kobject, and
      upon reaching 0 blk_release_queue() is called. Although blk_exit_rl() is
      now removed through commit db6d9952 ("block: remove request_list code")
      on v5.0, we reserve the right to be able to sleep within
      blk_release_queue() context.
      
      The last reference for the request_queue must not be called from atomic
      context. *When* the last reference to the request_queue reaches 0 varies,
      and so let's take the opportunity to document when that is expected to
      happen and also document the context of the related calls as best as
      possible so we can avoid future issues, and with the hopes that the
      synchronous request_queue removal sticks.
      
      We revert back to synchronous request_queue removal because asynchronous
      removal creates a regression with expected userspace interaction with
      several drivers. An example is when removing the loopback driver, one
      uses ioctls from userspace to do so, but upon return and if successful,
      one expects the device to be removed. Likewise if one races to add another
      device the new one may not be added as it is still being removed. This was
      expected behavior before and it now fails as the device is still present
      and busy still. Moving to asynchronous request_queue removal could have
      broken many scripts which relied on the removal to have been completed if
      there was no error. Document this expectation as well so that this
      doesn't regress userspace again.
      
      Using asynchronous request_queue removal however has helped us find
      other bugs. In the future we can test what could break with this
      arrangement by enabling CONFIG_DEBUG_KOBJECT_RELEASE.
      
      While at it, update the docs with the context expectations for the
      request_queue / gendisk refcount decrement, and make these
      expectations explicit by using might_sleep().
      
      Fixes: dc9edc44 ("block: Fix a blk_exit_rl() regression")
      Suggested-by: NNicolai Stange <nstange@suse.de>
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NBart Van Assche <bvanassche@acm.org>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Omar Sandoval <osandov@fb.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Nicolai Stange <nstange@suse.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: yu kuai <yukuai3@huawei.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      e8c7d14a
    • L
      block: clarify context for refcount increment helpers · 763b5892
      Luis Chamberlain 提交于
      Let us clarify the context under which the helpers to increment the
      refcount for the gendisk and request_queue can be called under. We
      make this explicit on the places where we may sleep with might_sleep().
      
      We don't address the decrement context yet, as that needs some extra
      work and fixes, but will be addressed in the next patch.
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      763b5892