Lines Matching refs:td

750 	struct dm_thin_device *td, *tmp;  in __write_changed_details()  local
754 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
755 if (!td->changed) in __write_changed_details()
758 key = td->id; in __write_changed_details()
760 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
761 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
762 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
763 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
771 if (td->open_count) in __write_changed_details()
772 td->changed = 0; in __write_changed_details()
774 list_del(&td->list); in __write_changed_details()
775 kfree(td); in __write_changed_details()
881 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
884 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
885 if (td->open_count) in dm_pool_metadata_close()
888 list_del(&td->list); in dm_pool_metadata_close()
889 kfree(td); in dm_pool_metadata_close()
921 struct dm_thin_device **td) in __open_device() argument
940 *td = td2; in __open_device()
963 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
964 if (!*td) in __open_device()
967 (*td)->pmd = pmd; in __open_device()
968 (*td)->id = dev; in __open_device()
969 (*td)->open_count = 1; in __open_device()
970 (*td)->changed = changed; in __open_device()
971 (*td)->aborted_with_changes = false; in __open_device()
972 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
973 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
974 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
975 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
977 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
982 static void __close_device(struct dm_thin_device *td) in __close_device() argument
984 --td->open_count; in __close_device()
994 struct dm_thin_device *td; in __create_thin() local
1020 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1026 __close_device(td); in __create_thin()
1048 struct dm_thin_device *td; in __set_snapshot_details() local
1050 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1054 td->changed = 1; in __set_snapshot_details()
1055 td->snapshotted_time = time; in __set_snapshot_details()
1057 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1059 __close_device(td); in __set_snapshot_details()
1070 struct dm_thin_device *td; in __create_snap() local
1101 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1105 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1106 __close_device(td); in __create_snap()
1138 struct dm_thin_device *td; in __delete_device() local
1141 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1145 if (td->open_count > 1) { in __delete_device()
1146 __close_device(td); in __delete_device()
1150 list_del(&td->list); in __delete_device()
1151 kfree(td); in __delete_device()
1376 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1382 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1388 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1390 down_write(&td->pmd->root_lock); in dm_pool_close_thin_device()
1391 __close_device(td); in dm_pool_close_thin_device()
1392 up_write(&td->pmd->root_lock); in dm_pool_close_thin_device()
1397 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1399 return td->id; in dm_thin_dev_id()
1408 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1410 return td->snapshotted_time > time; in __snapshotted_since()
1413 static void unpack_lookup_result(struct dm_thin_device *td, __le64 value, in unpack_lookup_result() argument
1423 result->shared = __snapshotted_since(td, exception_time); in unpack_lookup_result()
1426 static int __find_block(struct dm_thin_device *td, dm_block_t block, in __find_block() argument
1431 struct dm_pool_metadata *pmd = td->pmd; in __find_block()
1432 dm_block_t keys[2] = { td->id, block }; in __find_block()
1442 unpack_lookup_result(td, value, result); in __find_block()
1447 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1451 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1459 r = __find_block(td, block, can_issue_io, result); in dm_thin_find_block()
1465 static int __find_next_mapped_block(struct dm_thin_device *td, dm_block_t block, in __find_next_mapped_block() argument
1471 struct dm_pool_metadata *pmd = td->pmd; in __find_next_mapped_block()
1472 dm_block_t keys[2] = { td->id, block }; in __find_next_mapped_block()
1476 unpack_lookup_result(td, value, result); in __find_next_mapped_block()
1481 static int __find_mapped_range(struct dm_thin_device *td, in __find_mapped_range() argument
1493 r = __find_next_mapped_block(td, begin, &begin, &lookup); in __find_mapped_range()
1507 r = __find_block(td, begin, true, &lookup); in __find_mapped_range()
1527 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1533 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_mapped_range()
1537 r = __find_mapped_range(td, begin, end, thin_begin, thin_end, in dm_thin_find_mapped_range()
1545 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1550 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1551 dm_block_t keys[2] = { td->id, block }; in __insert()
1561 td->changed = 1; in __insert()
1563 td->mapped_blocks++; in __insert()
1568 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1573 down_write(&td->pmd->root_lock); in dm_thin_insert_block()
1574 if (!td->pmd->fail_io) in dm_thin_insert_block()
1575 r = __insert(td, block, data_block); in dm_thin_insert_block()
1576 up_write(&td->pmd->root_lock); in dm_thin_insert_block()
1581 static int __remove(struct dm_thin_device *td, dm_block_t block) in __remove() argument
1584 struct dm_pool_metadata *pmd = td->pmd; in __remove()
1585 dm_block_t keys[2] = { td->id, block }; in __remove()
1591 td->mapped_blocks--; in __remove()
1592 td->changed = 1; in __remove()
1597 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1601 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1602 dm_block_t keys[1] = { td->id }; in __remove_range()
1645 td->mapped_blocks -= total_count; in __remove_range()
1646 td->changed = 1; in __remove_range()
1656 int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) in dm_thin_remove_block() argument
1660 down_write(&td->pmd->root_lock); in dm_thin_remove_block()
1661 if (!td->pmd->fail_io) in dm_thin_remove_block()
1662 r = __remove(td, block); in dm_thin_remove_block()
1663 up_write(&td->pmd->root_lock); in dm_thin_remove_block()
1668 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1673 down_write(&td->pmd->root_lock); in dm_thin_remove_range()
1674 if (!td->pmd->fail_io) in dm_thin_remove_range()
1675 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1676 up_write(&td->pmd->root_lock); in dm_thin_remove_range()
1725 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1729 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1730 r = td->changed; in dm_thin_changed_this_transaction()
1731 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1739 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1742 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1743 if (td->changed) { in dm_pool_changed_this_transaction()
1744 r = td->changed; in dm_pool_changed_this_transaction()
1753 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1757 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1758 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1759 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1799 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1801 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1802 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
1882 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
1885 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
1889 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
1897 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
1902 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
1904 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
1913 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
1917 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
1921 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()