This patch removes endio_hook_pool from dm-thin and uses per-bio data instead. This patch removes any use of map_info in preparation for the next patch that removes map_info from bio-based device mapper.
Unified · Split
| @@ -186,7 +186,6 @@ struct pool { · 185 unmodified lines | ||
| 186 | 186 | |
| 187 | 187 | struct dm_thin_new_mapping *next_mapping; |
| 188 | 188 | mempool_t *mapping_pool; |
| 189 | − mempool_t *endio_hook_pool; | |
| 190 | 189 | |
| 191 | 190 | process_bio_fn process_bio; |
| 192 | 191 | process_bio_fn process_discard; |
| @@ -304,7 +303,7 @@ static void __requeue_bio_list(struct thin_c *tc, struct bio_list *master) · 111 unmodified lines | ||
| 304 | 303 | bio_list_init(master); |
| 305 | 304 | |
| 306 | 305 | while ((bio = bio_list_pop(&bios))) { |
| 307 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 306 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 308 | 307 | |
| 309 | 308 | if (h->tc == tc) |
| 310 | 309 | bio_endio(bio, DM_ENDIO_REQUEUE); |
| @@ -375,7 +374,7 @@ static void inc_all_io_entry(struct pool *pool, struct bio *bio) · 64 unmodified lines | ||
| 375 | 374 | if (bio->bi_rw & REQ_DISCARD) |
| 376 | 375 | return; |
| 377 | 376 | |
| 378 | − h = dm_get_mapinfo(bio)->ptr; | |
| 377 | + h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 379 | 378 | h->all_io_entry = dm_deferred_entry_inc(pool->all_io_ds); |
| 380 | 379 | } |
| 381 | 380 | |
| @@ -485,7 +484,7 @@ static void copy_complete(int read_err, unsigned long write_err, void *context) · 103 unmodified lines | ||
| 485 | 484 | static void overwrite_endio(struct bio *bio, int err) |
| 486 | 485 | { |
| 487 | 486 | unsigned long flags; |
| 488 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 487 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 489 | 488 | struct dm_thin_new_mapping *m = h->overwrite_mapping; |
| 490 | 489 | struct pool *pool = m->tc->pool; |
| 491 | 490 | |
| @@ -714,7 +713,7 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, · 222 unmodified lines | ||
| 714 | 713 | * bio immediately. Otherwise we use kcopyd to clone the data first. |
| 715 | 714 | */ |
| 716 | 715 | if (io_overwrites_block(pool, bio)) { |
| 717 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 716 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 718 | 717 | |
| 719 | 718 | h->overwrite_mapping = m; |
| 720 | 719 | m->bio = bio; |
| @@ -784,7 +783,7 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, · 63 unmodified lines | ||
| 784 | 783 | process_prepared_mapping(m); |
| 785 | 784 | |
| 786 | 785 | else if (io_overwrites_block(pool, bio)) { |
| 787 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 786 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 788 | 787 | |
| 789 | 788 | h->overwrite_mapping = m; |
| 790 | 789 | m->bio = bio; |
| @@ -899,7 +898,7 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result) · 108 unmodified lines | ||
| 899 | 898 | */ |
| 900 | 899 | static void retry_on_resume(struct bio *bio) |
| 901 | 900 | { |
| 902 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 901 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 903 | 902 | struct thin_c *tc = h->tc; |
| 904 | 903 | struct pool *pool = tc->pool; |
| 905 | 904 | unsigned long flags; |
| @@ -1051,7 +1050,7 @@ static void process_shared_bio(struct thin_c *tc, struct bio *bio, · 145 unmodified lines | ||
| 1051 | 1050 | if (bio_data_dir(bio) == WRITE && bio->bi_size) |
| 1052 | 1051 | break_sharing(tc, bio, block, &key, lookup_result, cell); |
| 1053 | 1052 | else { |
| 1054 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 1053 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 1055 | 1054 | |
| 1056 | 1055 | h->shared_read_entry = dm_deferred_entry_inc(pool->shared_read_ds); |
| 1057 | 1056 | inc_all_io_entry(pool, bio); |
| @@ -1226,7 +1225,7 @@ static void process_deferred_bios(struct pool *pool) · 168 unmodified lines | ||
| 1226 | 1225 | spin_unlock_irqrestore(&pool->lock, flags); |
| 1227 | 1226 | |
| 1228 | 1227 | while ((bio = bio_list_pop(&bios))) { |
| 1229 | − struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; | |
| 1228 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 1230 | 1229 | struct thin_c *tc = h->tc; |
| 1231 | 1230 | |
| 1232 | 1231 | /* |
| @@ -1359,17 +1358,14 @@ static void thin_defer_bio(struct thin_c *tc, struct bio *bio) · 126 unmodified lines | ||
| 1359 | 1358 | wake_worker(pool); |
| 1360 | 1359 | } |
| 1361 | 1360 | |
| 1362 | −static struct dm_thin_endio_hook *thin_hook_bio(struct thin_c *tc, struct bio *bio) | |
| 1361 | +static void thin_hook_bio(struct thin_c *tc, struct bio *bio) | |
| 1363 | 1362 | { |
| 1364 | − struct pool *pool = tc->pool; | |
| 1365 | − struct dm_thin_endio_hook *h = mempool_alloc(pool->endio_hook_pool, GFP_NOIO); | |
| 1363 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 1366 | 1364 | |
| 1367 | 1365 | h->tc = tc; |
| 1368 | 1366 | h->shared_read_entry = NULL; |
| 1369 | 1367 | h->all_io_entry = NULL; |
| 1370 | 1368 | h->overwrite_mapping = NULL; |
| 1371 | − | |
| 1372 | − return h; | |
| 1373 | 1369 | } |
| 1374 | 1370 | |
| 1375 | 1371 | /* |
| @@ -1386,7 +1382,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio, · 10 unmodified lines | ||
| 1386 | 1382 | struct dm_bio_prison_cell *cell1, *cell2; |
| 1387 | 1383 | struct dm_cell_key key; |
| 1388 | 1384 | |
| 1389 | − map_context->ptr = thin_hook_bio(tc, bio); | |
| 1385 | + thin_hook_bio(tc, bio); | |
| 1390 | 1386 | |
| 1391 | 1387 | if (get_pool_mode(tc->pool) == PM_FAIL) { |
| 1392 | 1388 | bio_io_error(bio); |
| @@ -1595,14 +1591,12 @@ static void __pool_destroy(struct pool *pool) · 202 unmodified lines | ||
| 1595 | 1591 | if (pool->next_mapping) |
| 1596 | 1592 | mempool_free(pool->next_mapping, pool->mapping_pool); |
| 1597 | 1593 | mempool_destroy(pool->mapping_pool); |
| 1598 | − mempool_destroy(pool->endio_hook_pool); | |
| 1599 | 1594 | dm_deferred_set_destroy(pool->shared_read_ds); |
| 1600 | 1595 | dm_deferred_set_destroy(pool->all_io_ds); |
| 1601 | 1596 | kfree(pool); |
| 1602 | 1597 | } |
| 1603 | 1598 | |
| 1604 | 1599 | static struct kmem_cache *_new_mapping_cache; |
| 1605 | −static struct kmem_cache *_endio_hook_cache; | |
| 1606 | 1600 | |
| 1607 | 1601 | static struct pool *pool_create(struct mapped_device *pool_md, |
| 1608 | 1602 | struct block_device *metadata_dev, |
| @@ -1696,13 +1690,6 @@ static struct pool *pool_create(struct mapped_device *pool_md, · 87 unmodified lines | ||
| 1696 | 1690 | goto bad_mapping_pool; |
| 1697 | 1691 | } |
| 1698 | 1692 | |
| 1699 | − pool->endio_hook_pool = mempool_create_slab_pool(ENDIO_HOOK_POOL_SIZE, | |
| 1700 | − _endio_hook_cache); | |
| 1701 | − if (!pool->endio_hook_pool) { | |
| 1702 | − *error = "Error creating pool's endio_hook mempool"; | |
| 1703 | − err_p = ERR_PTR(-ENOMEM); | |
| 1704 | − goto bad_endio_hook_pool; | |
| 1705 | − } | |
| 1706 | 1693 | pool->ref_count = 1; |
| 1707 | 1694 | pool->last_commit_jiffies = jiffies; |
| 1708 | 1695 | pool->pool_md = pool_md; |
| @@ -1711,8 +1698,6 @@ static struct pool *pool_create(struct mapped_device *pool_md, · 2 unmodified lines | ||
| 1711 | 1698 | |
| 1712 | 1699 | return pool; |
| 1713 | 1700 | |
| 1714 | −bad_endio_hook_pool: | |
| 1715 | − mempool_destroy(pool->mapping_pool); | |
| 1716 | 1701 | bad_mapping_pool: |
| 1717 | 1702 | dm_deferred_set_destroy(pool->all_io_ds); |
| 1718 | 1703 | bad_all_io_ds: |
| @@ -2607,6 +2592,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) · 888 unmodified lines | ||
| 2607 | 2592 | |
| 2608 | 2593 | ti->num_flush_requests = 1; |
| 2609 | 2594 | ti->flush_supported = true; |
| 2595 | + ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook); | |
| 2610 | 2596 | |
| 2611 | 2597 | /* In case the pool supports discards, pass them on. */ |
| 2612 | 2598 | if (tc->pool->pf.discard_enabled) { |
| @@ -2653,7 +2639,7 @@ static int thin_endio(struct dm_target *ti, · 40 unmodified lines | ||
| 2653 | 2639 | union map_info *map_context) |
| 2654 | 2640 | { |
| 2655 | 2641 | unsigned long flags; |
| 2656 | − struct dm_thin_endio_hook *h = map_context->ptr; | |
| 2642 | + struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); | |
| 2657 | 2643 | struct list_head work; |
| 2658 | 2644 | struct dm_thin_new_mapping *m, *tmp; |
| 2659 | 2645 | struct pool *pool = h->tc->pool; |
| @@ -2683,8 +2669,6 @@ static int thin_endio(struct dm_target *ti, · 23 unmodified lines | ||
| 2683 | 2669 | } |
| 2684 | 2670 | } |
| 2685 | 2671 | |
| 2686 | − mempool_free(h, pool->endio_hook_pool); | |
| 2687 | − | |
| 2688 | 2672 | return 0; |
| 2689 | 2673 | } |
| 2690 | 2674 | |
| @@ -2813,14 +2797,8 @@ static int __init dm_thin_init(void) · 122 unmodified lines | ||
| 2813 | 2797 | if (!_new_mapping_cache) |
| 2814 | 2798 | goto bad_new_mapping_cache; |
| 2815 | 2799 | |
| 2816 | − _endio_hook_cache = KMEM_CACHE(dm_thin_endio_hook, 0); | |
| 2817 | − if (!_endio_hook_cache) | |
| 2818 | − goto bad_endio_hook_cache; | |
| 2819 | − | |
| 2820 | 2800 | return 0; |
| 2821 | 2801 | |
| 2822 | −bad_endio_hook_cache: | |
| 2823 | − kmem_cache_destroy(_new_mapping_cache); | |
| 2824 | 2802 | bad_new_mapping_cache: |
| 2825 | 2803 | dm_unregister_target(&pool_target); |
| 2826 | 2804 | bad_pool_target: |
| @@ -2835,7 +2813,6 @@ static void dm_thin_exit(void) · 8 unmodified lines | ||
| 2835 | 2813 | dm_unregister_target(&pool_target); |
| 2836 | 2814 | |
| 2837 | 2815 | kmem_cache_destroy(_new_mapping_cache); |
| 2838 | − kmem_cache_destroy(_endio_hook_cache); | |
| 2839 | 2816 | } |
| 2840 | 2817 | |
| 2841 | 2818 | module_init(dm_thin_init); |