Lines Matching refs:td

795 	struct dm_thin_device *td, *tmp;  in __write_changed_details()  local
799 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
800 if (!td->changed) in __write_changed_details()
803 key = td->id; in __write_changed_details()
805 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
806 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
807 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
808 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
816 if (td->open_count) in __write_changed_details()
817 td->changed = false; in __write_changed_details()
819 list_del(&td->list); in __write_changed_details()
820 kfree(td); in __write_changed_details()
941 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
944 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
945 if (td->open_count) in dm_pool_metadata_close()
948 list_del(&td->list); in dm_pool_metadata_close()
949 kfree(td); in dm_pool_metadata_close()
982 struct dm_thin_device **td) in __open_device() argument
1001 *td = td2; in __open_device()
1024 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
1025 if (!*td) in __open_device()
1028 (*td)->pmd = pmd; in __open_device()
1029 (*td)->id = dev; in __open_device()
1030 (*td)->open_count = 1; in __open_device()
1031 (*td)->changed = changed; in __open_device()
1032 (*td)->aborted_with_changes = false; in __open_device()
1033 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
1034 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
1035 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
1036 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
1038 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
1043 static void __close_device(struct dm_thin_device *td) in __close_device() argument
1045 --td->open_count; in __close_device()
1054 struct dm_thin_device *td; in __create_thin() local
1080 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1086 __close_device(td); in __create_thin()
1108 struct dm_thin_device *td; in __set_snapshot_details() local
1110 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1114 td->changed = true; in __set_snapshot_details()
1115 td->snapshotted_time = time; in __set_snapshot_details()
1117 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1119 __close_device(td); in __set_snapshot_details()
1130 struct dm_thin_device *td; in __create_snap() local
1160 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1164 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1165 __close_device(td); in __create_snap()
1197 struct dm_thin_device *td; in __delete_device() local
1200 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1204 if (td->open_count > 1) { in __delete_device()
1205 __close_device(td); in __delete_device()
1209 list_del(&td->list); in __delete_device()
1210 kfree(td); in __delete_device()
1440 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1446 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1452 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1454 pmd_write_lock_in_core(td->pmd); in dm_pool_close_thin_device()
1455 __close_device(td); in dm_pool_close_thin_device()
1456 pmd_write_unlock(td->pmd); in dm_pool_close_thin_device()
1461 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1463 return td->id; in dm_thin_dev_id()
1472 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1474 return td->snapshotted_time > time; in __snapshotted_since()
1477 static void unpack_lookup_result(struct dm_thin_device *td, __le64 value, in unpack_lookup_result() argument
1487 result->shared = __snapshotted_since(td, exception_time); in unpack_lookup_result()
1490 static int __find_block(struct dm_thin_device *td, dm_block_t block, in __find_block() argument
1495 struct dm_pool_metadata *pmd = td->pmd; in __find_block()
1496 dm_block_t keys[2] = { td->id, block }; in __find_block()
1506 unpack_lookup_result(td, value, result); in __find_block()
1511 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1515 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1523 r = __find_block(td, block, can_issue_io, result); in dm_thin_find_block()
1529 static int __find_next_mapped_block(struct dm_thin_device *td, dm_block_t block, in __find_next_mapped_block() argument
1535 struct dm_pool_metadata *pmd = td->pmd; in __find_next_mapped_block()
1536 dm_block_t keys[2] = { td->id, block }; in __find_next_mapped_block()
1540 unpack_lookup_result(td, value, result); in __find_next_mapped_block()
1545 static int __find_mapped_range(struct dm_thin_device *td, in __find_mapped_range() argument
1557 r = __find_next_mapped_block(td, begin, &begin, &lookup); in __find_mapped_range()
1571 r = __find_block(td, begin, true, &lookup); in __find_mapped_range()
1591 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1597 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_mapped_range()
1601 r = __find_mapped_range(td, begin, end, thin_begin, thin_end, in dm_thin_find_mapped_range()
1609 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1614 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1615 dm_block_t keys[2] = { td->id, block }; in __insert()
1625 td->changed = true; in __insert()
1627 td->mapped_blocks++; in __insert()
1632 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1637 pmd_write_lock(td->pmd); in dm_thin_insert_block()
1638 if (!td->pmd->fail_io) in dm_thin_insert_block()
1639 r = __insert(td, block, data_block); in dm_thin_insert_block()
1640 pmd_write_unlock(td->pmd); in dm_thin_insert_block()
1645 static int __remove(struct dm_thin_device *td, dm_block_t block) in __remove() argument
1648 struct dm_pool_metadata *pmd = td->pmd; in __remove()
1649 dm_block_t keys[2] = { td->id, block }; in __remove()
1655 td->mapped_blocks--; in __remove()
1656 td->changed = true; in __remove()
1661 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1665 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1666 dm_block_t keys[1] = { td->id }; in __remove_range()
1709 td->mapped_blocks -= total_count; in __remove_range()
1710 td->changed = true; in __remove_range()
1720 int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) in dm_thin_remove_block() argument
1724 pmd_write_lock(td->pmd); in dm_thin_remove_block()
1725 if (!td->pmd->fail_io) in dm_thin_remove_block()
1726 r = __remove(td, block); in dm_thin_remove_block()
1727 pmd_write_unlock(td->pmd); in dm_thin_remove_block()
1732 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1737 pmd_write_lock(td->pmd); in dm_thin_remove_range()
1738 if (!td->pmd->fail_io) in dm_thin_remove_range()
1739 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1740 pmd_write_unlock(td->pmd); in dm_thin_remove_range()
1789 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1793 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1794 r = td->changed; in dm_thin_changed_this_transaction()
1795 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1803 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1806 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1807 if (td->changed) { in dm_pool_changed_this_transaction()
1808 r = td->changed; in dm_pool_changed_this_transaction()
1817 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1821 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1822 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1823 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1867 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1869 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1870 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
1950 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
1953 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
1957 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
1965 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
1970 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
1972 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
1981 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
1985 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
1989 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()