Merge tag 'for-5.11/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Dec 2020 21:27:21 +0000 (13:27 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Dec 2020 21:27:21 +0000 (13:27 -0800)
Pull device mapper updates from Mike Snitzer:

 - Add DM verity support for signature verification with 2nd keyring

 - Fix DM verity to skip verity work if IO completes with error while
   system is shutting down

 - Add new DM multipath "IO affinity" path selector that maps IO
   destined to a given path to a specific CPU based on user provided
   mapping

 - Rename DM multipath path selector source files to have "dm-ps" prefix

 - Add REQ_NOWAIT support to some other simple DM targets that don't
   block in more elaborate ways waiting for IO

 - Export DM crypt's kcryptd workqueue via sysfs (WQ_SYSFS)

 - Fix error return code in DM's target_message() if empty message is
   received

 - A handful of other small cleanups

* tag 'for-5.11/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm cache: simplify the return expression of load_mapping()
  dm ebs: avoid double unlikely() notation when using IS_ERR()
  dm verity: skip verity work if I/O error when system is shutting down
  dm crypt: export sysfs of kcryptd workqueue
  dm ioctl: fix error return code in target_message
  dm crypt: Constify static crypt_iv_operations
  dm: add support for REQ_NOWAIT to various targets
  dm: rename multipath path selector source files to have "dm-ps" prefix
  dm mpath: add IO affinity path selector
  dm verity: Add support for signature verification with 2nd keyring
  dm: remove unnecessary current->bio_list check when submitting split bio

1  2 
Documentation/admin-guide/device-mapper/verity.rst
drivers/md/dm.c

@@@ -69,7 -69,7 +69,7 @@@ Construction Parameter
  
  <#opt_params>
      Number of optional parameters. If there are no optional parameters,
 -    the optional paramaters section can be skipped or #opt_params can be zero.
 +    the optional parameters section can be skipped or #opt_params can be zero.
      Otherwise #opt_params is the number of following arguments.
  
      Example of optional parameters section:
@@@ -134,7 -134,12 +134,12 @@@ root_hash_sig_key_desc <key_description
      the pkcs7 signature of the roothash. The pkcs7 signature is used to validate
      the root hash during the creation of the device mapper block device.
      Verification of roothash depends on the config DM_VERITY_VERIFY_ROOTHASH_SIG
-     being set in the kernel.
+     being set in the kernel.  The signatures are checked against the builtin
+     trusted keyring by default, or the secondary trusted keyring if
+     DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING is set.  The secondary
+     trusted keyring includes by default the builtin trusted keyring, and it can
+     also gain new certificates at run time if they are signed by a certificate
+     already in the secondary trusted keyring.
  
  Theory of operation
  ===================
diff --combined drivers/md/dm.c
@@@ -570,10 -570,7 +570,10 @@@ static int dm_blk_ioctl(struct block_de
                }
        }
  
 -      r =  __blkdev_driver_ioctl(bdev, mode, cmd, arg);
 +      if (!bdev->bd_disk->fops->ioctl)
 +              r = -ENOTTY;
 +      else
 +              r = bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
  out:
        dm_unprepare_ioctl(md, srcu_idx);
        return r;
@@@ -1277,7 -1274,8 +1277,7 @@@ static blk_qc_t __map_bio(struct dm_tar
                break;
        case DM_MAPIO_REMAPPED:
                /* the bio has been remapped so dispatch it */
 -              trace_block_bio_remap(clone->bi_disk->queue, clone,
 -                                    bio_dev(io->orig_bio), sector);
 +              trace_block_bio_remap(clone, bio_dev(io->orig_bio), sector);
                ret = submit_bio_noacct(clone);
                break;
        case DM_MAPIO_KILL:
@@@ -1422,12 -1420,18 +1422,12 @@@ static int __send_empty_flush(struct cl
         */
        bio_init(&flush_bio, NULL, 0);
        flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
 +      flush_bio.bi_disk = ci->io->md->disk;
 +      bio_associate_blkg(&flush_bio);
 +
        ci->bio = &flush_bio;
        ci->sector_count = 0;
  
 -      /*
 -       * Empty flush uses a statically initialized bio, as the base for
 -       * cloning.  However, blkg association requires that a bdev is
 -       * associated with a gendisk, which doesn't happen until the bdev is
 -       * opened.  So, blkg association is done at issue time of the flush
 -       * rather than when the device is created in alloc_dev().
 -       */
 -      bio_set_dev(ci->bio, ci->io->md->bdev);
 -
        BUG_ON(bio_has_data(ci->bio));
        while ((ti = dm_table_get_target(ci->map, target_nr++)))
                __send_duplicate_bios(ci, ti, ti->num_flush_bios, NULL);
@@@ -1586,7 -1590,7 +1586,7 @@@ static blk_qc_t __split_and_process_bio
                ci.sector_count = bio_sectors(bio);
                while (ci.sector_count && !error) {
                        error = __split_and_process_non_flush(&ci);
-                       if (current->bio_list && ci.sector_count && !error) {
+                       if (ci.sector_count && !error) {
                                /*
                                 * Remainder must be passed to submit_bio_noacct()
                                 * so that it gets handled *after* bios already submitted
                                 * (by eliminating DM's splitting and just using bio_split)
                                 */
                                part_stat_lock();
 -                              __dm_part_stat_sub(&dm_disk(md)->part0,
 +                              __dm_part_stat_sub(dm_disk(md)->part0,
                                                   sectors[op_stat_group(bio_op(bio))], ci.sector_count);
                                part_stat_unlock();
  
                                bio_chain(b, bio);
 -                              trace_block_split(md->queue, b, bio->bi_iter.bi_sector);
 +                              trace_block_split(b, bio->bi_iter.bi_sector);
                                ret = submit_bio_noacct(bio);
                                break;
                        }
@@@ -1744,6 -1748,11 +1744,6 @@@ static void cleanup_mapped_device(struc
  
        cleanup_srcu_struct(&md->io_barrier);
  
 -      if (md->bdev) {
 -              bdput(md->bdev);
 -              md->bdev = NULL;
 -      }
 -
        mutex_destroy(&md->suspend_lock);
        mutex_destroy(&md->type_lock);
        mutex_destroy(&md->table_devices_lock);
@@@ -1835,6 -1844,10 +1835,6 @@@ static struct mapped_device *alloc_dev(
        if (!md->wq)
                goto bad;
  
 -      md->bdev = bdget_disk(md->disk, 0);
 -      if (!md->bdev)
 -              goto bad;
 -
        dm_stats_init(&md->stats);
  
        /* Populate the mapping, nobody knows we exist yet */
@@@ -1959,7 -1972,8 +1959,7 @@@ static struct dm_table *__bind(struct m
        if (size != dm_get_size(md))
                memset(&md->geometry, 0, sizeof(md->geometry));
  
 -      set_capacity(md->disk, size);
 -      bd_set_nr_sectors(md->bdev, size);
 +      set_capacity_and_notify(md->disk, size);
  
        dm_table_event_callback(t, event_callback, md);
  
@@@ -2242,7 -2256,7 +2242,7 @@@ EXPORT_SYMBOL_GPL(dm_put)
  static bool md_in_flight_bios(struct mapped_device *md)
  {
        int cpu;
 -      struct hd_struct *part = &dm_disk(md)->part0;
 +      struct block_device *part = dm_disk(md)->part0;
        long sum = 0;
  
        for_each_possible_cpu(cpu) {
@@@ -2377,19 -2391,27 +2377,19 @@@ static int lock_fs(struct mapped_devic
  {
        int r;
  
 -      WARN_ON(md->frozen_sb);
 -
 -      md->frozen_sb = freeze_bdev(md->bdev);
 -      if (IS_ERR(md->frozen_sb)) {
 -              r = PTR_ERR(md->frozen_sb);
 -              md->frozen_sb = NULL;
 -              return r;
 -      }
 -
 -      set_bit(DMF_FROZEN, &md->flags);
 +      WARN_ON(test_bit(DMF_FROZEN, &md->flags));
  
 -      return 0;
 +      r = freeze_bdev(md->disk->part0);
 +      if (!r)
 +              set_bit(DMF_FROZEN, &md->flags);
 +      return r;
  }
  
  static void unlock_fs(struct mapped_device *md)
  {
        if (!test_bit(DMF_FROZEN, &md->flags))
                return;
 -
 -      thaw_bdev(md->bdev, md->frozen_sb);
 -      md->frozen_sb = NULL;
 +      thaw_bdev(md->disk->part0);
        clear_bit(DMF_FROZEN, &md->flags);
  }