Lines Matching refs:td

818 	struct dm_thin_device *td, *tmp;  in __write_changed_details()  local
822 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
823 if (!td->changed) in __write_changed_details()
826 key = td->id; in __write_changed_details()
828 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
829 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
830 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
831 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
839 if (td->open_count) in __write_changed_details()
840 td->changed = false; in __write_changed_details()
842 list_del(&td->list); in __write_changed_details()
843 kfree(td); in __write_changed_details()
964 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
967 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
968 if (td->open_count) in dm_pool_metadata_close()
971 list_del(&td->list); in dm_pool_metadata_close()
972 kfree(td); in dm_pool_metadata_close()
1005 struct dm_thin_device **td) in __open_device() argument
1024 *td = td2; in __open_device()
1047 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
1048 if (!*td) in __open_device()
1051 (*td)->pmd = pmd; in __open_device()
1052 (*td)->id = dev; in __open_device()
1053 (*td)->open_count = 1; in __open_device()
1054 (*td)->changed = changed; in __open_device()
1055 (*td)->aborted_with_changes = false; in __open_device()
1056 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
1057 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
1058 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
1059 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
1061 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
1066 static void __close_device(struct dm_thin_device *td) in __close_device() argument
1068 --td->open_count; in __close_device()
1077 struct dm_thin_device *td; in __create_thin() local
1103 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1109 __close_device(td); in __create_thin()
1131 struct dm_thin_device *td; in __set_snapshot_details() local
1133 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1137 td->changed = true; in __set_snapshot_details()
1138 td->snapshotted_time = time; in __set_snapshot_details()
1140 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1142 __close_device(td); in __set_snapshot_details()
1153 struct dm_thin_device *td; in __create_snap() local
1183 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1187 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1188 __close_device(td); in __create_snap()
1220 struct dm_thin_device *td; in __delete_device() local
1223 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1227 if (td->open_count > 1) { in __delete_device()
1228 __close_device(td); in __delete_device()
1232 list_del(&td->list); in __delete_device()
1233 kfree(td); in __delete_device()
1463 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1469 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1475 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1477 pmd_write_lock_in_core(td->pmd); in dm_pool_close_thin_device()
1478 __close_device(td); in dm_pool_close_thin_device()
1479 pmd_write_unlock(td->pmd); in dm_pool_close_thin_device()
1484 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1486 return td->id; in dm_thin_dev_id()
1495 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1497 return td->snapshotted_time > time; in __snapshotted_since()
1500 static void unpack_lookup_result(struct dm_thin_device *td, __le64 value, in unpack_lookup_result() argument
1510 result->shared = __snapshotted_since(td, exception_time); in unpack_lookup_result()
1513 static int __find_block(struct dm_thin_device *td, dm_block_t block, in __find_block() argument
1518 struct dm_pool_metadata *pmd = td->pmd; in __find_block()
1519 dm_block_t keys[2] = { td->id, block }; in __find_block()
1529 unpack_lookup_result(td, value, result); in __find_block()
1534 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1538 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1546 r = __find_block(td, block, can_issue_io, result); in dm_thin_find_block()
1552 static int __find_next_mapped_block(struct dm_thin_device *td, dm_block_t block, in __find_next_mapped_block() argument
1558 struct dm_pool_metadata *pmd = td->pmd; in __find_next_mapped_block()
1559 dm_block_t keys[2] = { td->id, block }; in __find_next_mapped_block()
1563 unpack_lookup_result(td, value, result); in __find_next_mapped_block()
1568 static int __find_mapped_range(struct dm_thin_device *td, in __find_mapped_range() argument
1580 r = __find_next_mapped_block(td, begin, &begin, &lookup); in __find_mapped_range()
1594 r = __find_block(td, begin, true, &lookup); in __find_mapped_range()
1614 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1620 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_mapped_range()
1624 r = __find_mapped_range(td, begin, end, thin_begin, thin_end, in dm_thin_find_mapped_range()
1632 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1637 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1638 dm_block_t keys[2] = { td->id, block }; in __insert()
1648 td->changed = true; in __insert()
1650 td->mapped_blocks++; in __insert()
1655 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1660 pmd_write_lock(td->pmd); in dm_thin_insert_block()
1661 if (!td->pmd->fail_io) in dm_thin_insert_block()
1662 r = __insert(td, block, data_block); in dm_thin_insert_block()
1663 pmd_write_unlock(td->pmd); in dm_thin_insert_block()
1668 static int __remove(struct dm_thin_device *td, dm_block_t block) in __remove() argument
1671 struct dm_pool_metadata *pmd = td->pmd; in __remove()
1672 dm_block_t keys[2] = { td->id, block }; in __remove()
1678 td->mapped_blocks--; in __remove()
1679 td->changed = true; in __remove()
1684 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1688 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1689 dm_block_t keys[1] = { td->id }; in __remove_range()
1732 td->mapped_blocks -= total_count; in __remove_range()
1733 td->changed = true; in __remove_range()
1743 int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) in dm_thin_remove_block() argument
1747 pmd_write_lock(td->pmd); in dm_thin_remove_block()
1748 if (!td->pmd->fail_io) in dm_thin_remove_block()
1749 r = __remove(td, block); in dm_thin_remove_block()
1750 pmd_write_unlock(td->pmd); in dm_thin_remove_block()
1755 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1760 pmd_write_lock(td->pmd); in dm_thin_remove_range()
1761 if (!td->pmd->fail_io) in dm_thin_remove_range()
1762 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1763 pmd_write_unlock(td->pmd); in dm_thin_remove_range()
1804 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1808 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1809 r = td->changed; in dm_thin_changed_this_transaction()
1810 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1818 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1821 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1822 if (td->changed) { in dm_pool_changed_this_transaction()
1823 r = td->changed; in dm_pool_changed_this_transaction()
1832 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1836 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1837 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1838 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1882 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1884 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1885 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
1965 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
1968 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
1972 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
1980 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
1985 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
1987 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
1996 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
2000 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
2004 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()