Pull device mapper fixes from Mike Snitzer: - Fix dm core to use more efficient bio_split() instead of bio_clone_bioset(). Also fixes splitting bio that has integrity payload. - Three fixes related to properly validating DAX capabilities of a stacked DM device that will advertise DAX support. - Update DM writecache target to use 2-factor allocator arguments. Kees says this is the last related change for 4.18. - Fix DM zoned target to use GFP_NOIO to avoid triggering reclaim during IO submission (caught by lockdep). - Fix DM thinp to gracefully recover from running out of data space while a previous async discard completes (whereby freeing space). - Fix DM thinp's metadata transaction commit to avoid needless work. * tag 'for-4.18/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm: prevent DAX mounts if not supported dax: check for QUEUE_FLAG_DAX in bdev_dax_supported() pmem: only set QUEUE_FLAG_DAX for fsdax mode dm thin: handle running out of data space vs concurrent discard dm raid: don't use 'const' in function return dm zoned: avoid triggering reclaim from inside dmz_map() dm writecache: use 2-factor allocator arguments dm thin metadata: remove needless work from __commit_transaction dm: use bio_split() when splitting out the already processed bio
Unified · Split
| @@ -86,6 +86,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) · 85 unmodified lines | |||
| 86 | { | 86 | { |
| 87 | struct dax_device *dax_dev; | 87 | struct dax_device *dax_dev; |
| 88 | bool dax_enabled = false; | 88 | bool dax_enabled = false; |
| 89 | struct request_queue *q; | ||
| 89 | pgoff_t pgoff; | 90 | pgoff_t pgoff; |
| 90 | int err, id; | 91 | int err, id; |
| 91 | void *kaddr; | 92 | void *kaddr; |
| @@ -99,6 +100,13 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) · 7 unmodified lines | |||
| 99 | return false; | 100 | return false; |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 103 | q = bdev_get_queue(bdev); | ||
| 104 | if (!q || !blk_queue_dax(q)) { | ||
| 105 | pr_debug("%s: error: request queue doesn't support dax\n", | ||
| 106 | bdevname(bdev, buf)); | ||
| 107 | return false; | ||
| 108 | } | ||
| 109 | |||
| 102 | err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); | 110 | err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); |
| 103 | if (err) { | 111 | if (err) { |
| 104 | pr_debug("%s: error: unaligned partition for dax\n", | 112 | pr_debug("%s: error: unaligned partition for dax\n", |
| @@ -588,7 +588,7 @@ static const char *raid10_md_layout_to_format(int layout) · 587 unmodified lines | |||
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | /* Return md raid10 algorithm for @name */ | 590 | /* Return md raid10 algorithm for @name */ |
| 591 | static const int raid10_name_to_format(const char *name) | 591 | static int raid10_name_to_format(const char *name) |
| 592 | { | 592 | { |
| 593 | if (!strcasecmp(name, "near")) | 593 | if (!strcasecmp(name, "near")) |
| 594 | return ALGORITHM_RAID10_NEAR; | 594 | return ALGORITHM_RAID10_NEAR; |
| @@ -885,9 +885,7 @@ EXPORT_SYMBOL_GPL(dm_table_set_type); · 884 unmodified lines | |||
| 885 | static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, | 885 | static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, |
| 886 | sector_t start, sector_t len, void *data) | 886 | sector_t start, sector_t len, void *data) |
| 887 | { | 887 | { |
| 888 | struct request_queue *q = bdev_get_queue(dev->bdev); | 888 | return bdev_dax_supported(dev->bdev, PAGE_SIZE); |
| 889 | |||
| 890 | return q && blk_queue_dax(q); | ||
| 891 | } | 889 | } |
| 892 | 890 | ||
| 893 | static bool dm_table_supports_dax(struct dm_table *t) | 891 | static bool dm_table_supports_dax(struct dm_table *t) |
| @@ -1907,6 +1905,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, · 1013 unmodified lines | |||
| 1907 | 1905 | ||
| 1908 | if (dm_table_supports_dax(t)) | 1906 | if (dm_table_supports_dax(t)) |
| 1909 | blk_queue_flag_set(QUEUE_FLAG_DAX, q); | 1907 | blk_queue_flag_set(QUEUE_FLAG_DAX, q); |
| 1908 | else | ||
| 1909 | blk_queue_flag_clear(QUEUE_FLAG_DAX, q); | ||
| 1910 | |||
| 1910 | if (dm_table_supports_dax_write_cache(t)) | 1911 | if (dm_table_supports_dax_write_cache(t)) |
| 1911 | dax_write_cache(t->md->dax_dev, true); | 1912 | dax_write_cache(t->md->dax_dev, true); |
| 1912 | 1913 | ||
| @@ -776,7 +776,6 @@ static int __write_changed_details(struct dm_pool_metadata *pmd) · 775 unmodified lines | |||
| 776 | static int __commit_transaction(struct dm_pool_metadata *pmd) | 776 | static int __commit_transaction(struct dm_pool_metadata *pmd) |
| 777 | { | 777 | { |
| 778 | int r; | 778 | int r; |
| 779 | size_t metadata_len, data_len; | ||
| 780 | struct thin_disk_superblock *disk_super; | 779 | struct thin_disk_superblock *disk_super; |
| 781 | struct dm_block *sblock; | 780 | struct dm_block *sblock; |
| 782 | 781 | ||
| @@ -797,14 +796,6 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) · 14 unmodified lines | |||
| 797 | if (r < 0) | 796 | if (r < 0) |
| 798 | return r; | 797 | return r; |
| 799 | 798 | ||
| 800 | r = dm_sm_root_size(pmd->metadata_sm, &metadata_len); | ||
| 801 | if (r < 0) | ||
| 802 | return r; | ||
| 803 | |||
| 804 | r = dm_sm_root_size(pmd->data_sm, &data_len); | ||
| 805 | if (r < 0) | ||
| 806 | return r; | ||
| 807 | |||
| 808 | r = save_sm_roots(pmd); | 799 | r = save_sm_roots(pmd); |
| 809 | if (r < 0) | 800 | if (r < 0) |
| 810 | return r; | 801 | return r; |
| @@ -1386,6 +1386,8 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block, · 1385 unmodified lines | |||
| 1386 | 1386 | ||
| 1387 | static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); | 1387 | static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); |
| 1388 | 1388 | ||
| 1389 | static void requeue_bios(struct pool *pool); | ||
| 1390 | |||
| 1389 | static void check_for_space(struct pool *pool) | 1391 | static void check_for_space(struct pool *pool) |
| 1390 | { | 1392 | { |
| 1391 | int r; | 1393 | int r; |
| @@ -1398,8 +1400,10 @@ static void check_for_space(struct pool *pool) · 6 unmodified lines | |||
| 1398 | if (r) | 1400 | if (r) |
| 1399 | return; | 1401 | return; |
| 1400 | 1402 | ||
| 1401 | if (nr_free) | 1403 | if (nr_free) { |
| 1402 | set_pool_mode(pool, PM_WRITE); | 1404 | set_pool_mode(pool, PM_WRITE); |
| 1405 | requeue_bios(pool); | ||
| 1406 | } | ||
| 1403 | } | 1407 | } |
| 1404 | 1408 | ||
| 1405 | /* | 1409 | /* |
| @@ -1476,7 +1480,10 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result) · 70 unmodified lines | |||
| 1476 | 1480 | ||
| 1477 | r = dm_pool_alloc_data_block(pool->pmd, result); | 1481 | r = dm_pool_alloc_data_block(pool->pmd, result); |
| 1478 | if (r) { | 1482 | if (r) { |
| 1479 | metadata_operation_failed(pool, "dm_pool_alloc_data_block", r); | 1483 | if (r == -ENOSPC) |
| 1484 | set_pool_mode(pool, PM_OUT_OF_DATA_SPACE); | ||
| 1485 | else | ||
| 1486 | metadata_operation_failed(pool, "dm_pool_alloc_data_block", r); | ||
| 1480 | return r; | 1487 | return r; |
| 1481 | } | 1488 | } |
| 1482 | 1489 | ||
| @@ -259,7 +259,7 @@ static int persistent_memory_claim(struct dm_writecache *wc) · 258 unmodified lines | |||
| 259 | if (da != p) { | 259 | if (da != p) { |
| 260 | long i; | 260 | long i; |
| 261 | wc->memory_map = NULL; | 261 | wc->memory_map = NULL; |
| 262 | pages = kvmalloc(p * sizeof(struct page *), GFP_KERNEL); | 262 | pages = kvmalloc_array(p, sizeof(struct page *), GFP_KERNEL); |
| 263 | if (!pages) { | 263 | if (!pages) { |
| 264 | r = -ENOMEM; | 264 | r = -ENOMEM; |
| 265 | goto err2; | 265 | goto err2; |
| @@ -859,7 +859,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc) · 593 unmodified lines | |||
| 859 | 859 | ||
| 860 | if (wc->entries) | 860 | if (wc->entries) |
| 861 | return 0; | 861 | return 0; |
| 862 | wc->entries = vmalloc(sizeof(struct wc_entry) * wc->n_blocks); | 862 | wc->entries = vmalloc(array_size(sizeof(struct wc_entry), wc->n_blocks)); |
| 863 | if (!wc->entries) | 863 | if (!wc->entries) |
| 864 | return -ENOMEM; | 864 | return -ENOMEM; |
| 865 | for (b = 0; b < wc->n_blocks; b++) { | 865 | for (b = 0; b < wc->n_blocks; b++) { |
| @@ -1481,9 +1481,9 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba · 615 unmodified lines | |||
| 1481 | wb->bio.bi_iter.bi_sector = read_original_sector(wc, e); | 1481 | wb->bio.bi_iter.bi_sector = read_original_sector(wc, e); |
| 1482 | wb->page_offset = PAGE_SIZE; | 1482 | wb->page_offset = PAGE_SIZE; |
| 1483 | if (max_pages <= WB_LIST_INLINE || | 1483 | if (max_pages <= WB_LIST_INLINE || |
| 1484 | unlikely(!(wb->wc_list = kmalloc(max_pages * sizeof(struct wc_entry *), | 1484 | unlikely(!(wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *), |
| 1485 | GFP_NOIO | __GFP_NORETRY | | 1485 | GFP_NOIO | __GFP_NORETRY | |
| 1486 | __GFP_NOMEMALLOC | __GFP_NOWARN)))) { | 1486 | __GFP_NOMEMALLOC | __GFP_NOWARN)))) { |
| 1487 | wb->wc_list = wb->wc_list_inline; | 1487 | wb->wc_list = wb->wc_list_inline; |
| 1488 | max_pages = WB_LIST_INLINE; | 1488 | max_pages = WB_LIST_INLINE; |
| 1489 | } | 1489 | } |
| @@ -787,7 +787,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 786 unmodified lines | |||
| 787 | 787 | ||
| 788 | /* Chunk BIO work */ | 788 | /* Chunk BIO work */ |
| 789 | mutex_init(&dmz->chunk_lock); | 789 | mutex_init(&dmz->chunk_lock); |
| 790 | INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_KERNEL); | 790 | INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_NOIO); |
| 791 | dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND, | 791 | dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND, |
| 792 | 0, dev->name); | 792 | 0, dev->name); |
| 793 | if (!dmz->chunk_wq) { | 793 | if (!dmz->chunk_wq) { |
| @@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, · 1055 unmodified lines | |||
| 1056 | if (len < 1) | 1056 | if (len < 1) |
| 1057 | goto out; | 1057 | goto out; |
| 1058 | nr_pages = min(len, nr_pages); | 1058 | nr_pages = min(len, nr_pages); |
| 1059 | if (ti->type->direct_access) | 1059 | ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); |
| 1060 | ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); | ||
| 1061 | 1060 | ||
| 1062 | out: | 1061 | out: |
| 1063 | dm_put_live_table(md, srcu_idx); | 1062 | dm_put_live_table(md, srcu_idx); |
| @@ -1606,10 +1605,9 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md, · 542 unmodified lines | |||
| 1606 | * the usage of io->orig_bio in dm_remap_zone_report() | 1605 | * the usage of io->orig_bio in dm_remap_zone_report() |
| 1607 | * won't be affected by this reassignment. | 1606 | * won't be affected by this reassignment. |
| 1608 | */ | 1607 | */ |
| 1609 | struct bio *b = bio_clone_bioset(bio, GFP_NOIO, | 1608 | struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count, |
| 1610 | &md->queue->bio_split); | 1609 | GFP_NOIO, &md->queue->bio_split); |
| 1611 | ci.io->orig_bio = b; | 1610 | ci.io->orig_bio = b; |
| 1612 | bio_advance(bio, (bio_sectors(bio) - ci.sector_count) << 9); | ||
| 1613 | bio_chain(b, bio); | 1611 | bio_chain(b, bio); |
| 1614 | ret = generic_make_request(bio); | 1612 | ret = generic_make_request(bio); |
| 1615 | break; | 1613 | break; |
| @@ -414,7 +414,8 @@ static int pmem_attach_disk(struct device *dev, · 413 unmodified lines | |||
| 414 | blk_queue_logical_block_size(q, pmem_sector_size(ndns)); | 414 | blk_queue_logical_block_size(q, pmem_sector_size(ndns)); |
| 415 | blk_queue_max_hw_sectors(q, UINT_MAX); | 415 | blk_queue_max_hw_sectors(q, UINT_MAX); |
| 416 | blk_queue_flag_set(QUEUE_FLAG_NONROT, q); | 416 | blk_queue_flag_set(QUEUE_FLAG_NONROT, q); |
| 417 | blk_queue_flag_set(QUEUE_FLAG_DAX, q); | 417 | if (pmem->pfn_flags & PFN_MAP) |
| 418 | blk_queue_flag_set(QUEUE_FLAG_DAX, q); | ||
| 418 | q->queuedata = pmem; | 419 | q->queuedata = pmem; |
| 419 | 420 | ||
| 420 | disk = alloc_disk_node(0, nid); | 421 | disk = alloc_disk_node(0, nid); |