Lines Matching refs:tc

223 typedef void (*process_bio_fn)(struct thin_c *tc, struct bio *bio);
224 typedef void (*process_cell_fn)(struct thin_c *tc, struct dm_bio_prison_cell *cell);
349 struct thin_c *tc; member
355 static void begin_discard(struct discard_op *op, struct thin_c *tc, struct bio *parent) in begin_discard() argument
359 op->tc = tc; in begin_discard()
367 struct thin_c *tc = op->tc; in issue_discard() local
368 sector_t s = block_to_sectors(tc->pool, data_b); in issue_discard()
369 sector_t len = block_to_sectors(tc->pool, data_e - data_b); in issue_discard()
371 return __blkdev_issue_discard(tc->pool_dev->bdev, s, len, in issue_discard()
554 struct thin_c *tc; member
578 static void error_thin_bio_list(struct thin_c *tc, struct bio_list *master, in error_thin_bio_list() argument
586 spin_lock_irqsave(&tc->lock, flags); in error_thin_bio_list()
588 spin_unlock_irqrestore(&tc->lock, flags); in error_thin_bio_list()
593 static void requeue_deferred_cells(struct thin_c *tc) in requeue_deferred_cells() argument
595 struct pool *pool = tc->pool; in requeue_deferred_cells()
602 spin_lock_irqsave(&tc->lock, flags); in requeue_deferred_cells()
603 list_splice_init(&tc->deferred_cells, &cells); in requeue_deferred_cells()
604 spin_unlock_irqrestore(&tc->lock, flags); in requeue_deferred_cells()
610 static void requeue_io(struct thin_c *tc) in requeue_io() argument
617 spin_lock_irqsave(&tc->lock, flags); in requeue_io()
618 __merge_bio_list(&bios, &tc->deferred_bio_list); in requeue_io()
619 __merge_bio_list(&bios, &tc->retry_on_resume_list); in requeue_io()
620 spin_unlock_irqrestore(&tc->lock, flags); in requeue_io()
623 requeue_deferred_cells(tc); in requeue_io()
628 struct thin_c *tc; in error_retry_list_with_code() local
631 list_for_each_entry_rcu(tc, &pool->active_thins, list) in error_retry_list_with_code()
632 error_thin_bio_list(tc, &tc->retry_on_resume_list, error); in error_retry_list_with_code()
648 static dm_block_t get_bio_block(struct thin_c *tc, struct bio *bio) in get_bio_block() argument
650 struct pool *pool = tc->pool; in get_bio_block()
664 static void get_bio_block_range(struct thin_c *tc, struct bio *bio, in get_bio_block_range() argument
667 struct pool *pool = tc->pool; in get_bio_block_range()
689 static void remap(struct thin_c *tc, struct bio *bio, dm_block_t block) in remap() argument
691 struct pool *pool = tc->pool; in remap()
694 bio_set_dev(bio, tc->pool_dev->bdev); in remap()
704 static void remap_to_origin(struct thin_c *tc, struct bio *bio) in remap_to_origin() argument
706 bio_set_dev(bio, tc->origin_dev->bdev); in remap_to_origin()
709 static int bio_triggers_commit(struct thin_c *tc, struct bio *bio) in bio_triggers_commit() argument
712 dm_thin_changed_this_transaction(tc->td); in bio_triggers_commit()
726 static void issue(struct thin_c *tc, struct bio *bio) in issue() argument
728 struct pool *pool = tc->pool; in issue()
731 if (!bio_triggers_commit(tc, bio)) { in issue()
741 if (dm_thin_aborted_changes(tc->td)) { in issue()
755 static void remap_to_origin_and_issue(struct thin_c *tc, struct bio *bio) in remap_to_origin_and_issue() argument
757 remap_to_origin(tc, bio); in remap_to_origin_and_issue()
758 issue(tc, bio); in remap_to_origin_and_issue()
761 static void remap_and_issue(struct thin_c *tc, struct bio *bio, in remap_and_issue() argument
764 remap(tc, bio, block); in remap_and_issue()
765 issue(tc, bio); in remap_and_issue()
787 struct thin_c *tc; member
804 struct pool *pool = m->tc->pool; in __complete_mapping_preparation()
815 struct pool *pool = m->tc->pool; in complete_mapping_preparation()
855 static void cell_defer_no_holder(struct thin_c *tc, struct dm_bio_prison_cell *cell) in cell_defer_no_holder() argument
857 struct pool *pool = tc->pool; in cell_defer_no_holder()
860 spin_lock_irqsave(&tc->lock, flags); in cell_defer_no_holder()
861 cell_release_no_holder(pool, cell, &tc->deferred_bio_list); in cell_defer_no_holder()
862 spin_unlock_irqrestore(&tc->lock, flags); in cell_defer_no_holder()
867 static void thin_defer_bio(struct thin_c *tc, struct bio *bio);
870 struct thin_c *tc; member
885 inc_all_io_entry(info->tc->pool, bio); in __inc_remap_and_issue_cell()
897 static void inc_remap_and_issue_cell(struct thin_c *tc, in inc_remap_and_issue_cell() argument
904 info.tc = tc; in inc_remap_and_issue_cell()
913 cell_visit_release(tc->pool, __inc_remap_and_issue_cell, in inc_remap_and_issue_cell()
917 thin_defer_bio(tc, bio); in inc_remap_and_issue_cell()
920 remap_and_issue(info.tc, bio, block); in inc_remap_and_issue_cell()
925 cell_error(m->tc->pool, m->cell); in process_prepared_mapping_fail()
927 mempool_free(m, &m->tc->pool->mapping_pool); in process_prepared_mapping_fail()
932 struct thin_c *tc = m->tc; in process_prepared_mapping() local
933 struct pool *pool = tc->pool; in process_prepared_mapping()
947 r = dm_thin_insert_block(tc->td, m->virt_begin, m->data_block); in process_prepared_mapping()
961 inc_remap_and_issue_cell(tc, m->cell, m->data_block); in process_prepared_mapping()
964 inc_all_io_entry(tc->pool, m->cell->holder); in process_prepared_mapping()
965 remap_and_issue(tc, m->cell->holder, m->data_block); in process_prepared_mapping()
966 inc_remap_and_issue_cell(tc, m->cell, m->data_block); in process_prepared_mapping()
978 struct thin_c *tc = m->tc; in free_discard_mapping() local
980 cell_defer_no_holder(tc, m->cell); in free_discard_mapping()
981 mempool_free(m, &tc->pool->mapping_pool); in free_discard_mapping()
999 struct thin_c *tc = m->tc; in process_prepared_discard_no_passdown() local
1001 r = dm_thin_remove_range(tc->td, m->cell->key.block_begin, m->cell->key.block_end); in process_prepared_discard_no_passdown()
1003 metadata_operation_failed(tc->pool, "dm_thin_remove_range", r); in process_prepared_discard_no_passdown()
1008 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_no_passdown()
1009 mempool_free(m, &tc->pool->mapping_pool); in process_prepared_discard_no_passdown()
1023 struct thin_c *tc = m->tc; in passdown_double_checking_shared_status() local
1024 struct pool *pool = tc->pool; in passdown_double_checking_shared_status()
1028 begin_discard(&op, tc, discard_parent); in passdown_double_checking_shared_status()
1066 struct pool *pool = m->tc->pool; in queue_passdown_pt2()
1087 struct thin_c *tc = m->tc; in process_prepared_discard_passdown_pt1() local
1088 struct pool *pool = tc->pool; in process_prepared_discard_passdown_pt1()
1097 r = dm_thin_remove_range(tc->td, m->virt_begin, m->virt_end); in process_prepared_discard_passdown_pt1()
1101 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt1()
1114 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt1()
1122 dm_device_name(tc->pool->pool_md)); in process_prepared_discard_passdown_pt1()
1134 begin_discard(&op, tc, discard_parent); in process_prepared_discard_passdown_pt1()
1144 struct thin_c *tc = m->tc; in process_prepared_discard_passdown_pt2() local
1145 struct pool *pool = tc->pool; in process_prepared_discard_passdown_pt2()
1159 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt2()
1226 static void ll_zero(struct thin_c *tc, struct dm_thin_new_mapping *m, in ll_zero() argument
1231 to.bdev = tc->pool_dev->bdev; in ll_zero()
1235 dm_kcopyd_zero(tc->pool->copier, 1, &to, 0, copy_complete, m); in ll_zero()
1238 static void remap_and_issue_overwrite(struct thin_c *tc, struct bio *bio, in remap_and_issue_overwrite() argument
1242 struct pool *pool = tc->pool; in remap_and_issue_overwrite()
1249 remap_and_issue(tc, bio, data_begin); in remap_and_issue_overwrite()
1255 static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_copy() argument
1261 struct pool *pool = tc->pool; in schedule_copy()
1264 m->tc = tc; in schedule_copy()
1287 remap_and_issue_overwrite(tc, bio, data_dest, m); in schedule_copy()
1295 to.bdev = tc->pool_dev->bdev; in schedule_copy()
1307 ll_zero(tc, m, in schedule_copy()
1316 static void schedule_internal_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_internal_copy() argument
1320 schedule_copy(tc, virt_block, tc->pool_dev, in schedule_internal_copy()
1322 tc->pool->sectors_per_block); in schedule_internal_copy()
1325 static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, in schedule_zero() argument
1329 struct pool *pool = tc->pool; in schedule_zero()
1333 m->tc = tc; in schedule_zero()
1346 remap_and_issue_overwrite(tc, bio, data_block, m); in schedule_zero()
1348 ll_zero(tc, m, data_block * pool->sectors_per_block, in schedule_zero()
1354 static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_external_copy() argument
1358 struct pool *pool = tc->pool; in schedule_external_copy()
1362 if (virt_block_end <= tc->origin_size) in schedule_external_copy()
1363 schedule_copy(tc, virt_block, tc->origin_dev, in schedule_external_copy()
1367 else if (virt_block_begin < tc->origin_size) in schedule_external_copy()
1368 schedule_copy(tc, virt_block, tc->origin_dev, in schedule_external_copy()
1370 tc->origin_size - virt_block_begin); in schedule_external_copy()
1373 schedule_zero(tc, virt_block, data_dest, cell, bio); in schedule_external_copy()
1462 static int alloc_data_block(struct thin_c *tc, dm_block_t *result) in alloc_data_block() argument
1466 struct pool *pool = tc->pool; in alloc_data_block()
1532 struct thin_c *tc = h->tc; in retry_on_resume() local
1535 spin_lock_irqsave(&tc->lock, flags); in retry_on_resume()
1536 bio_list_add(&tc->retry_on_resume_list, bio); in retry_on_resume()
1537 spin_unlock_irqrestore(&tc->lock, flags); in retry_on_resume()
1594 static void process_discard_cell_no_passdown(struct thin_c *tc, in process_discard_cell_no_passdown() argument
1597 struct pool *pool = tc->pool; in process_discard_cell_no_passdown()
1604 m->tc = tc; in process_discard_cell_no_passdown()
1614 static void break_up_discard_bio(struct thin_c *tc, dm_block_t begin, dm_block_t end, in break_up_discard_bio() argument
1617 struct pool *pool = tc->pool; in break_up_discard_bio()
1632 r = dm_thin_find_mapped_range(tc->td, begin, end, &virt_begin, &virt_end, in break_up_discard_bio()
1641 build_key(tc->td, PHYSICAL, data_begin, data_begin + (virt_end - virt_begin), &data_key); in break_up_discard_bio()
1642 if (bio_detain(tc->pool, &data_key, NULL, &data_cell)) { in break_up_discard_bio()
1653 m->tc = tc; in break_up_discard_bio()
1677 static void process_discard_cell_passdown(struct thin_c *tc, struct dm_bio_prison_cell *virt_cell) in process_discard_cell_passdown() argument
1688 break_up_discard_bio(tc, virt_cell->key.block_begin, virt_cell->key.block_end, bio); in process_discard_cell_passdown()
1698 static void process_discard_bio(struct thin_c *tc, struct bio *bio) in process_discard_bio() argument
1704 get_bio_block_range(tc, bio, &begin, &end); in process_discard_bio()
1713 build_key(tc->td, VIRTUAL, begin, end, &virt_key); in process_discard_bio()
1714 if (bio_detain(tc->pool, &virt_key, bio, &virt_cell)) in process_discard_bio()
1724 tc->pool->process_discard_cell(tc, virt_cell); in process_discard_bio()
1727 static void break_sharing(struct thin_c *tc, struct bio *bio, dm_block_t block, in break_sharing() argument
1734 struct pool *pool = tc->pool; in break_sharing()
1736 r = alloc_data_block(tc, &data_block); in break_sharing()
1739 schedule_internal_copy(tc, block, lookup_result->block, in break_sharing()
1768 h->shared_read_entry = dm_deferred_entry_inc(info->tc->pool->shared_read_ds); in __remap_and_issue_shared_cell()
1769 inc_all_io_entry(info->tc->pool, bio); in __remap_and_issue_shared_cell()
1775 static void remap_and_issue_shared_cell(struct thin_c *tc, in remap_and_issue_shared_cell() argument
1782 info.tc = tc; in remap_and_issue_shared_cell()
1786 cell_visit_release(tc->pool, __remap_and_issue_shared_cell, in remap_and_issue_shared_cell()
1790 thin_defer_bio(tc, bio); in remap_and_issue_shared_cell()
1793 remap_and_issue(tc, bio, block); in remap_and_issue_shared_cell()
1796 static void process_shared_bio(struct thin_c *tc, struct bio *bio, in process_shared_bio() argument
1802 struct pool *pool = tc->pool; in process_shared_bio()
1809 build_data_key(tc->td, lookup_result->block, &key); in process_shared_bio()
1811 cell_defer_no_holder(tc, virt_cell); in process_shared_bio()
1816 break_sharing(tc, bio, block, &key, lookup_result, data_cell); in process_shared_bio()
1817 cell_defer_no_holder(tc, virt_cell); in process_shared_bio()
1823 remap_and_issue(tc, bio, lookup_result->block); in process_shared_bio()
1825 remap_and_issue_shared_cell(tc, data_cell, lookup_result->block); in process_shared_bio()
1826 remap_and_issue_shared_cell(tc, virt_cell, lookup_result->block); in process_shared_bio()
1830 static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block, in provision_block() argument
1835 struct pool *pool = tc->pool; in provision_block()
1842 cell_defer_no_holder(tc, cell); in provision_block()
1844 remap_and_issue(tc, bio, 0); in provision_block()
1853 cell_defer_no_holder(tc, cell); in provision_block()
1858 r = alloc_data_block(tc, &data_block); in provision_block()
1861 if (tc->origin_dev) in provision_block()
1862 schedule_external_copy(tc, block, data_block, cell, bio); in provision_block()
1864 schedule_zero(tc, block, data_block, cell, bio); in provision_block()
1879 static void process_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell() argument
1882 struct pool *pool = tc->pool; in process_cell()
1884 dm_block_t block = get_bio_block(tc, bio); in process_cell()
1887 if (tc->requeue_mode) { in process_cell()
1892 r = dm_thin_find_block(tc->td, block, 1, &lookup_result); in process_cell()
1896 process_shared_bio(tc, bio, block, &lookup_result, cell); in process_cell()
1899 remap_and_issue(tc, bio, lookup_result.block); in process_cell()
1900 inc_remap_and_issue_cell(tc, cell, lookup_result.block); in process_cell()
1905 if (bio_data_dir(bio) == READ && tc->origin_dev) { in process_cell()
1907 cell_defer_no_holder(tc, cell); in process_cell()
1909 if (bio_end_sector(bio) <= tc->origin_size) in process_cell()
1910 remap_to_origin_and_issue(tc, bio); in process_cell()
1912 else if (bio->bi_iter.bi_sector < tc->origin_size) { in process_cell()
1914 bio->bi_iter.bi_size = (tc->origin_size - bio->bi_iter.bi_sector) << SECTOR_SHIFT; in process_cell()
1915 remap_to_origin_and_issue(tc, bio); in process_cell()
1922 provision_block(tc, bio, block, cell); in process_cell()
1928 cell_defer_no_holder(tc, cell); in process_cell()
1934 static void process_bio(struct thin_c *tc, struct bio *bio) in process_bio() argument
1936 struct pool *pool = tc->pool; in process_bio()
1937 dm_block_t block = get_bio_block(tc, bio); in process_bio()
1945 build_virtual_key(tc->td, block, &key); in process_bio()
1949 process_cell(tc, cell); in process_bio()
1952 static void __process_bio_read_only(struct thin_c *tc, struct bio *bio, in __process_bio_read_only() argument
1957 dm_block_t block = get_bio_block(tc, bio); in __process_bio_read_only()
1960 r = dm_thin_find_block(tc->td, block, 1, &lookup_result); in __process_bio_read_only()
1964 handle_unserviceable_bio(tc->pool, bio); in __process_bio_read_only()
1966 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
1968 inc_all_io_entry(tc->pool, bio); in __process_bio_read_only()
1969 remap_and_issue(tc, bio, lookup_result.block); in __process_bio_read_only()
1971 inc_remap_and_issue_cell(tc, cell, lookup_result.block); in __process_bio_read_only()
1977 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
1979 handle_unserviceable_bio(tc->pool, bio); in __process_bio_read_only()
1983 if (tc->origin_dev) { in __process_bio_read_only()
1984 inc_all_io_entry(tc->pool, bio); in __process_bio_read_only()
1985 remap_to_origin_and_issue(tc, bio); in __process_bio_read_only()
1997 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
2003 static void process_bio_read_only(struct thin_c *tc, struct bio *bio) in process_bio_read_only() argument
2005 __process_bio_read_only(tc, bio, NULL); in process_bio_read_only()
2008 static void process_cell_read_only(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_read_only() argument
2010 __process_bio_read_only(tc, cell->holder, cell); in process_cell_read_only()
2013 static void process_bio_success(struct thin_c *tc, struct bio *bio) in process_bio_success() argument
2018 static void process_bio_fail(struct thin_c *tc, struct bio *bio) in process_bio_fail() argument
2023 static void process_cell_success(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_success() argument
2025 cell_success(tc->pool, cell); in process_cell_success()
2028 static void process_cell_fail(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_fail() argument
2030 cell_error(tc->pool, cell); in process_cell_fail()
2046 static void __thin_bio_rb_add(struct thin_c *tc, struct bio *bio) in __thin_bio_rb_add() argument
2052 rbp = &tc->sort_bio_list.rb_node; in __thin_bio_rb_add()
2066 rb_insert_color(&pbd->rb_node, &tc->sort_bio_list); in __thin_bio_rb_add()
2069 static void __extract_sorted_bios(struct thin_c *tc) in __extract_sorted_bios() argument
2075 for (node = rb_first(&tc->sort_bio_list); node; node = rb_next(node)) { in __extract_sorted_bios()
2079 bio_list_add(&tc->deferred_bio_list, bio); in __extract_sorted_bios()
2080 rb_erase(&pbd->rb_node, &tc->sort_bio_list); in __extract_sorted_bios()
2083 WARN_ON(!RB_EMPTY_ROOT(&tc->sort_bio_list)); in __extract_sorted_bios()
2086 static void __sort_thin_deferred_bios(struct thin_c *tc) in __sort_thin_deferred_bios() argument
2092 bio_list_merge(&bios, &tc->deferred_bio_list); in __sort_thin_deferred_bios()
2093 bio_list_init(&tc->deferred_bio_list); in __sort_thin_deferred_bios()
2097 __thin_bio_rb_add(tc, bio); in __sort_thin_deferred_bios()
2104 __extract_sorted_bios(tc); in __sort_thin_deferred_bios()
2107 static void process_thin_deferred_bios(struct thin_c *tc) in process_thin_deferred_bios() argument
2109 struct pool *pool = tc->pool; in process_thin_deferred_bios()
2116 if (tc->requeue_mode) { in process_thin_deferred_bios()
2117 error_thin_bio_list(tc, &tc->deferred_bio_list, in process_thin_deferred_bios()
2124 spin_lock_irqsave(&tc->lock, flags); in process_thin_deferred_bios()
2126 if (bio_list_empty(&tc->deferred_bio_list)) { in process_thin_deferred_bios()
2127 spin_unlock_irqrestore(&tc->lock, flags); in process_thin_deferred_bios()
2131 __sort_thin_deferred_bios(tc); in process_thin_deferred_bios()
2133 bio_list_merge(&bios, &tc->deferred_bio_list); in process_thin_deferred_bios()
2134 bio_list_init(&tc->deferred_bio_list); in process_thin_deferred_bios()
2136 spin_unlock_irqrestore(&tc->lock, flags); in process_thin_deferred_bios()
2146 spin_lock_irqsave(&tc->lock, flags); in process_thin_deferred_bios()
2147 bio_list_add(&tc->deferred_bio_list, bio); in process_thin_deferred_bios()
2148 bio_list_merge(&tc->deferred_bio_list, &bios); in process_thin_deferred_bios()
2149 spin_unlock_irqrestore(&tc->lock, flags); in process_thin_deferred_bios()
2154 pool->process_discard(tc, bio); in process_thin_deferred_bios()
2156 pool->process_bio(tc, bio); in process_thin_deferred_bios()
2201 static void process_thin_deferred_cells(struct thin_c *tc) in process_thin_deferred_cells() argument
2203 struct pool *pool = tc->pool; in process_thin_deferred_cells()
2211 spin_lock_irqsave(&tc->lock, flags); in process_thin_deferred_cells()
2212 list_splice_init(&tc->deferred_cells, &cells); in process_thin_deferred_cells()
2213 spin_unlock_irqrestore(&tc->lock, flags); in process_thin_deferred_cells()
2219 count = sort_cells(tc->pool, &cells); in process_thin_deferred_cells()
2234 spin_lock_irqsave(&tc->lock, flags); in process_thin_deferred_cells()
2235 list_splice(&cells, &tc->deferred_cells); in process_thin_deferred_cells()
2236 spin_unlock_irqrestore(&tc->lock, flags); in process_thin_deferred_cells()
2241 pool->process_discard_cell(tc, cell); in process_thin_deferred_cells()
2243 pool->process_cell(tc, cell); in process_thin_deferred_cells()
2248 static void thin_get(struct thin_c *tc);
2249 static void thin_put(struct thin_c *tc);
2258 struct thin_c *tc = NULL; in get_first_thin() local
2262 tc = list_entry_rcu(pool->active_thins.next, struct thin_c, list); in get_first_thin()
2263 thin_get(tc); in get_first_thin()
2267 return tc; in get_first_thin()
2270 static struct thin_c *get_next_thin(struct pool *pool, struct thin_c *tc) in get_next_thin() argument
2272 struct thin_c *old_tc = tc; in get_next_thin()
2275 list_for_each_entry_continue_rcu(tc, &pool->active_thins, list) { in get_next_thin()
2276 thin_get(tc); in get_next_thin()
2279 return tc; in get_next_thin()
2292 struct thin_c *tc; in process_deferred_bios() local
2294 tc = get_first_thin(pool); in process_deferred_bios()
2295 while (tc) { in process_deferred_bios()
2296 process_thin_deferred_cells(tc); in process_deferred_bios()
2297 process_thin_deferred_bios(tc); in process_deferred_bios()
2298 tc = get_next_thin(pool, tc); in process_deferred_bios()
2403 struct thin_c *tc; member
2414 w->tc->requeue_mode = true; in do_noflush_start()
2415 requeue_io(w->tc); in do_noflush_start()
2422 w->tc->requeue_mode = false; in do_noflush_stop()
2426 static void noflush_work(struct thin_c *tc, void (*fn)(struct work_struct *)) in noflush_work() argument
2430 w.tc = tc; in noflush_work()
2431 pool_work_wait(&w.pw, tc->pool, fn); in noflush_work()
2612 static void thin_defer_bio(struct thin_c *tc, struct bio *bio) in thin_defer_bio() argument
2615 struct pool *pool = tc->pool; in thin_defer_bio()
2617 spin_lock_irqsave(&tc->lock, flags); in thin_defer_bio()
2618 bio_list_add(&tc->deferred_bio_list, bio); in thin_defer_bio()
2619 spin_unlock_irqrestore(&tc->lock, flags); in thin_defer_bio()
2624 static void thin_defer_bio_with_throttle(struct thin_c *tc, struct bio *bio) in thin_defer_bio_with_throttle() argument
2626 struct pool *pool = tc->pool; in thin_defer_bio_with_throttle()
2629 thin_defer_bio(tc, bio); in thin_defer_bio_with_throttle()
2633 static void thin_defer_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell) in thin_defer_cell() argument
2636 struct pool *pool = tc->pool; in thin_defer_cell()
2639 spin_lock_irqsave(&tc->lock, flags); in thin_defer_cell()
2640 list_add_tail(&cell->user_list, &tc->deferred_cells); in thin_defer_cell()
2641 spin_unlock_irqrestore(&tc->lock, flags); in thin_defer_cell()
2647 static void thin_hook_bio(struct thin_c *tc, struct bio *bio) in thin_hook_bio() argument
2651 h->tc = tc; in thin_hook_bio()
2664 struct thin_c *tc = ti->private; in thin_bio_map() local
2665 dm_block_t block = get_bio_block(tc, bio); in thin_bio_map()
2666 struct dm_thin_device *td = tc->td; in thin_bio_map()
2671 thin_hook_bio(tc, bio); in thin_bio_map()
2673 if (tc->requeue_mode) { in thin_bio_map()
2679 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_bio_map()
2685 thin_defer_bio_with_throttle(tc, bio); in thin_bio_map()
2693 build_virtual_key(tc->td, block, &key); in thin_bio_map()
2694 if (bio_detain(tc->pool, &key, bio, &virt_cell)) in thin_bio_map()
2719 thin_defer_cell(tc, virt_cell); in thin_bio_map()
2723 build_data_key(tc->td, result.block, &key); in thin_bio_map()
2724 if (bio_detain(tc->pool, &key, bio, &data_cell)) { in thin_bio_map()
2725 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2729 inc_all_io_entry(tc->pool, bio); in thin_bio_map()
2730 cell_defer_no_holder(tc, data_cell); in thin_bio_map()
2731 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2733 remap(tc, bio, result.block); in thin_bio_map()
2738 thin_defer_cell(tc, virt_cell); in thin_bio_map()
2748 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2768 struct thin_c *tc; in requeue_bios() local
2771 list_for_each_entry_rcu(tc, &pool->active_thins, list) { in requeue_bios()
2772 spin_lock_irqsave(&tc->lock, flags); in requeue_bios()
2773 bio_list_merge(&tc->deferred_bio_list, &tc->retry_on_resume_list); in requeue_bios()
2774 bio_list_init(&tc->retry_on_resume_list); in requeue_bios()
2775 spin_unlock_irqrestore(&tc->lock, flags); in requeue_bios()
3514 struct thin_c *tc; in pool_suspend_active_thins() local
3517 tc = get_first_thin(pool); in pool_suspend_active_thins()
3518 while (tc) { in pool_suspend_active_thins()
3519 dm_internal_suspend_noflush(tc->thin_md); in pool_suspend_active_thins()
3520 tc = get_next_thin(pool, tc); in pool_suspend_active_thins()
3526 struct thin_c *tc; in pool_resume_active_thins() local
3529 tc = get_first_thin(pool); in pool_resume_active_thins()
3530 while (tc) { in pool_resume_active_thins()
3531 dm_internal_resume(tc->thin_md); in pool_resume_active_thins()
3532 tc = get_next_thin(pool, tc); in pool_resume_active_thins()
4045 static void thin_get(struct thin_c *tc) in thin_get() argument
4047 atomic_inc(&tc->refcount); in thin_get()
4050 static void thin_put(struct thin_c *tc) in thin_put() argument
4052 if (atomic_dec_and_test(&tc->refcount)) in thin_put()
4053 complete(&tc->can_destroy); in thin_put()
4058 struct thin_c *tc = ti->private; in thin_dtr() local
4061 spin_lock_irqsave(&tc->pool->lock, flags); in thin_dtr()
4062 list_del_rcu(&tc->list); in thin_dtr()
4063 spin_unlock_irqrestore(&tc->pool->lock, flags); in thin_dtr()
4066 thin_put(tc); in thin_dtr()
4067 wait_for_completion(&tc->can_destroy); in thin_dtr()
4071 __pool_dec(tc->pool); in thin_dtr()
4072 dm_pool_close_thin_device(tc->td); in thin_dtr()
4073 dm_put_device(ti, tc->pool_dev); in thin_dtr()
4074 if (tc->origin_dev) in thin_dtr()
4075 dm_put_device(ti, tc->origin_dev); in thin_dtr()
4076 kfree(tc); in thin_dtr()
4096 struct thin_c *tc; in thin_ctr() local
4109 tc = ti->private = kzalloc(sizeof(*tc), GFP_KERNEL); in thin_ctr()
4110 if (!tc) { in thin_ctr()
4115 tc->thin_md = dm_table_get_md(ti->table); in thin_ctr()
4116 spin_lock_init(&tc->lock); in thin_ctr()
4117 INIT_LIST_HEAD(&tc->deferred_cells); in thin_ctr()
4118 bio_list_init(&tc->deferred_bio_list); in thin_ctr()
4119 bio_list_init(&tc->retry_on_resume_list); in thin_ctr()
4120 tc->sort_bio_list = RB_ROOT; in thin_ctr()
4128 tc->origin_dev = origin_dev; in thin_ctr()
4136 tc->pool_dev = pool_dev; in thin_ctr()
4138 if (read_dev_id(argv[1], (unsigned long long *)&tc->dev_id, 0)) { in thin_ctr()
4144 pool_md = dm_get_md(tc->pool_dev->bdev->bd_dev); in thin_ctr()
4151 tc->pool = __pool_table_lookup(pool_md); in thin_ctr()
4152 if (!tc->pool) { in thin_ctr()
4157 __pool_inc(tc->pool); in thin_ctr()
4159 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_ctr()
4165 r = dm_pool_open_thin_device(tc->pool->pmd, tc->dev_id, &tc->td); in thin_ctr()
4171 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block); in thin_ctr()
4180 if (tc->pool->pf.discard_enabled) { in thin_ctr()
4188 spin_lock_irqsave(&tc->pool->lock, flags); in thin_ctr()
4189 if (tc->pool->suspended) { in thin_ctr()
4190 spin_unlock_irqrestore(&tc->pool->lock, flags); in thin_ctr()
4196 atomic_set(&tc->refcount, 1); in thin_ctr()
4197 init_completion(&tc->can_destroy); in thin_ctr()
4198 list_add_tail_rcu(&tc->list, &tc->pool->active_thins); in thin_ctr()
4199 spin_unlock_irqrestore(&tc->pool->lock, flags); in thin_ctr()
4213 dm_pool_close_thin_device(tc->td); in thin_ctr()
4215 __pool_dec(tc->pool); in thin_ctr()
4219 dm_put_device(ti, tc->pool_dev); in thin_ctr()
4221 if (tc->origin_dev) in thin_ctr()
4222 dm_put_device(ti, tc->origin_dev); in thin_ctr()
4224 kfree(tc); in thin_ctr()
4245 struct pool *pool = h->tc->pool; in thin_endio()
4272 cell_defer_no_holder(h->tc, h->cell); in thin_endio()
4279 struct thin_c *tc = ti->private; in thin_presuspend() local
4282 noflush_work(tc, do_noflush_start); in thin_presuspend()
4287 struct thin_c *tc = ti->private; in thin_postsuspend() local
4293 noflush_work(tc, do_noflush_stop); in thin_postsuspend()
4298 struct thin_c *tc = ti->private; in thin_preresume() local
4300 if (tc->origin_dev) in thin_preresume()
4301 tc->origin_size = get_dev_size(tc->origin_dev->bdev); in thin_preresume()
4316 struct thin_c *tc = ti->private; in thin_status() local
4318 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_status()
4323 if (!tc->td) in thin_status()
4328 r = dm_thin_get_mapped_count(tc->td, &mapped); in thin_status()
4334 r = dm_thin_get_highest_mapped_block(tc->td, &highest); in thin_status()
4340 DMEMIT("%llu ", mapped * tc->pool->sectors_per_block); in thin_status()
4343 tc->pool->sectors_per_block) - 1); in thin_status()
4350 format_dev_t(buf, tc->pool_dev->bdev->bd_dev), in thin_status()
4351 (unsigned long) tc->dev_id); in thin_status()
4352 if (tc->origin_dev) in thin_status()
4353 DMEMIT(" %s", format_dev_t(buf, tc->origin_dev->bdev->bd_dev)); in thin_status()
4368 struct thin_c *tc = ti->private; in thin_iterate_devices() local
4369 struct pool *pool = tc->pool; in thin_iterate_devices()
4381 return fn(ti, tc->pool_dev, 0, pool->sectors_per_block * blocks, data); in thin_iterate_devices()
4388 struct thin_c *tc = ti->private; in thin_io_hints() local
4389 struct pool *pool = tc->pool; in thin_io_hints()