Lines Matching refs:td
852 struct dm_thin_device *td, *tmp; in __write_changed_details() local
856 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
857 if (!td->changed) in __write_changed_details()
860 key = td->id; in __write_changed_details()
862 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
863 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
864 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
865 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
873 if (td->open_count) in __write_changed_details()
874 td->changed = false; in __write_changed_details()
876 list_del(&td->list); in __write_changed_details()
877 kfree(td); in __write_changed_details()
998 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
1001 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
1002 if (td->open_count) in dm_pool_metadata_close()
1005 list_del(&td->list); in dm_pool_metadata_close()
1006 kfree(td); in dm_pool_metadata_close()
1038 struct dm_thin_device **td) in __open_device() argument
1057 *td = td2; in __open_device()
1080 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
1081 if (!*td) in __open_device()
1084 (*td)->pmd = pmd; in __open_device()
1085 (*td)->id = dev; in __open_device()
1086 (*td)->open_count = 1; in __open_device()
1087 (*td)->changed = changed; in __open_device()
1088 (*td)->aborted_with_changes = false; in __open_device()
1089 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
1090 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
1091 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
1092 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
1094 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
1099 static void __close_device(struct dm_thin_device *td) in __close_device() argument
1101 --td->open_count; in __close_device()
1110 struct dm_thin_device *td; in __create_thin() local
1136 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1142 __close_device(td); in __create_thin()
1164 struct dm_thin_device *td; in __set_snapshot_details() local
1166 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1170 td->changed = true; in __set_snapshot_details()
1171 td->snapshotted_time = time; in __set_snapshot_details()
1173 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1175 __close_device(td); in __set_snapshot_details()
1186 struct dm_thin_device *td; in __create_snap() local
1216 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1220 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1221 __close_device(td); in __create_snap()
1253 struct dm_thin_device *td; in __delete_device() local
1256 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1260 if (td->open_count > 1) { in __delete_device()
1261 __close_device(td); in __delete_device()
1265 list_del(&td->list); in __delete_device()
1266 kfree(td); in __delete_device()
1496 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1502 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1508 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1510 pmd_write_lock_in_core(td->pmd); in dm_pool_close_thin_device()
1511 __close_device(td); in dm_pool_close_thin_device()
1512 pmd_write_unlock(td->pmd); in dm_pool_close_thin_device()
1517 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1519 return td->id; in dm_thin_dev_id()
1528 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1530 return td->snapshotted_time > time; in __snapshotted_since()
1533 static void unpack_lookup_result(struct dm_thin_device *td, __le64 value, in unpack_lookup_result() argument
1543 result->shared = __snapshotted_since(td, exception_time); in unpack_lookup_result()
1546 static int __find_block(struct dm_thin_device *td, dm_block_t block, in __find_block() argument
1551 struct dm_pool_metadata *pmd = td->pmd; in __find_block()
1552 dm_block_t keys[2] = { td->id, block }; in __find_block()
1562 unpack_lookup_result(td, value, result); in __find_block()
1567 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1571 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1579 r = __find_block(td, block, can_issue_io, result); in dm_thin_find_block()
1585 static int __find_next_mapped_block(struct dm_thin_device *td, dm_block_t block, in __find_next_mapped_block() argument
1591 struct dm_pool_metadata *pmd = td->pmd; in __find_next_mapped_block()
1592 dm_block_t keys[2] = { td->id, block }; in __find_next_mapped_block()
1596 unpack_lookup_result(td, value, result); in __find_next_mapped_block()
1601 static int __find_mapped_range(struct dm_thin_device *td, in __find_mapped_range() argument
1613 r = __find_next_mapped_block(td, begin, &begin, &lookup); in __find_mapped_range()
1627 r = __find_block(td, begin, true, &lookup); in __find_mapped_range()
1647 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1653 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_mapped_range()
1657 r = __find_mapped_range(td, begin, end, thin_begin, thin_end, in dm_thin_find_mapped_range()
1665 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1670 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1671 dm_block_t keys[2] = { td->id, block }; in __insert()
1681 td->changed = true; in __insert()
1683 td->mapped_blocks++; in __insert()
1688 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1693 pmd_write_lock(td->pmd); in dm_thin_insert_block()
1694 if (!td->pmd->fail_io) in dm_thin_insert_block()
1695 r = __insert(td, block, data_block); in dm_thin_insert_block()
1696 pmd_write_unlock(td->pmd); in dm_thin_insert_block()
1701 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1705 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1706 dm_block_t keys[1] = { td->id }; in __remove_range()
1749 td->mapped_blocks -= total_count; in __remove_range()
1750 td->changed = true; in __remove_range()
1760 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1765 pmd_write_lock(td->pmd); in dm_thin_remove_range()
1766 if (!td->pmd->fail_io) in dm_thin_remove_range()
1767 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1768 pmd_write_unlock(td->pmd); in dm_thin_remove_range()
1813 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1817 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1818 r = td->changed; in dm_thin_changed_this_transaction()
1819 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1827 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1830 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1831 if (td->changed) { in dm_pool_changed_this_transaction()
1832 r = td->changed; in dm_pool_changed_this_transaction()
1841 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1845 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1846 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1847 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1891 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1893 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1894 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
1983 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
1986 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
1990 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
1998 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
2003 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
2005 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
2014 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
2018 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
2022 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()