1. 06 3月, 2019 10 次提交
    • M
      dm cache: add support for discard passdown to the origin device · de7180ff
      Mike Snitzer 提交于
      DM cache now defaults to passing discards down to the origin device.
      User may disable this using the "no_discard_passdown" feature when
      creating the cache device.
      
      If the cache's underlying origin device doesn't support discards then
      passdown is disabled (with warning).  Similarly, if the underlying
      origin device's max_discard_sectors is less than a cache block discard
      passdown will be disabled (this is required because sizing of the cache
      internal discard bitset depends on it).
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      de7180ff
    • H
      dm writecache: fix typo in name for writeback_wq · f87e033b
      Huaisheng Ye 提交于
      The workqueue's name should be "writecache-writeback" instead of
      "writecache-writeabck".
      Signed-off-by: NHuaisheng Ye <yehs1@lenovo.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      f87e033b
    • H
      dm: add support to directly boot to a mapped device · 6bbc923d
      Helen Koike 提交于
      Add a "create" module parameter, which allows device-mapper targets to
      be configured at boot time. This enables early use of DM targets in the
      boot process (as the root device or otherwise) without the need of an
      initramfs.
      
      The syntax used in the boot param is based on the concise format from
      the dmsetup tool to follow the rule of least surprise:
      
      	dmsetup table --concise /dev/mapper/lroot
      
      Which is:
      	dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
      
      Where,
      	<name>		::= The device name.
      	<uuid>		::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ""
      	<minor>		::= The device minor number | ""
      	<flags>		::= "ro" | "rw"
      	<table>		::= <start_sector> <num_sectors> <target_type> <target_args>
      	<target_type>	::= "verity" | "linear" | ...
      
      For example, the following could be added in the boot parameters:
      dm-mod.create="lroot,,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" root=/dev/dm-0
      
      Only the targets that were tested are allowed and the ones that don't
      change any block device when the device is create as read-only. For
      example, mirror and cache targets are not allowed. The rationale behind
      this is that if the user makes a mistake, choosing the wrong device to
      be the mirror or the cache can corrupt data.
      
      The only targets initially allowed are:
      * crypt
      * delay
      * linear
      * snapshot-origin
      * striped
      * verity
      Co-developed-by: NWill Drewry <wad@chromium.org>
      Co-developed-by: NKees Cook <keescook@chromium.org>
      Co-developed-by: NEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: NHelen Koike <helen.koike@collabora.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      6bbc923d
    • J
      dm thin: add sanity checks to thin-pool and external snapshot creation · 70de2cbd
      Jason Cai (Xiang Feng) 提交于
      Invoking dm_get_device() twice on the same device path with different
      modes is dangerous.  Because in that case, upgrade_mode() will alloc a
      new 'dm_dev' and free the old one, which may be referenced by a previous
      caller.  Dereferencing the dangling pointer will trigger kernel NULL
      pointer dereference.
      
      The following two cases can reproduce this issue.  Actually, they are
      invalid setups that must be disallowed, e.g.:
      
      1. Creating a thin-pool with read_only mode, and the same device as
      both metadata and data.
      
      dmsetup create thinp --table \
          "0 41943040 thin-pool /dev/vdb /dev/vdb 128 0 1 read_only"
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000080
      ...
      Call Trace:
       new_read+0xfb/0x110 [dm_bufio]
       dm_bm_read_lock+0x43/0x190 [dm_persistent_data]
       ? kmem_cache_alloc_trace+0x15c/0x1e0
       __create_persistent_data_objects+0x65/0x3e0 [dm_thin_pool]
       dm_pool_metadata_open+0x8c/0xf0 [dm_thin_pool]
       pool_ctr.cold.79+0x213/0x913 [dm_thin_pool]
       ? realloc_argv+0x50/0x70 [dm_mod]
       dm_table_add_target+0x14e/0x330 [dm_mod]
       table_load+0x122/0x2e0 [dm_mod]
       ? dev_status+0x40/0x40 [dm_mod]
       ctl_ioctl+0x1aa/0x3e0 [dm_mod]
       dm_ctl_ioctl+0xa/0x10 [dm_mod]
       do_vfs_ioctl+0xa2/0x600
       ? handle_mm_fault+0xda/0x200
       ? __do_page_fault+0x26c/0x4f0
       ksys_ioctl+0x60/0x90
       __x64_sys_ioctl+0x16/0x20
       do_syscall_64+0x55/0x150
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      2. Creating a external snapshot using the same thin-pool device.
      
      dmsetup create thinp --table \
          "0 41943040 thin-pool /dev/vdc /dev/vdb 128 0 2 ignore_discard"
      dmsetup message /dev/mapper/thinp 0 "create_thin 0"
      dmsetup create snap --table \
                  "0 204800 thin /dev/mapper/thinp 0 /dev/mapper/thinp"
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
      ...
      Call Trace:
      ? __alloc_pages_nodemask+0x13c/0x2e0
      retrieve_status+0xa5/0x1f0 [dm_mod]
      ? dm_get_live_or_inactive_table.isra.7+0x20/0x20 [dm_mod]
       table_status+0x61/0xa0 [dm_mod]
       ctl_ioctl+0x1aa/0x3e0 [dm_mod]
       dm_ctl_ioctl+0xa/0x10 [dm_mod]
       do_vfs_ioctl+0xa2/0x600
       ksys_ioctl+0x60/0x90
       ? ksys_write+0x4f/0xb0
       __x64_sys_ioctl+0x16/0x20
       do_syscall_64+0x55/0x150
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Signed-off-by: NJason Cai (Xiang Feng) <jason.cai@linux.alibaba.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      70de2cbd
    • C
      dm block manager: remove redundant unlikely annotation · 5941c621
      Chengguang Xu 提交于
      unlikely has already included in IS_ERR(),
      so just remove redundant unlikely annotation.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      5941c621
    • C
      dm verity fec: remove redundant unlikely annotation · 821b40da
      Chengguang Xu 提交于
      unlikely has already included in IS_ERR(),
      so just remove redundant unlikely annotation.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      821b40da
    • C
      dm integrity: remove redundant unlikely annotation · 5e3d0e37
      Chengguang Xu 提交于
      unlikely has already included in IS_ERR(),
      so just remove redundant unlikely annotation.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      5e3d0e37
    • M
      dm: always call blk_queue_split() in dm_process_bio() · effd58c9
      Mike Snitzer 提交于
      Do not just call blk_queue_split() if the bio is_abnormal_io().
      
      Fixes: 568c73a3 ("dm: update dm_process_bio() to split bio if in ->make_request_fn()")
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      effd58c9
    • G
      dm switch: use struct_size() in kzalloc() · d2832376
      Gustavo A. R. Silva 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      d2832376
    • M
      dm: remove unused _rq_tio_cache and _rq_cache · e689fbab
      Mike Snitzer 提交于
      Also move dm_rq_target_io structure definition from dm-rq.h to dm-rq.c
      
      Fixes: 6a23e05c ("dm: remove legacy request-based IO path")
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      e689fbab
  2. 21 2月, 2019 1 次提交
  3. 20 2月, 2019 1 次提交
  4. 15 2月, 2019 1 次提交
    • N
      dm thin: fix bug where bio that overwrites thin block ignores FUA · 4ae280b4
      Nikos Tsironis 提交于
      When provisioning a new data block for a virtual block, either because
      the block was previously unallocated or because we are breaking sharing,
      if the whole block of data is being overwritten the bio that triggered
      the provisioning is issued immediately, skipping copying or zeroing of
      the data block.
      
      When this bio completes the new mapping is inserted in to the pool's
      metadata by process_prepared_mapping(), where the bio completion is
      signaled to the upper layers.
      
      This completion is signaled without first committing the metadata.  If
      the bio in question has the REQ_FUA flag set and the system crashes
      right after its completion and before the next metadata commit, then the
      write is lost despite the REQ_FUA flag requiring that I/O completion for
      this request must only be signaled after the data has been committed to
      non-volatile storage.
      
      Fix this by deferring the completion of overwrite bios, with the REQ_FUA
      flag set, until after the metadata has been committed.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNikos Tsironis <ntsironis@arrikto.com>
      Acked-by: NJoe Thornber <ejt@redhat.com>
      Acked-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      4ae280b4
  5. 12 2月, 2019 1 次提交
    • M
      dm crypt: don't overallocate the integrity tag space · ff0c129d
      Mikulas Patocka 提交于
      bio_sectors() returns the value in the units of 512-byte sectors (no
      matter what the real sector size of the device).  dm-crypt multiplies
      bio_sectors() by on_disk_tag_size to calculate the space allocated for
      integrity tags.  If dm-crypt is running with sector size larger than
      512b, it allocates more data than is needed.
      
      Device Mapper trims the extra space when passing the bio to
      dm-integrity, so this bug didn't result in any visible misbehavior.
      But it must be fixed to avoid wasteful memory allocation for the block
      integrity payload.
      
      Fixes: ef43aa38 ("dm crypt: add cryptographic data integrity protection (authenticated encryption)")
      Cc: stable@vger.kernel.org # 4.12+
      Reported-by: NMilan Broz <mbroz@redhat.com>
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      ff0c129d
  6. 08 2月, 2019 2 次提交
  7. 07 2月, 2019 24 次提交