1. 11 May, 2022 1 commit
    • Mike Snitzer's avatar
      dm: pass NULL bdev to bio_alloc_clone · ca522482
      Mike Snitzer authored
      Most DM targets will remap the clone bio passed to their ->map
      function using bio_set_bdev(). So this change to pass NULL bdev to
      bio_alloc_clone avoids clone-time work that sets up resources for a
      bdev association that will not be used in practice (e.g. clone issued
      to underlying device will not use DM device's blk-cgroups resources).
      
      But clone->bi_bdev is still initialized following bio_alloc_clone to
      preserve DM target expectations that clone->bi_bdev will be set.
      Follow-up work is needed to audit DM targets to remove accesses to a
      clone->bi_bdev that the target didn't initialize with bio_set_dev().
      
      Depends-on: 7ecc56c6 ("block: allow passing a NULL bdev to bio_alloc_clone/bio_init_clone")
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      ca522482
  2. 09 May, 2022 5 commits
    • Guo Zhengkui's avatar
      dm cache metadata: remove unnecessary variable in __dump_mapping · d254c369
      Guo Zhengkui authored
      Fix the following coccicheck warning:
      
      drivers/md/dm-cache-metadata.c:1512:5-6: Unneeded variable: "r".
      Return "0" on line 1520.
      Signed-off-by: default avatarGuo Zhengkui <guozhengkui@vivo.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      d254c369
    • Gabriel Krisman Bertazi's avatar
      dm mpath: provide high-resolution timer to HST for bio-based · c06dfd12
      Gabriel Krisman Bertazi authored
      The precision loss of reading IO start_time with jiffies_to_nsecs
      instead of using a high resolution timer degrades HST path prediction
      for BIO-based mpath on high load workloads.
      
      Below, I show the utilization percentage of a 10 disk multipath with
      asymmetrical disk access cost, while being exercised by a randwrite FIO
      benchmark with high submission queue depth (depth=64).  It is possible
      to see that the HST path selection degrades heavily for high-iops in
      BIO-mpath, underutilizing the slower paths way beyond expected.  This
      seems to be caused by the start_time truncation, which makes some IO to
      seem much slower than it actually is.  In this scenario ST outperforms
      HST for bio-mpath, but not for mq-mpath, which already uses ktime_get_ns().
      
      The third column shows utilization with this patch applied.  It is easy
      to see that now HST prediction is much closer to the ideal distribution
      (calculated considering the real cost of each path).
      
      |     |   ST | HST (orig) | HST(ktime) | Best |
      | sdd | 0.17 |       0.20 |       0.17 | 0.18 |
      | sde | 0.17 |       0.20 |       0.17 | 0.18 |
      | sdf | 0.17 |       0.20 |       0.17 | 0.18 |
      | sdg | 0.06 |       0.00 |       0.06 | 0.04 |
      | sdh | 0.03 |       0.00 |       0.03 | 0.02 |
      | sdi | 0.03 |       0.00 |       0.03 | 0.02 |
      | sdj | 0.02 |       0.00 |       0.01 | 0.01 |
      | sdk | 0.02 |       0.00 |       0.01 | 0.01 |
      | sdl | 0.17 |       0.20 |       0.17 | 0.18 |
      | sdm | 0.17 |       0.20 |       0.17 | 0.18 |
      
      This issue was originally discussed [1] when we first merged HST, and
      this patch was left as a low hanging fruit to be solved later.
      
      Regarding the implementation, as suggested by Mike in that mail thread,
      in order to avoid the overhead of ktime_get_ns for other selectors, this
      patch adds a flag for the selector code to request the high-resolution
      timer.
      
      I tested this using the same benchmark used in the original HST submission.
      
      Full test and benchmark scripts are available here:
      
        https://people.collabora.com/~krisman/HST-BIO-MPATH/
      
      [1] https://lore.kernel.org/lkml/85tv0am9de.fsf@collabora.com/T/Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
      [snitzer: cleaned up various implementation details]
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      c06dfd12
    • Mikulas Patocka's avatar
      dm crypt: make printing of the key constant-time · 567dd8f3
      Mikulas Patocka authored
      The device mapper dm-crypt target is using scnprintf("%02x", cc->key[i]) to
      report the current key to userspace. However, this is not a constant-time
      operation and it may leak information about the key via timing, via cache
      access patterns or via the branch predictor.
      
      Change dm-crypt's key printing to use "%c" instead of "%02x". Also
      introduce hex2asc() that carefully avoids any branching or memory
      accesses when converting a number in the range 0 ... 15 to an ascii
      character.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Tested-by: default avatarMilan Broz <gmazyland@gmail.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      567dd8f3
    • Dan Carpenter's avatar
      dm integrity: fix error code in dm_integrity_ctr() · d3f2a14b
      Dan Carpenter authored
      The "r" variable shadows an earlier "r" that has function scope.  It
      means that we accidentally return success instead of an error code.
      Smatch has a warning for this:
      
      	drivers/md/dm-integrity.c:4503 dm_integrity_ctr()
      	warn: missing error code 'r'
      
      Fixes: 7eada909 ("dm: add integrity target")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      d3f2a14b
    • Mikulas Patocka's avatar
      dm stats: add cond_resched when looping over entries · bfe2b014
      Mikulas Patocka authored
      dm-stats can be used with a very large number of entries (it is only
      limited by 1/4 of total system memory), so add rescheduling points to
      the loops that iterate over the entries.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      bfe2b014
  3. 05 May, 2022 23 commits
  4. 02 May, 2022 11 commits