Lines Matching refs:td
829 struct dm_thin_device *td, *tmp; in __write_changed_details() local
833 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
834 if (!td->changed) in __write_changed_details()
837 key = td->id; in __write_changed_details()
839 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
840 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
841 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
842 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
850 if (td->open_count) in __write_changed_details()
851 td->changed = false; in __write_changed_details()
853 list_del(&td->list); in __write_changed_details()
854 kfree(td); in __write_changed_details()
975 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
978 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
979 if (td->open_count) in dm_pool_metadata_close()
982 list_del(&td->list); in dm_pool_metadata_close()
983 kfree(td); in dm_pool_metadata_close()
1016 struct dm_thin_device **td) in __open_device() argument
1035 *td = td2; in __open_device()
1058 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
1059 if (!*td) in __open_device()
1062 (*td)->pmd = pmd; in __open_device()
1063 (*td)->id = dev; in __open_device()
1064 (*td)->open_count = 1; in __open_device()
1065 (*td)->changed = changed; in __open_device()
1066 (*td)->aborted_with_changes = false; in __open_device()
1067 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
1068 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
1069 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
1070 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
1072 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
1077 static void __close_device(struct dm_thin_device *td) in __close_device() argument
1079 --td->open_count; in __close_device()
1088 struct dm_thin_device *td; in __create_thin() local
1114 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1120 __close_device(td); in __create_thin()
1142 struct dm_thin_device *td; in __set_snapshot_details() local
1144 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1148 td->changed = true; in __set_snapshot_details()
1149 td->snapshotted_time = time; in __set_snapshot_details()
1151 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1153 __close_device(td); in __set_snapshot_details()
1164 struct dm_thin_device *td; in __create_snap() local
1194 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1198 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1199 __close_device(td); in __create_snap()
1231 struct dm_thin_device *td; in __delete_device() local
1234 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1238 if (td->open_count > 1) { in __delete_device()
1239 __close_device(td); in __delete_device()
1243 list_del(&td->list); in __delete_device()
1244 kfree(td); in __delete_device()
1474 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1480 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1486 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1488 pmd_write_lock_in_core(td->pmd); in dm_pool_close_thin_device()
1489 __close_device(td); in dm_pool_close_thin_device()
1490 pmd_write_unlock(td->pmd); in dm_pool_close_thin_device()
1495 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1497 return td->id; in dm_thin_dev_id()
1506 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1508 return td->snapshotted_time > time; in __snapshotted_since()
1511 static void unpack_lookup_result(struct dm_thin_device *td, __le64 value, in unpack_lookup_result() argument
1521 result->shared = __snapshotted_since(td, exception_time); in unpack_lookup_result()
1524 static int __find_block(struct dm_thin_device *td, dm_block_t block, in __find_block() argument
1529 struct dm_pool_metadata *pmd = td->pmd; in __find_block()
1530 dm_block_t keys[2] = { td->id, block }; in __find_block()
1540 unpack_lookup_result(td, value, result); in __find_block()
1545 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1549 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1557 r = __find_block(td, block, can_issue_io, result); in dm_thin_find_block()
1563 static int __find_next_mapped_block(struct dm_thin_device *td, dm_block_t block, in __find_next_mapped_block() argument
1569 struct dm_pool_metadata *pmd = td->pmd; in __find_next_mapped_block()
1570 dm_block_t keys[2] = { td->id, block }; in __find_next_mapped_block()
1574 unpack_lookup_result(td, value, result); in __find_next_mapped_block()
1579 static int __find_mapped_range(struct dm_thin_device *td, in __find_mapped_range() argument
1591 r = __find_next_mapped_block(td, begin, &begin, &lookup); in __find_mapped_range()
1605 r = __find_block(td, begin, true, &lookup); in __find_mapped_range()
1625 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1631 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_mapped_range()
1635 r = __find_mapped_range(td, begin, end, thin_begin, thin_end, in dm_thin_find_mapped_range()
1643 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1648 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1649 dm_block_t keys[2] = { td->id, block }; in __insert()
1659 td->changed = true; in __insert()
1661 td->mapped_blocks++; in __insert()
1666 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1671 pmd_write_lock(td->pmd); in dm_thin_insert_block()
1672 if (!td->pmd->fail_io) in dm_thin_insert_block()
1673 r = __insert(td, block, data_block); in dm_thin_insert_block()
1674 pmd_write_unlock(td->pmd); in dm_thin_insert_block()
1679 static int __remove(struct dm_thin_device *td, dm_block_t block) in __remove() argument
1682 struct dm_pool_metadata *pmd = td->pmd; in __remove()
1683 dm_block_t keys[2] = { td->id, block }; in __remove()
1689 td->mapped_blocks--; in __remove()
1690 td->changed = true; in __remove()
1695 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1699 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1700 dm_block_t keys[1] = { td->id }; in __remove_range()
1743 td->mapped_blocks -= total_count; in __remove_range()
1744 td->changed = true; in __remove_range()
1754 int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) in dm_thin_remove_block() argument
1758 pmd_write_lock(td->pmd); in dm_thin_remove_block()
1759 if (!td->pmd->fail_io) in dm_thin_remove_block()
1760 r = __remove(td, block); in dm_thin_remove_block()
1761 pmd_write_unlock(td->pmd); in dm_thin_remove_block()
1766 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1771 pmd_write_lock(td->pmd); in dm_thin_remove_range()
1772 if (!td->pmd->fail_io) in dm_thin_remove_range()
1773 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1774 pmd_write_unlock(td->pmd); in dm_thin_remove_range()
1819 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1823 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1824 r = td->changed; in dm_thin_changed_this_transaction()
1825 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1833 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1836 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1837 if (td->changed) { in dm_pool_changed_this_transaction()
1838 r = td->changed; in dm_pool_changed_this_transaction()
1847 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1851 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1852 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1853 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1897 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1899 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1900 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
2013 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
2016 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
2020 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
2028 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
2033 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
2035 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
2044 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
2048 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
2052 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()