Skip to content
Snippets Groups Projects
  1. Mar 16, 2023
    • Eric Biggers's avatar
      blk-mq: release crypto keyslot before reporting I/O complete · 9cd1e566
      Eric Biggers authored
      
      Once all I/O using a blk_crypto_key has completed, filesystems can call
      blk_crypto_evict_key().  However, the block layer currently doesn't call
      blk_crypto_put_keyslot() until the request is being freed, which happens
      after upper layers have been told (via bio_endio()) the I/O has
      completed.  This causes a race condition where blk_crypto_evict_key()
      can see 'slot_refs != 0' without there being an actual bug.
      
      This makes __blk_crypto_evict_key() hit the
      'WARN_ON_ONCE(atomic_read(&slot->slot_refs) != 0)' and return without
      doing anything, eventually causing a use-after-free in
      blk_crypto_reprogram_all_keys().  (This is a very rare bug and has only
      been seen when per-file keys are being used with fscrypt.)
      
      There are two options to fix this: either release the keyslot before
      bio_endio() is called on the request's last bio, or make
      __blk_crypto_evict_key() ignore slot_refs.  Let's go with the first
      solution, since it preserves the ability to report bugs (via
      WARN_ON_ONCE) where a key is evicted while still in-use.
      
      Fixes: a892c8d5 ("block: Inline encryption support for blk-mq")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarNathan Huckleberry <nhuck@google.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20230315183907.53675-2-ebiggers@kernel.org
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      9cd1e566
  2. Mar 03, 2023
  3. Feb 17, 2023
  4. Feb 16, 2023
    • Ming Lei's avatar
      block: sync mixed merged request's failfast with 1st bio's · 3ce6a115
      Ming Lei authored
      
      We support mixed merge for requests/bios with different fastfail
      settings. When request fails, each time we only handle the portion
      with same failfast setting, then bios with failfast can be failed
      immediately, and bios without failfast can be retried.
      
      The idea is pretty good, but the current implementation has several
      defects:
      
      1) initially RA bio doesn't set failfast, however bio merge code
      doesn't consider this point, and just check its failfast setting for
      deciding if mixed merge is required. Fix this issue by adding helper
      of bio_failfast().
      
      2) when merging bio to request front, if this request is mixed
      merged, we have to sync request's faifast setting with 1st bio's
      failfast. Fix it by calling blk_update_mixed_merge().
      
      3) when merging bio to request back, if this request is mixed
      merged, we have to mark the bio as failfast, because blk_update_request
      simply updates request failfast with 1st bio's failfast. Fix
      it by calling blk_update_mixed_merge().
      
      Fixes one normal EXT4 READ IO failure issue, because it is observed
      that the normal READ IO is merged with RA IO, and the mixed merged
      request has different failfast setting with 1st bio's, so finally
      the normal READ IO doesn't get retried.
      
      Cc: Tejun Heo <tj@kernel.org>
      Fixes: 80a761fd ("block: implement mixed merge of different failfast requests")
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20230209125527.667004-1-ming.lei@redhat.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      3ce6a115
  5. Feb 15, 2023
  6. Jan 04, 2023
  7. Oct 25, 2022
  8. Aug 03, 2022
  9. Aug 02, 2022
  10. Jul 14, 2022
  11. Jul 06, 2022
  12. Jun 27, 2022
  13. Mar 15, 2022
  14. Mar 11, 2022
    • Jens Axboe's avatar
      block: ensure plug merging checks the correct queue at least once · 5b205071
      Jens Axboe authored
      
      Song reports that a RAID rebuild workload runs much slower recently,
      and it is seeing a lot less merging than it did previously. The reason
      is that a previous commit reduced the amount of work we do for plug
      merging. RAID rebuild interleaves requests between disks, so a last-entry
      check in plug merging always misses a merge opportunity since we always
      find a different disk than what we are looking for.
      
      Modify the logic such that it's still a one-hit cache, but ensure that
      we check enough to find the right target before giving up.
      
      Fixes: d38a9c04 ("block: only check previous entry for plug merge attempt")
      Reported-and-tested-by: default avatarSong Liu <song@kernel.org>
      Reviewed-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      5b205071
  15. Mar 07, 2022
  16. Feb 23, 2022
  17. Feb 17, 2022
    • Ming Lei's avatar
      block: throttle split bio in case of iops limit · 9f5ede3c
      Ming Lei authored
      
      Commit 111be883 ("block-throttle: avoid double charge") marks bio as
      BIO_THROTTLED unconditionally if __blk_throtl_bio() is called on this bio,
      then this bio won't be called into __blk_throtl_bio() any more. This way
      is to avoid double charge in case of bio splitting. It is reasonable for
      read/write throughput limit, but not reasonable for IOPS limit because
      block layer provides io accounting against split bio.
      
      Chunguang Xu has already observed this issue and fixed it in commit
      4f1e9630 ("blk-throtl: optimize IOPS throttle for large IO scenarios").
      However, that patch only covers bio splitting in __blk_queue_split(), and
      we have other kind of bio splitting, such as bio_split() &
      submit_bio_noacct() and other ways.
      
      This patch tries to fix the issue in one generic way by always charging
      the bio for iops limit in blk_throtl_bio(). This way is reasonable:
      re-submission & fast-cloned bio is charged if it is submitted to same
      disk/queue, and BIO_THROTTLED will be cleared if bio->bi_bdev is changed.
      
      This new approach can get much more smooth/stable iops limit compared with
      commit 4f1e9630 ("blk-throtl: optimize IOPS throttle for large IO
      scenarios") since that commit can't throttle current split bios actually.
      
      Also this way won't cause new double bio iops charge in
      blk_throtl_dispatch_work_fn() in which blk_throtl_bio() won't be called
      any more.
      
      Reported-by: default avatarNing Li <lining2020x@163.com>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Chunguang Xu <brookxu@tencent.com>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20220216044514.2903784-7-ming.lei@redhat.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      9f5ede3c
  18. Nov 29, 2021
  19. Nov 03, 2021
  20. Oct 20, 2021
  21. Oct 19, 2021
  22. Oct 18, 2021
Loading