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);
379 struct thin_c *tc; member
385 static void begin_discard(struct discard_op *op, struct thin_c *tc, struct bio *parent) in begin_discard() argument
389 op->tc = tc; in begin_discard()
397 struct thin_c *tc = op->tc; in issue_discard() local
398 sector_t s = block_to_sectors(tc->pool, data_b); in issue_discard()
399 sector_t len = block_to_sectors(tc->pool, data_e - data_b); in issue_discard()
401 return __blkdev_issue_discard(tc->pool_dev->bdev, s, len, GFP_NOWAIT, in issue_discard()
584 struct thin_c *tc; member
608 static void error_thin_bio_list(struct thin_c *tc, struct bio_list *master, in error_thin_bio_list() argument
615 spin_lock_irq(&tc->lock); in error_thin_bio_list()
617 spin_unlock_irq(&tc->lock); in error_thin_bio_list()
622 static void requeue_deferred_cells(struct thin_c *tc) in requeue_deferred_cells() argument
624 struct pool *pool = tc->pool; in requeue_deferred_cells()
630 spin_lock_irq(&tc->lock); in requeue_deferred_cells()
631 list_splice_init(&tc->deferred_cells, &cells); in requeue_deferred_cells()
632 spin_unlock_irq(&tc->lock); in requeue_deferred_cells()
638 static void requeue_io(struct thin_c *tc) in requeue_io() argument
644 spin_lock_irq(&tc->lock); in requeue_io()
645 __merge_bio_list(&bios, &tc->deferred_bio_list); in requeue_io()
646 __merge_bio_list(&bios, &tc->retry_on_resume_list); in requeue_io()
647 spin_unlock_irq(&tc->lock); in requeue_io()
650 requeue_deferred_cells(tc); in requeue_io()
655 struct thin_c *tc; in error_retry_list_with_code() local
658 list_for_each_entry_rcu(tc, &pool->active_thins, list) in error_retry_list_with_code()
659 error_thin_bio_list(tc, &tc->retry_on_resume_list, error); in error_retry_list_with_code()
675 static dm_block_t get_bio_block(struct thin_c *tc, struct bio *bio) in get_bio_block() argument
677 struct pool *pool = tc->pool; in get_bio_block()
691 static void get_bio_block_range(struct thin_c *tc, struct bio *bio, in get_bio_block_range() argument
694 struct pool *pool = tc->pool; in get_bio_block_range()
716 static void remap(struct thin_c *tc, struct bio *bio, dm_block_t block) in remap() argument
718 struct pool *pool = tc->pool; in remap()
721 bio_set_dev(bio, tc->pool_dev->bdev); in remap()
731 static void remap_to_origin(struct thin_c *tc, struct bio *bio) in remap_to_origin() argument
733 bio_set_dev(bio, tc->origin_dev->bdev); in remap_to_origin()
736 static int bio_triggers_commit(struct thin_c *tc, struct bio *bio) in bio_triggers_commit() argument
739 dm_thin_changed_this_transaction(tc->td); in bio_triggers_commit()
753 static void issue(struct thin_c *tc, struct bio *bio) in issue() argument
755 struct pool *pool = tc->pool; in issue()
757 if (!bio_triggers_commit(tc, bio)) { in issue()
767 if (dm_thin_aborted_changes(tc->td)) { in issue()
781 static void remap_to_origin_and_issue(struct thin_c *tc, struct bio *bio) in remap_to_origin_and_issue() argument
783 remap_to_origin(tc, bio); in remap_to_origin_and_issue()
784 issue(tc, bio); in remap_to_origin_and_issue()
787 static void remap_and_issue(struct thin_c *tc, struct bio *bio, in remap_and_issue() argument
790 remap(tc, bio, block); in remap_and_issue()
791 issue(tc, bio); in remap_and_issue()
813 struct thin_c *tc; member
830 struct pool *pool = m->tc->pool; in __complete_mapping_preparation()
841 struct pool *pool = m->tc->pool; in complete_mapping_preparation()
881 static void cell_defer_no_holder(struct thin_c *tc, struct dm_bio_prison_cell *cell) in cell_defer_no_holder() argument
883 struct pool *pool = tc->pool; in cell_defer_no_holder()
887 spin_lock_irqsave(&tc->lock, flags); in cell_defer_no_holder()
888 cell_release_no_holder(pool, cell, &tc->deferred_bio_list); in cell_defer_no_holder()
889 has_work = !bio_list_empty(&tc->deferred_bio_list); in cell_defer_no_holder()
890 spin_unlock_irqrestore(&tc->lock, flags); in cell_defer_no_holder()
896 static void thin_defer_bio(struct thin_c *tc, struct bio *bio);
899 struct thin_c *tc; member
914 inc_all_io_entry(info->tc->pool, bio); in __inc_remap_and_issue_cell()
926 static void inc_remap_and_issue_cell(struct thin_c *tc, in inc_remap_and_issue_cell() argument
933 info.tc = tc; in inc_remap_and_issue_cell()
942 cell_visit_release(tc->pool, __inc_remap_and_issue_cell, in inc_remap_and_issue_cell()
946 thin_defer_bio(tc, bio); in inc_remap_and_issue_cell()
949 remap_and_issue(info.tc, bio, block); in inc_remap_and_issue_cell()
954 cell_error(m->tc->pool, m->cell); in process_prepared_mapping_fail()
956 mempool_free(m, &m->tc->pool->mapping_pool); in process_prepared_mapping_fail()
959 static void complete_overwrite_bio(struct thin_c *tc, struct bio *bio) in complete_overwrite_bio() argument
961 struct pool *pool = tc->pool; in complete_overwrite_bio()
967 if (!bio_triggers_commit(tc, bio)) { in complete_overwrite_bio()
977 if (dm_thin_aborted_changes(tc->td)) { in complete_overwrite_bio()
993 struct thin_c *tc = m->tc; in process_prepared_mapping() local
994 struct pool *pool = tc->pool; in process_prepared_mapping()
1008 r = dm_thin_insert_block(tc->td, m->virt_begin, m->data_block); in process_prepared_mapping()
1022 inc_remap_and_issue_cell(tc, m->cell, m->data_block); in process_prepared_mapping()
1023 complete_overwrite_bio(tc, bio); in process_prepared_mapping()
1025 inc_all_io_entry(tc->pool, m->cell->holder); in process_prepared_mapping()
1026 remap_and_issue(tc, m->cell->holder, m->data_block); in process_prepared_mapping()
1027 inc_remap_and_issue_cell(tc, m->cell, m->data_block); in process_prepared_mapping()
1039 struct thin_c *tc = m->tc; in free_discard_mapping() local
1041 cell_defer_no_holder(tc, m->cell); in free_discard_mapping()
1042 mempool_free(m, &tc->pool->mapping_pool); in free_discard_mapping()
1060 struct thin_c *tc = m->tc; in process_prepared_discard_no_passdown() local
1062 r = dm_thin_remove_range(tc->td, m->cell->key.block_begin, m->cell->key.block_end); in process_prepared_discard_no_passdown()
1064 metadata_operation_failed(tc->pool, "dm_thin_remove_range", r); in process_prepared_discard_no_passdown()
1069 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_no_passdown()
1070 mempool_free(m, &tc->pool->mapping_pool); in process_prepared_discard_no_passdown()
1084 struct thin_c *tc = m->tc; in passdown_double_checking_shared_status() local
1085 struct pool *pool = tc->pool; in passdown_double_checking_shared_status()
1089 begin_discard(&op, tc, discard_parent); in passdown_double_checking_shared_status()
1127 struct pool *pool = m->tc->pool; in queue_passdown_pt2()
1148 struct thin_c *tc = m->tc; in process_prepared_discard_passdown_pt1() local
1149 struct pool *pool = tc->pool; in process_prepared_discard_passdown_pt1()
1158 r = dm_thin_remove_range(tc->td, m->virt_begin, m->virt_end); in process_prepared_discard_passdown_pt1()
1162 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt1()
1175 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt1()
1188 begin_discard(&op, tc, discard_parent); in process_prepared_discard_passdown_pt1()
1197 struct thin_c *tc = m->tc; in process_prepared_discard_passdown_pt2() local
1198 struct pool *pool = tc->pool; in process_prepared_discard_passdown_pt2()
1212 cell_defer_no_holder(tc, m->cell); in process_prepared_discard_passdown_pt2()
1278 static void ll_zero(struct thin_c *tc, struct dm_thin_new_mapping *m, in ll_zero() argument
1283 to.bdev = tc->pool_dev->bdev; in ll_zero()
1287 dm_kcopyd_zero(tc->pool->copier, 1, &to, 0, copy_complete, m); in ll_zero()
1290 static void remap_and_issue_overwrite(struct thin_c *tc, struct bio *bio, in remap_and_issue_overwrite() argument
1294 struct pool *pool = tc->pool; in remap_and_issue_overwrite()
1301 remap_and_issue(tc, bio, data_begin); in remap_and_issue_overwrite()
1307 static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_copy() argument
1313 struct pool *pool = tc->pool; in schedule_copy()
1316 m->tc = tc; in schedule_copy()
1339 remap_and_issue_overwrite(tc, bio, data_dest, m); in schedule_copy()
1347 to.bdev = tc->pool_dev->bdev; in schedule_copy()
1359 ll_zero(tc, m, in schedule_copy()
1368 static void schedule_internal_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_internal_copy() argument
1372 schedule_copy(tc, virt_block, tc->pool_dev, in schedule_internal_copy()
1374 tc->pool->sectors_per_block); in schedule_internal_copy()
1377 static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, in schedule_zero() argument
1381 struct pool *pool = tc->pool; in schedule_zero()
1385 m->tc = tc; in schedule_zero()
1398 remap_and_issue_overwrite(tc, bio, data_block, m); in schedule_zero()
1400 ll_zero(tc, m, data_block * pool->sectors_per_block, in schedule_zero()
1406 static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block, in schedule_external_copy() argument
1410 struct pool *pool = tc->pool; in schedule_external_copy()
1414 if (virt_block_end <= tc->origin_size) in schedule_external_copy()
1415 schedule_copy(tc, virt_block, tc->origin_dev, in schedule_external_copy()
1419 else if (virt_block_begin < tc->origin_size) in schedule_external_copy()
1420 schedule_copy(tc, virt_block, tc->origin_dev, in schedule_external_copy()
1422 tc->origin_size - virt_block_begin); in schedule_external_copy()
1425 schedule_zero(tc, virt_block, data_dest, cell, bio); in schedule_external_copy()
1512 static int alloc_data_block(struct thin_c *tc, dm_block_t *result) in alloc_data_block() argument
1516 struct pool *pool = tc->pool; in alloc_data_block()
1582 struct thin_c *tc = h->tc; in retry_on_resume() local
1584 spin_lock_irq(&tc->lock); in retry_on_resume()
1585 bio_list_add(&tc->retry_on_resume_list, bio); in retry_on_resume()
1586 spin_unlock_irq(&tc->lock); in retry_on_resume()
1643 static void process_discard_cell_no_passdown(struct thin_c *tc, in process_discard_cell_no_passdown() argument
1646 struct pool *pool = tc->pool; in process_discard_cell_no_passdown()
1653 m->tc = tc; in process_discard_cell_no_passdown()
1663 static void break_up_discard_bio(struct thin_c *tc, dm_block_t begin, dm_block_t end, in break_up_discard_bio() argument
1666 struct pool *pool = tc->pool; in break_up_discard_bio()
1681 r = dm_thin_find_mapped_range(tc->td, begin, end, &virt_begin, &virt_end, in break_up_discard_bio()
1690 build_key(tc->td, PHYSICAL, data_begin, data_begin + (virt_end - virt_begin), &data_key); in break_up_discard_bio()
1691 if (bio_detain(tc->pool, &data_key, NULL, &data_cell)) { in break_up_discard_bio()
1702 m->tc = tc; in break_up_discard_bio()
1726 static void process_discard_cell_passdown(struct thin_c *tc, struct dm_bio_prison_cell *virt_cell) in process_discard_cell_passdown() argument
1737 break_up_discard_bio(tc, virt_cell->key.block_begin, virt_cell->key.block_end, bio); in process_discard_cell_passdown()
1747 static void process_discard_bio(struct thin_c *tc, struct bio *bio) in process_discard_bio() argument
1753 get_bio_block_range(tc, bio, &begin, &end); in process_discard_bio()
1762 build_key(tc->td, VIRTUAL, begin, end, &virt_key); in process_discard_bio()
1763 if (bio_detain(tc->pool, &virt_key, bio, &virt_cell)) in process_discard_bio()
1773 tc->pool->process_discard_cell(tc, virt_cell); in process_discard_bio()
1776 static void break_sharing(struct thin_c *tc, struct bio *bio, dm_block_t block, in break_sharing() argument
1783 struct pool *pool = tc->pool; in break_sharing()
1785 r = alloc_data_block(tc, &data_block); in break_sharing()
1788 schedule_internal_copy(tc, block, lookup_result->block, in break_sharing()
1817 h->shared_read_entry = dm_deferred_entry_inc(info->tc->pool->shared_read_ds); in __remap_and_issue_shared_cell()
1818 inc_all_io_entry(info->tc->pool, bio); in __remap_and_issue_shared_cell()
1824 static void remap_and_issue_shared_cell(struct thin_c *tc, in remap_and_issue_shared_cell() argument
1831 info.tc = tc; in remap_and_issue_shared_cell()
1835 cell_visit_release(tc->pool, __remap_and_issue_shared_cell, in remap_and_issue_shared_cell()
1839 thin_defer_bio(tc, bio); in remap_and_issue_shared_cell()
1842 remap_and_issue(tc, bio, block); in remap_and_issue_shared_cell()
1845 static void process_shared_bio(struct thin_c *tc, struct bio *bio, in process_shared_bio() argument
1851 struct pool *pool = tc->pool; in process_shared_bio()
1858 build_data_key(tc->td, lookup_result->block, &key); in process_shared_bio()
1860 cell_defer_no_holder(tc, virt_cell); in process_shared_bio()
1865 break_sharing(tc, bio, block, &key, lookup_result, data_cell); in process_shared_bio()
1866 cell_defer_no_holder(tc, virt_cell); in process_shared_bio()
1872 remap_and_issue(tc, bio, lookup_result->block); in process_shared_bio()
1874 remap_and_issue_shared_cell(tc, data_cell, lookup_result->block); in process_shared_bio()
1875 remap_and_issue_shared_cell(tc, virt_cell, lookup_result->block); in process_shared_bio()
1879 static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block, in provision_block() argument
1884 struct pool *pool = tc->pool; in provision_block()
1891 cell_defer_no_holder(tc, cell); in provision_block()
1893 remap_and_issue(tc, bio, 0); in provision_block()
1902 cell_defer_no_holder(tc, cell); in provision_block()
1907 r = alloc_data_block(tc, &data_block); in provision_block()
1910 if (tc->origin_dev) in provision_block()
1911 schedule_external_copy(tc, block, data_block, cell, bio); in provision_block()
1913 schedule_zero(tc, block, data_block, cell, bio); in provision_block()
1928 static void process_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell() argument
1931 struct pool *pool = tc->pool; in process_cell()
1933 dm_block_t block = get_bio_block(tc, bio); in process_cell()
1936 if (tc->requeue_mode) { in process_cell()
1941 r = dm_thin_find_block(tc->td, block, 1, &lookup_result); in process_cell()
1945 process_shared_bio(tc, bio, block, &lookup_result, cell); in process_cell()
1948 remap_and_issue(tc, bio, lookup_result.block); in process_cell()
1949 inc_remap_and_issue_cell(tc, cell, lookup_result.block); in process_cell()
1954 if (bio_data_dir(bio) == READ && tc->origin_dev) { in process_cell()
1956 cell_defer_no_holder(tc, cell); in process_cell()
1958 if (bio_end_sector(bio) <= tc->origin_size) in process_cell()
1959 remap_to_origin_and_issue(tc, bio); in process_cell()
1961 else if (bio->bi_iter.bi_sector < tc->origin_size) { in process_cell()
1963 bio->bi_iter.bi_size = (tc->origin_size - bio->bi_iter.bi_sector) << SECTOR_SHIFT; in process_cell()
1964 remap_to_origin_and_issue(tc, bio); in process_cell()
1971 provision_block(tc, bio, block, cell); in process_cell()
1977 cell_defer_no_holder(tc, cell); in process_cell()
1983 static void process_bio(struct thin_c *tc, struct bio *bio) in process_bio() argument
1985 struct pool *pool = tc->pool; in process_bio()
1986 dm_block_t block = get_bio_block(tc, bio); in process_bio()
1994 build_virtual_key(tc->td, block, &key); in process_bio()
1998 process_cell(tc, cell); in process_bio()
2001 static void __process_bio_read_only(struct thin_c *tc, struct bio *bio, in __process_bio_read_only() argument
2006 dm_block_t block = get_bio_block(tc, bio); in __process_bio_read_only()
2009 r = dm_thin_find_block(tc->td, block, 1, &lookup_result); in __process_bio_read_only()
2013 handle_unserviceable_bio(tc->pool, bio); in __process_bio_read_only()
2015 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
2017 inc_all_io_entry(tc->pool, bio); in __process_bio_read_only()
2018 remap_and_issue(tc, bio, lookup_result.block); in __process_bio_read_only()
2020 inc_remap_and_issue_cell(tc, cell, lookup_result.block); in __process_bio_read_only()
2026 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
2028 handle_unserviceable_bio(tc->pool, bio); in __process_bio_read_only()
2032 if (tc->origin_dev) { in __process_bio_read_only()
2033 inc_all_io_entry(tc->pool, bio); in __process_bio_read_only()
2034 remap_to_origin_and_issue(tc, bio); in __process_bio_read_only()
2046 cell_defer_no_holder(tc, cell); in __process_bio_read_only()
2052 static void process_bio_read_only(struct thin_c *tc, struct bio *bio) in process_bio_read_only() argument
2054 __process_bio_read_only(tc, bio, NULL); in process_bio_read_only()
2057 static void process_cell_read_only(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_read_only() argument
2059 __process_bio_read_only(tc, cell->holder, cell); in process_cell_read_only()
2062 static void process_bio_success(struct thin_c *tc, struct bio *bio) in process_bio_success() argument
2067 static void process_bio_fail(struct thin_c *tc, struct bio *bio) in process_bio_fail() argument
2072 static void process_cell_success(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_success() argument
2074 cell_success(tc->pool, cell); in process_cell_success()
2077 static void process_cell_fail(struct thin_c *tc, struct dm_bio_prison_cell *cell) in process_cell_fail() argument
2079 cell_error(tc->pool, cell); in process_cell_fail()
2095 static void __thin_bio_rb_add(struct thin_c *tc, struct bio *bio) in __thin_bio_rb_add() argument
2101 rbp = &tc->sort_bio_list.rb_node; in __thin_bio_rb_add()
2115 rb_insert_color(&pbd->rb_node, &tc->sort_bio_list); in __thin_bio_rb_add()
2118 static void __extract_sorted_bios(struct thin_c *tc) in __extract_sorted_bios() argument
2124 for (node = rb_first(&tc->sort_bio_list); node; node = rb_next(node)) { in __extract_sorted_bios()
2128 bio_list_add(&tc->deferred_bio_list, bio); in __extract_sorted_bios()
2129 rb_erase(&pbd->rb_node, &tc->sort_bio_list); in __extract_sorted_bios()
2132 WARN_ON(!RB_EMPTY_ROOT(&tc->sort_bio_list)); in __extract_sorted_bios()
2135 static void __sort_thin_deferred_bios(struct thin_c *tc) in __sort_thin_deferred_bios() argument
2141 bio_list_merge(&bios, &tc->deferred_bio_list); in __sort_thin_deferred_bios()
2142 bio_list_init(&tc->deferred_bio_list); in __sort_thin_deferred_bios()
2146 __thin_bio_rb_add(tc, bio); in __sort_thin_deferred_bios()
2153 __extract_sorted_bios(tc); in __sort_thin_deferred_bios()
2156 static void process_thin_deferred_bios(struct thin_c *tc) in process_thin_deferred_bios() argument
2158 struct pool *pool = tc->pool; in process_thin_deferred_bios()
2164 if (tc->requeue_mode) { in process_thin_deferred_bios()
2165 error_thin_bio_list(tc, &tc->deferred_bio_list, in process_thin_deferred_bios()
2172 spin_lock_irq(&tc->lock); in process_thin_deferred_bios()
2174 if (bio_list_empty(&tc->deferred_bio_list)) { in process_thin_deferred_bios()
2175 spin_unlock_irq(&tc->lock); in process_thin_deferred_bios()
2179 __sort_thin_deferred_bios(tc); in process_thin_deferred_bios()
2181 bio_list_merge(&bios, &tc->deferred_bio_list); in process_thin_deferred_bios()
2182 bio_list_init(&tc->deferred_bio_list); in process_thin_deferred_bios()
2184 spin_unlock_irq(&tc->lock); in process_thin_deferred_bios()
2194 spin_lock_irq(&tc->lock); in process_thin_deferred_bios()
2195 bio_list_add(&tc->deferred_bio_list, bio); in process_thin_deferred_bios()
2196 bio_list_merge(&tc->deferred_bio_list, &bios); in process_thin_deferred_bios()
2197 spin_unlock_irq(&tc->lock); in process_thin_deferred_bios()
2202 pool->process_discard(tc, bio); in process_thin_deferred_bios()
2204 pool->process_bio(tc, bio); in process_thin_deferred_bios()
2249 static void process_thin_deferred_cells(struct thin_c *tc) in process_thin_deferred_cells() argument
2251 struct pool *pool = tc->pool; in process_thin_deferred_cells()
2258 spin_lock_irq(&tc->lock); in process_thin_deferred_cells()
2259 list_splice_init(&tc->deferred_cells, &cells); in process_thin_deferred_cells()
2260 spin_unlock_irq(&tc->lock); in process_thin_deferred_cells()
2266 count = sort_cells(tc->pool, &cells); in process_thin_deferred_cells()
2281 spin_lock_irq(&tc->lock); in process_thin_deferred_cells()
2282 list_splice(&cells, &tc->deferred_cells); in process_thin_deferred_cells()
2283 spin_unlock_irq(&tc->lock); in process_thin_deferred_cells()
2288 pool->process_discard_cell(tc, cell); in process_thin_deferred_cells()
2290 pool->process_cell(tc, cell); in process_thin_deferred_cells()
2295 static void thin_get(struct thin_c *tc);
2296 static void thin_put(struct thin_c *tc);
2305 struct thin_c *tc = NULL; in get_first_thin() local
2309 tc = list_entry_rcu(pool->active_thins.next, struct thin_c, list); in get_first_thin()
2310 thin_get(tc); in get_first_thin()
2314 return tc; in get_first_thin()
2317 static struct thin_c *get_next_thin(struct pool *pool, struct thin_c *tc) in get_next_thin() argument
2319 struct thin_c *old_tc = tc; in get_next_thin()
2322 list_for_each_entry_continue_rcu(tc, &pool->active_thins, list) { in get_next_thin()
2323 thin_get(tc); in get_next_thin()
2326 return tc; in get_next_thin()
2338 struct thin_c *tc; in process_deferred_bios() local
2340 tc = get_first_thin(pool); in process_deferred_bios()
2341 while (tc) { in process_deferred_bios()
2342 process_thin_deferred_cells(tc); in process_deferred_bios()
2343 process_thin_deferred_bios(tc); in process_deferred_bios()
2344 tc = get_next_thin(pool, tc); in process_deferred_bios()
2465 struct thin_c *tc; member
2476 w->tc->requeue_mode = true; in do_noflush_start()
2477 requeue_io(w->tc); in do_noflush_start()
2484 w->tc->requeue_mode = false; in do_noflush_stop()
2488 static void noflush_work(struct thin_c *tc, void (*fn)(struct work_struct *)) in noflush_work() argument
2492 w.tc = tc; in noflush_work()
2493 pool_work_wait(&w.pw, tc->pool, fn); in noflush_work()
2649 static void thin_defer_bio(struct thin_c *tc, struct bio *bio) in thin_defer_bio() argument
2651 struct pool *pool = tc->pool; in thin_defer_bio()
2653 spin_lock_irq(&tc->lock); in thin_defer_bio()
2654 bio_list_add(&tc->deferred_bio_list, bio); in thin_defer_bio()
2655 spin_unlock_irq(&tc->lock); in thin_defer_bio()
2660 static void thin_defer_bio_with_throttle(struct thin_c *tc, struct bio *bio) in thin_defer_bio_with_throttle() argument
2662 struct pool *pool = tc->pool; in thin_defer_bio_with_throttle()
2665 thin_defer_bio(tc, bio); in thin_defer_bio_with_throttle()
2669 static void thin_defer_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell) in thin_defer_cell() argument
2671 struct pool *pool = tc->pool; in thin_defer_cell()
2674 spin_lock_irq(&tc->lock); in thin_defer_cell()
2675 list_add_tail(&cell->user_list, &tc->deferred_cells); in thin_defer_cell()
2676 spin_unlock_irq(&tc->lock); in thin_defer_cell()
2682 static void thin_hook_bio(struct thin_c *tc, struct bio *bio) in thin_hook_bio() argument
2686 h->tc = tc; in thin_hook_bio()
2699 struct thin_c *tc = ti->private; in thin_bio_map() local
2700 dm_block_t block = get_bio_block(tc, bio); in thin_bio_map()
2701 struct dm_thin_device *td = tc->td; in thin_bio_map()
2706 thin_hook_bio(tc, bio); in thin_bio_map()
2708 if (tc->requeue_mode) { in thin_bio_map()
2714 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_bio_map()
2720 thin_defer_bio_with_throttle(tc, bio); in thin_bio_map()
2728 build_virtual_key(tc->td, block, &key); in thin_bio_map()
2729 if (bio_detain(tc->pool, &key, bio, &virt_cell)) in thin_bio_map()
2754 thin_defer_cell(tc, virt_cell); in thin_bio_map()
2758 build_data_key(tc->td, result.block, &key); in thin_bio_map()
2759 if (bio_detain(tc->pool, &key, bio, &data_cell)) { in thin_bio_map()
2760 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2764 inc_all_io_entry(tc->pool, bio); in thin_bio_map()
2765 cell_defer_no_holder(tc, data_cell); in thin_bio_map()
2766 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2768 remap(tc, bio, result.block); in thin_bio_map()
2773 thin_defer_cell(tc, virt_cell); in thin_bio_map()
2783 cell_defer_no_holder(tc, virt_cell); in thin_bio_map()
2790 struct thin_c *tc; in requeue_bios() local
2793 list_for_each_entry_rcu(tc, &pool->active_thins, list) { in requeue_bios()
2794 spin_lock_irq(&tc->lock); in requeue_bios()
2795 bio_list_merge(&tc->deferred_bio_list, &tc->retry_on_resume_list); in requeue_bios()
2796 bio_list_init(&tc->retry_on_resume_list); in requeue_bios()
2797 spin_unlock_irq(&tc->lock); in requeue_bios()
3561 struct thin_c *tc; in pool_suspend_active_thins() local
3564 tc = get_first_thin(pool); in pool_suspend_active_thins()
3565 while (tc) { in pool_suspend_active_thins()
3566 dm_internal_suspend_noflush(tc->thin_md); in pool_suspend_active_thins()
3567 tc = get_next_thin(pool, tc); in pool_suspend_active_thins()
3573 struct thin_c *tc; in pool_resume_active_thins() local
3576 tc = get_first_thin(pool); in pool_resume_active_thins()
3577 while (tc) { in pool_resume_active_thins()
3578 dm_internal_resume(tc->thin_md); in pool_resume_active_thins()
3579 tc = get_next_thin(pool, tc); in pool_resume_active_thins()
4091 static void thin_get(struct thin_c *tc) in thin_get() argument
4093 refcount_inc(&tc->refcount); in thin_get()
4096 static void thin_put(struct thin_c *tc) in thin_put() argument
4098 if (refcount_dec_and_test(&tc->refcount)) in thin_put()
4099 complete(&tc->can_destroy); in thin_put()
4104 struct thin_c *tc = ti->private; in thin_dtr() local
4106 spin_lock_irq(&tc->pool->lock); in thin_dtr()
4107 list_del_rcu(&tc->list); in thin_dtr()
4108 spin_unlock_irq(&tc->pool->lock); in thin_dtr()
4111 thin_put(tc); in thin_dtr()
4112 wait_for_completion(&tc->can_destroy); in thin_dtr()
4116 __pool_dec(tc->pool); in thin_dtr()
4117 dm_pool_close_thin_device(tc->td); in thin_dtr()
4118 dm_put_device(ti, tc->pool_dev); in thin_dtr()
4119 if (tc->origin_dev) in thin_dtr()
4120 dm_put_device(ti, tc->origin_dev); in thin_dtr()
4121 kfree(tc); in thin_dtr()
4141 struct thin_c *tc; in thin_ctr() local
4153 tc = ti->private = kzalloc(sizeof(*tc), GFP_KERNEL); in thin_ctr()
4154 if (!tc) { in thin_ctr()
4159 tc->thin_md = dm_table_get_md(ti->table); in thin_ctr()
4160 spin_lock_init(&tc->lock); in thin_ctr()
4161 INIT_LIST_HEAD(&tc->deferred_cells); in thin_ctr()
4162 bio_list_init(&tc->deferred_bio_list); in thin_ctr()
4163 bio_list_init(&tc->retry_on_resume_list); in thin_ctr()
4164 tc->sort_bio_list = RB_ROOT; in thin_ctr()
4178 tc->origin_dev = origin_dev; in thin_ctr()
4186 tc->pool_dev = pool_dev; in thin_ctr()
4188 if (read_dev_id(argv[1], (unsigned long long *)&tc->dev_id, 0)) { in thin_ctr()
4194 pool_md = dm_get_md(tc->pool_dev->bdev->bd_dev); in thin_ctr()
4201 tc->pool = __pool_table_lookup(pool_md); in thin_ctr()
4202 if (!tc->pool) { in thin_ctr()
4207 __pool_inc(tc->pool); in thin_ctr()
4209 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_ctr()
4215 r = dm_pool_open_thin_device(tc->pool->pmd, tc->dev_id, &tc->td); in thin_ctr()
4221 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block); in thin_ctr()
4231 if (tc->pool->pf.discard_enabled) { in thin_ctr()
4238 spin_lock_irq(&tc->pool->lock); in thin_ctr()
4239 if (tc->pool->suspended) { in thin_ctr()
4240 spin_unlock_irq(&tc->pool->lock); in thin_ctr()
4246 refcount_set(&tc->refcount, 1); in thin_ctr()
4247 init_completion(&tc->can_destroy); in thin_ctr()
4248 list_add_tail_rcu(&tc->list, &tc->pool->active_thins); in thin_ctr()
4249 spin_unlock_irq(&tc->pool->lock); in thin_ctr()
4263 dm_pool_close_thin_device(tc->td); in thin_ctr()
4265 __pool_dec(tc->pool); in thin_ctr()
4269 dm_put_device(ti, tc->pool_dev); in thin_ctr()
4271 if (tc->origin_dev) in thin_ctr()
4272 dm_put_device(ti, tc->origin_dev); in thin_ctr()
4274 kfree(tc); in thin_ctr()
4295 struct pool *pool = h->tc->pool; in thin_endio()
4322 cell_defer_no_holder(h->tc, h->cell); in thin_endio()
4329 struct thin_c *tc = ti->private; in thin_presuspend() local
4332 noflush_work(tc, do_noflush_start); in thin_presuspend()
4337 struct thin_c *tc = ti->private; in thin_postsuspend() local
4343 noflush_work(tc, do_noflush_stop); in thin_postsuspend()
4348 struct thin_c *tc = ti->private; in thin_preresume() local
4350 if (tc->origin_dev) in thin_preresume()
4351 tc->origin_size = get_dev_size(tc->origin_dev->bdev); in thin_preresume()
4366 struct thin_c *tc = ti->private; in thin_status() local
4368 if (get_pool_mode(tc->pool) == PM_FAIL) { in thin_status()
4373 if (!tc->td) in thin_status()
4378 r = dm_thin_get_mapped_count(tc->td, &mapped); in thin_status()
4384 r = dm_thin_get_highest_mapped_block(tc->td, &highest); in thin_status()
4390 DMEMIT("%llu ", mapped * tc->pool->sectors_per_block); in thin_status()
4393 tc->pool->sectors_per_block) - 1); in thin_status()
4400 format_dev_t(buf, tc->pool_dev->bdev->bd_dev), in thin_status()
4401 (unsigned long) tc->dev_id); in thin_status()
4402 if (tc->origin_dev) in thin_status()
4403 DMEMIT(" %s", format_dev_t(buf, tc->origin_dev->bdev->bd_dev)); in thin_status()
4422 struct thin_c *tc = ti->private; in thin_iterate_devices() local
4423 struct pool *pool = tc->pool; in thin_iterate_devices()
4435 return fn(ti, tc->pool_dev, 0, pool->sectors_per_block * blocks, data); in thin_iterate_devices()
4442 struct thin_c *tc = ti->private; in thin_io_hints() local
4443 struct pool *pool = tc->pool; in thin_io_hints()