Lines Matching refs:td

742 	struct dm_thin_device *td, *tmp;  in __write_changed_details()  local
746 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in __write_changed_details()
747 if (!td->changed) in __write_changed_details()
750 key = td->id; in __write_changed_details()
752 details.mapped_blocks = cpu_to_le64(td->mapped_blocks); in __write_changed_details()
753 details.transaction_id = cpu_to_le64(td->transaction_id); in __write_changed_details()
754 details.creation_time = cpu_to_le32(td->creation_time); in __write_changed_details()
755 details.snapshotted_time = cpu_to_le32(td->snapshotted_time); in __write_changed_details()
763 if (td->open_count) in __write_changed_details()
764 td->changed = 0; in __write_changed_details()
766 list_del(&td->list); in __write_changed_details()
767 kfree(td); in __write_changed_details()
866 struct dm_thin_device *td, *tmp; in dm_pool_metadata_close() local
869 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_metadata_close()
870 if (td->open_count) in dm_pool_metadata_close()
873 list_del(&td->list); in dm_pool_metadata_close()
874 kfree(td); in dm_pool_metadata_close()
906 struct dm_thin_device **td) in __open_device() argument
925 *td = td2; in __open_device()
948 *td = kmalloc(sizeof(**td), GFP_NOIO); in __open_device()
949 if (!*td) in __open_device()
952 (*td)->pmd = pmd; in __open_device()
953 (*td)->id = dev; in __open_device()
954 (*td)->open_count = 1; in __open_device()
955 (*td)->changed = changed; in __open_device()
956 (*td)->aborted_with_changes = false; in __open_device()
957 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); in __open_device()
958 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); in __open_device()
959 (*td)->creation_time = le32_to_cpu(details_le.creation_time); in __open_device()
960 (*td)->snapshotted_time = le32_to_cpu(details_le.snapshotted_time); in __open_device()
962 list_add(&(*td)->list, &pmd->thin_devices); in __open_device()
967 static void __close_device(struct dm_thin_device *td) in __close_device() argument
969 --td->open_count; in __close_device()
979 struct dm_thin_device *td; in __create_thin() local
1005 r = __open_device(pmd, dev, 1, &td); in __create_thin()
1011 __close_device(td); in __create_thin()
1033 struct dm_thin_device *td; in __set_snapshot_details() local
1035 r = __open_device(pmd, origin, 0, &td); in __set_snapshot_details()
1039 td->changed = 1; in __set_snapshot_details()
1040 td->snapshotted_time = time; in __set_snapshot_details()
1042 snap->mapped_blocks = td->mapped_blocks; in __set_snapshot_details()
1044 __close_device(td); in __set_snapshot_details()
1055 struct dm_thin_device *td; in __create_snap() local
1086 r = __open_device(pmd, dev, 1, &td); in __create_snap()
1090 r = __set_snapshot_details(pmd, td, origin, pmd->time); in __create_snap()
1091 __close_device(td); in __create_snap()
1123 struct dm_thin_device *td; in __delete_device() local
1126 r = __open_device(pmd, dev, 0, &td); in __delete_device()
1130 if (td->open_count > 1) { in __delete_device()
1131 __close_device(td); in __delete_device()
1135 list_del(&td->list); in __delete_device()
1136 kfree(td); in __delete_device()
1361 struct dm_thin_device **td) in dm_pool_open_thin_device() argument
1367 r = __open_device(pmd, dev, 0, td); in dm_pool_open_thin_device()
1373 int dm_pool_close_thin_device(struct dm_thin_device *td) in dm_pool_close_thin_device() argument
1375 down_write(&td->pmd->root_lock); in dm_pool_close_thin_device()
1376 __close_device(td); in dm_pool_close_thin_device()
1377 up_write(&td->pmd->root_lock); in dm_pool_close_thin_device()
1382 dm_thin_id dm_thin_dev_id(struct dm_thin_device *td) in dm_thin_dev_id() argument
1384 return td->id; in dm_thin_dev_id()
1393 static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time) in __snapshotted_since() argument
1395 return td->snapshotted_time > time; in __snapshotted_since()
1398 int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_find_block() argument
1403 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_find_block()
1404 dm_block_t keys[2] = { td->id, block }; in dm_thin_find_block()
1428 result->shared = __snapshotted_since(td, exception_time); in dm_thin_find_block()
1436 int dm_thin_find_mapped_range(struct dm_thin_device *td, in dm_thin_find_mapped_range() argument
1452 r = dm_thin_find_block(td, begin, true, &lookup); in dm_thin_find_mapped_range()
1472 r = dm_thin_find_block(td, begin, true, &lookup); in dm_thin_find_mapped_range()
1492 static int __insert(struct dm_thin_device *td, dm_block_t block, in __insert() argument
1497 struct dm_pool_metadata *pmd = td->pmd; in __insert()
1498 dm_block_t keys[2] = { td->id, block }; in __insert()
1508 td->changed = 1; in __insert()
1510 td->mapped_blocks++; in __insert()
1515 int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, in dm_thin_insert_block() argument
1520 down_write(&td->pmd->root_lock); in dm_thin_insert_block()
1521 if (!td->pmd->fail_io) in dm_thin_insert_block()
1522 r = __insert(td, block, data_block); in dm_thin_insert_block()
1523 up_write(&td->pmd->root_lock); in dm_thin_insert_block()
1528 static int __remove(struct dm_thin_device *td, dm_block_t block) in __remove() argument
1531 struct dm_pool_metadata *pmd = td->pmd; in __remove()
1532 dm_block_t keys[2] = { td->id, block }; in __remove()
1538 td->mapped_blocks--; in __remove()
1539 td->changed = 1; in __remove()
1544 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end) in __remove_range() argument
1548 struct dm_pool_metadata *pmd = td->pmd; in __remove_range()
1549 dm_block_t keys[1] = { td->id }; in __remove_range()
1592 td->mapped_blocks -= total_count; in __remove_range()
1593 td->changed = 1; in __remove_range()
1603 int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) in dm_thin_remove_block() argument
1607 down_write(&td->pmd->root_lock); in dm_thin_remove_block()
1608 if (!td->pmd->fail_io) in dm_thin_remove_block()
1609 r = __remove(td, block); in dm_thin_remove_block()
1610 up_write(&td->pmd->root_lock); in dm_thin_remove_block()
1615 int dm_thin_remove_range(struct dm_thin_device *td, in dm_thin_remove_range() argument
1620 down_write(&td->pmd->root_lock); in dm_thin_remove_range()
1621 if (!td->pmd->fail_io) in dm_thin_remove_range()
1622 r = __remove_range(td, begin, end); in dm_thin_remove_range()
1623 up_write(&td->pmd->root_lock); in dm_thin_remove_range()
1642 bool dm_thin_changed_this_transaction(struct dm_thin_device *td) in dm_thin_changed_this_transaction() argument
1646 down_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1647 r = td->changed; in dm_thin_changed_this_transaction()
1648 up_read(&td->pmd->root_lock); in dm_thin_changed_this_transaction()
1656 struct dm_thin_device *td, *tmp; in dm_pool_changed_this_transaction() local
1659 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { in dm_pool_changed_this_transaction()
1660 if (td->changed) { in dm_pool_changed_this_transaction()
1661 r = td->changed; in dm_pool_changed_this_transaction()
1670 bool dm_thin_aborted_changes(struct dm_thin_device *td) in dm_thin_aborted_changes() argument
1674 down_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1675 r = td->aborted_with_changes; in dm_thin_aborted_changes()
1676 up_read(&td->pmd->root_lock); in dm_thin_aborted_changes()
1716 struct dm_thin_device *td; in __set_abort_with_changes_flags() local
1718 list_for_each_entry(td, &pmd->thin_devices, list) in __set_abort_with_changes_flags()
1719 td->aborted_with_changes = td->changed; in __set_abort_with_changes_flags()
1792 int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) in dm_thin_get_mapped_count() argument
1795 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_mapped_count()
1799 *result = td->mapped_blocks; in dm_thin_get_mapped_count()
1807 static int __highest_block(struct dm_thin_device *td, dm_block_t *result) in __highest_block() argument
1812 struct dm_pool_metadata *pmd = td->pmd; in __highest_block()
1814 r = dm_btree_lookup(&pmd->tl_info, pmd->root, &td->id, &value_le); in __highest_block()
1823 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, in dm_thin_get_highest_mapped_block() argument
1827 struct dm_pool_metadata *pmd = td->pmd; in dm_thin_get_highest_mapped_block()
1831 r = __highest_block(td, result); in dm_thin_get_highest_mapped_block()