Lines Matching +full:low +full:- +full:vt
7 #include "dm-cache-metadata.h"
9 #include "persistent-data/dm-array.h"
10 #include "persistent-data/dm-bitset.h"
11 #include "persistent-data/dm-space-map.h"
12 #include "persistent-data/dm-space-map-disk.h"
13 #include "persistent-data/dm-transaction-manager.h"
15 #include <linux/device-mapper.h>
18 /*----------------------------------------------------------------*/
46 * Each mapping from cache block -> origin block carries a set of flags.
165 /*-------------------------------------------------------------------
167 *-----------------------------------------------------------------*/
177 disk_super->blocknr = cpu_to_le64(dm_block_location(b)); in sb_prepare_for_write()
178 disk_super->csum = cpu_to_le32(dm_bm_checksum(&disk_super->flags, in sb_prepare_for_write()
179 sb_block_size - sizeof(__le32), in sb_prepare_for_write()
185 uint32_t metadata_version = le32_to_cpu(disk_super->version); in check_metadata_version()
190 return -EINVAL; in check_metadata_version()
203 if (dm_block_location(b) != le64_to_cpu(disk_super->blocknr)) { in sb_check()
205 le64_to_cpu(disk_super->blocknr), in sb_check()
207 return -ENOTBLK; in sb_check()
210 if (le64_to_cpu(disk_super->magic) != CACHE_SUPERBLOCK_MAGIC) { in sb_check()
212 le64_to_cpu(disk_super->magic), in sb_check()
214 return -EILSEQ; in sb_check()
217 csum_le = cpu_to_le32(dm_bm_checksum(&disk_super->flags, in sb_check()
218 sb_block_size - sizeof(__le32), in sb_check()
220 if (csum_le != disk_super->csum) { in sb_check()
222 le32_to_cpu(csum_le), le32_to_cpu(disk_super->csum)); in sb_check()
223 return -EILSEQ; in sb_check()
235 /*----------------------------------------------------------------*/
240 return dm_bm_read_lock(cmd->bm, CACHE_SUPERBLOCK_LOCATION, in superblock_read_lock()
247 return dm_bm_write_lock_zero(cmd->bm, CACHE_SUPERBLOCK_LOCATION, in superblock_lock_zero()
254 return dm_bm_write_lock(cmd->bm, CACHE_SUPERBLOCK_LOCATION, in superblock_lock()
258 /*----------------------------------------------------------------*/
269 * We can't use a validator here - it may be all zeroes. in __superblock_all_zeroes()
291 struct dm_btree_value_type vt; in __setup_mapping_info() local
293 vt.context = NULL; in __setup_mapping_info()
294 vt.size = sizeof(__le64); in __setup_mapping_info()
295 vt.inc = NULL; in __setup_mapping_info()
296 vt.dec = NULL; in __setup_mapping_info()
297 vt.equal = NULL; in __setup_mapping_info()
298 dm_array_info_init(&cmd->info, cmd->tm, &vt); in __setup_mapping_info()
300 if (cmd->policy_hint_size) { in __setup_mapping_info()
301 vt.size = sizeof(__le32); in __setup_mapping_info()
302 dm_array_info_init(&cmd->hint_info, cmd->tm, &vt); in __setup_mapping_info()
311 r = dm_sm_root_size(cmd->metadata_sm, &metadata_len); in __save_sm_root()
315 return dm_sm_copy_root(cmd->metadata_sm, &cmd->metadata_space_map_root, in __save_sm_root()
322 memcpy(&disk_super->metadata_space_map_root, in __copy_sm_root()
323 &cmd->metadata_space_map_root, in __copy_sm_root()
324 sizeof(cmd->metadata_space_map_root)); in __copy_sm_root()
329 return cmd->version >= 2; in separate_dirty_bits()
337 sector_t bdev_size = i_size_read(cmd->bdev->bd_inode) >> SECTOR_SHIFT; in __write_initial_superblock()
343 r = dm_tm_pre_commit(cmd->tm); in __write_initial_superblock()
360 disk_super->flags = 0; in __write_initial_superblock()
361 memset(disk_super->uuid, 0, sizeof(disk_super->uuid)); in __write_initial_superblock()
362 disk_super->magic = cpu_to_le64(CACHE_SUPERBLOCK_MAGIC); in __write_initial_superblock()
363 disk_super->version = cpu_to_le32(cmd->version); in __write_initial_superblock()
364 memset(disk_super->policy_name, 0, sizeof(disk_super->policy_name)); in __write_initial_superblock()
365 memset(disk_super->policy_version, 0, sizeof(disk_super->policy_version)); in __write_initial_superblock()
366 disk_super->policy_hint_size = cpu_to_le32(0); in __write_initial_superblock()
370 disk_super->mapping_root = cpu_to_le64(cmd->root); in __write_initial_superblock()
371 disk_super->hint_root = cpu_to_le64(cmd->hint_root); in __write_initial_superblock()
372 disk_super->discard_root = cpu_to_le64(cmd->discard_root); in __write_initial_superblock()
373 disk_super->discard_block_size = cpu_to_le64(cmd->discard_block_size); in __write_initial_superblock()
374 disk_super->discard_nr_blocks = cpu_to_le64(from_dblock(cmd->discard_nr_blocks)); in __write_initial_superblock()
375 disk_super->metadata_block_size = cpu_to_le32(DM_CACHE_METADATA_BLOCK_SIZE); in __write_initial_superblock()
376 disk_super->data_block_size = cpu_to_le32(cmd->data_block_size); in __write_initial_superblock()
377 disk_super->cache_blocks = cpu_to_le32(0); in __write_initial_superblock()
379 disk_super->read_hits = cpu_to_le32(0); in __write_initial_superblock()
380 disk_super->read_misses = cpu_to_le32(0); in __write_initial_superblock()
381 disk_super->write_hits = cpu_to_le32(0); in __write_initial_superblock()
382 disk_super->write_misses = cpu_to_le32(0); in __write_initial_superblock()
385 disk_super->dirty_root = cpu_to_le64(cmd->dirty_root); in __write_initial_superblock()
387 return dm_tm_commit(cmd->tm, sblock); in __write_initial_superblock()
394 r = dm_tm_create_with_sm(cmd->bm, CACHE_SUPERBLOCK_LOCATION, in __format_metadata()
395 &cmd->tm, &cmd->metadata_sm); in __format_metadata()
403 r = dm_array_empty(&cmd->info, &cmd->root); in __format_metadata()
408 dm_disk_bitset_init(cmd->tm, &cmd->dirty_info); in __format_metadata()
409 r = dm_bitset_empty(&cmd->dirty_info, &cmd->dirty_root); in __format_metadata()
414 dm_disk_bitset_init(cmd->tm, &cmd->discard_info); in __format_metadata()
415 r = dm_bitset_empty(&cmd->discard_info, &cmd->discard_root); in __format_metadata()
419 cmd->discard_block_size = 0; in __format_metadata()
420 cmd->discard_nr_blocks = 0; in __format_metadata()
426 cmd->clean_when_opened = true; in __format_metadata()
430 dm_tm_destroy(cmd->tm); in __format_metadata()
431 dm_sm_destroy(cmd->metadata_sm); in __format_metadata()
441 incompat_flags = le32_to_cpu(disk_super->incompat_flags); in __check_incompat_features()
446 return -EINVAL; in __check_incompat_features()
450 * Check for read-only metadata to skip the following RDWR checks. in __check_incompat_features()
452 if (get_disk_ro(cmd->bdev->bd_disk)) in __check_incompat_features()
455 features = le32_to_cpu(disk_super->compat_ro_flags) & ~DM_CACHE_FEATURE_COMPAT_RO_SUPP; in __check_incompat_features()
459 return -EINVAL; in __check_incompat_features()
481 if (le32_to_cpu(disk_super->data_block_size) != cmd->data_block_size) { in __open_metadata()
483 le32_to_cpu(disk_super->data_block_size), in __open_metadata()
484 (unsigned long long)cmd->data_block_size); in __open_metadata()
485 r = -EINVAL; in __open_metadata()
493 r = dm_tm_open_with_sm(cmd->bm, CACHE_SUPERBLOCK_LOCATION, in __open_metadata()
494 disk_super->metadata_space_map_root, in __open_metadata()
495 sizeof(disk_super->metadata_space_map_root), in __open_metadata()
496 &cmd->tm, &cmd->metadata_sm); in __open_metadata()
503 dm_disk_bitset_init(cmd->tm, &cmd->dirty_info); in __open_metadata()
504 dm_disk_bitset_init(cmd->tm, &cmd->discard_info); in __open_metadata()
505 sb_flags = le32_to_cpu(disk_super->flags); in __open_metadata()
506 cmd->clean_when_opened = test_bit(CLEAN_SHUTDOWN, &sb_flags); in __open_metadata()
522 r = __superblock_all_zeroes(cmd->bm, &unformatted); in __open_or_format_metadata()
527 return format_device ? __format_metadata(cmd) : -EPERM; in __open_or_format_metadata()
536 cmd->bm = dm_block_manager_create(cmd->bdev, DM_CACHE_METADATA_BLOCK_SIZE << SECTOR_SHIFT, in __create_persistent_data_objects()
538 if (IS_ERR(cmd->bm)) { in __create_persistent_data_objects()
540 r = PTR_ERR(cmd->bm); in __create_persistent_data_objects()
541 cmd->bm = NULL; in __create_persistent_data_objects()
547 dm_block_manager_destroy(cmd->bm); in __create_persistent_data_objects()
548 cmd->bm = NULL; in __create_persistent_data_objects()
556 dm_sm_destroy(cmd->metadata_sm); in __destroy_persistent_data_objects()
557 dm_tm_destroy(cmd->tm); in __destroy_persistent_data_objects()
558 dm_block_manager_destroy(cmd->bm); in __destroy_persistent_data_objects()
566 uint32_t sb_flags = mutator(le32_to_cpu(disk_super->flags)); in update_flags()
567 disk_super->flags = cpu_to_le32(sb_flags); in update_flags()
585 cmd->version = le32_to_cpu(disk_super->version); in read_superblock_fields()
586 cmd->flags = le32_to_cpu(disk_super->flags); in read_superblock_fields()
587 cmd->root = le64_to_cpu(disk_super->mapping_root); in read_superblock_fields()
588 cmd->hint_root = le64_to_cpu(disk_super->hint_root); in read_superblock_fields()
589 cmd->discard_root = le64_to_cpu(disk_super->discard_root); in read_superblock_fields()
590 cmd->discard_block_size = le64_to_cpu(disk_super->discard_block_size); in read_superblock_fields()
591 cmd->discard_nr_blocks = to_dblock(le64_to_cpu(disk_super->discard_nr_blocks)); in read_superblock_fields()
592 cmd->data_block_size = le32_to_cpu(disk_super->data_block_size); in read_superblock_fields()
593 cmd->cache_blocks = to_cblock(le32_to_cpu(disk_super->cache_blocks)); in read_superblock_fields()
594 strncpy(cmd->policy_name, disk_super->policy_name, sizeof(cmd->policy_name)); in read_superblock_fields()
595 cmd->policy_version[0] = le32_to_cpu(disk_super->policy_version[0]); in read_superblock_fields()
596 cmd->policy_version[1] = le32_to_cpu(disk_super->policy_version[1]); in read_superblock_fields()
597 cmd->policy_version[2] = le32_to_cpu(disk_super->policy_version[2]); in read_superblock_fields()
598 cmd->policy_hint_size = le32_to_cpu(disk_super->policy_hint_size); in read_superblock_fields()
600 cmd->stats.read_hits = le32_to_cpu(disk_super->read_hits); in read_superblock_fields()
601 cmd->stats.read_misses = le32_to_cpu(disk_super->read_misses); in read_superblock_fields()
602 cmd->stats.write_hits = le32_to_cpu(disk_super->write_hits); in read_superblock_fields()
603 cmd->stats.write_misses = le32_to_cpu(disk_super->write_misses); in read_superblock_fields()
606 cmd->dirty_root = le64_to_cpu(disk_super->dirty_root); in read_superblock_fields()
608 cmd->changed = false; in read_superblock_fields()
630 return dm_bm_flush(cmd->bm); in __begin_transaction_flags()
640 * We re-read the superblock every time. Shouldn't need to do this in __begin_transaction()
662 * We need to know if the cache_disk_superblock exceeds a 512-byte sector. in __commit_transaction()
667 r = dm_bitset_flush(&cmd->dirty_info, cmd->dirty_root, in __commit_transaction()
668 &cmd->dirty_root); in __commit_transaction()
673 r = dm_bitset_flush(&cmd->discard_info, cmd->discard_root, in __commit_transaction()
674 &cmd->discard_root); in __commit_transaction()
678 r = dm_tm_pre_commit(cmd->tm); in __commit_transaction()
692 disk_super->flags = cpu_to_le32(cmd->flags); in __commit_transaction()
696 disk_super->mapping_root = cpu_to_le64(cmd->root); in __commit_transaction()
698 disk_super->dirty_root = cpu_to_le64(cmd->dirty_root); in __commit_transaction()
699 disk_super->hint_root = cpu_to_le64(cmd->hint_root); in __commit_transaction()
700 disk_super->discard_root = cpu_to_le64(cmd->discard_root); in __commit_transaction()
701 disk_super->discard_block_size = cpu_to_le64(cmd->discard_block_size); in __commit_transaction()
702 disk_super->discard_nr_blocks = cpu_to_le64(from_dblock(cmd->discard_nr_blocks)); in __commit_transaction()
703 disk_super->cache_blocks = cpu_to_le32(from_cblock(cmd->cache_blocks)); in __commit_transaction()
704 strncpy(disk_super->policy_name, cmd->policy_name, sizeof(disk_super->policy_name)); in __commit_transaction()
705 disk_super->policy_version[0] = cpu_to_le32(cmd->policy_version[0]); in __commit_transaction()
706 disk_super->policy_version[1] = cpu_to_le32(cmd->policy_version[1]); in __commit_transaction()
707 disk_super->policy_version[2] = cpu_to_le32(cmd->policy_version[2]); in __commit_transaction()
708 disk_super->policy_hint_size = cpu_to_le32(cmd->policy_hint_size); in __commit_transaction()
710 disk_super->read_hits = cpu_to_le32(cmd->stats.read_hits); in __commit_transaction()
711 disk_super->read_misses = cpu_to_le32(cmd->stats.read_misses); in __commit_transaction()
712 disk_super->write_hits = cpu_to_le32(cmd->stats.write_hits); in __commit_transaction()
713 disk_super->write_misses = cpu_to_le32(cmd->stats.write_misses); in __commit_transaction()
716 return dm_tm_commit(cmd->tm, sblock); in __commit_transaction()
719 /*----------------------------------------------------------------*/
722 * The mappings are held in a dm-array that has 64-bit values stored in
723 * little-endian format. The index is the cblock, the high 48bits of the
724 * value are the oblock and the low 16 bit the flags.
726 #define FLAGS_MASK ((1 << 16) - 1)
744 /*----------------------------------------------------------------*/
758 return ERR_PTR(-ENOMEM); in metadata_open()
761 cmd->version = metadata_version; in metadata_open()
762 refcount_set(&cmd->ref_count, 1); in metadata_open()
763 init_rwsem(&cmd->root_lock); in metadata_open()
764 cmd->bdev = bdev; in metadata_open()
765 cmd->data_block_size = data_block_size; in metadata_open()
766 cmd->cache_blocks = 0; in metadata_open()
767 cmd->policy_hint_size = policy_hint_size; in metadata_open()
768 cmd->changed = true; in metadata_open()
769 cmd->fail_io = false; in metadata_open()
799 if (cmd->bdev == bdev) { in lookup()
800 refcount_inc(&cmd->ref_count); in lookup()
833 list_add(&cmd->list, &table); in lookup_or_open()
842 if (cmd->data_block_size != data_block_size) { in same_params()
845 (unsigned long long) cmd->data_block_size); in same_params()
863 return ERR_PTR(-EINVAL); in dm_cache_metadata_open()
871 if (refcount_dec_and_test(&cmd->ref_count)) { in dm_cache_metadata_close()
873 list_del(&cmd->list); in dm_cache_metadata_close()
876 if (!cmd->fail_io) in dm_cache_metadata_close()
893 r = dm_array_get_value(&cmd->info, cmd->root, from_cblock(b), &value); in block_clean_combined_dirty()
937 if (from_cblock(cmd->cache_blocks) == 0) in blocks_are_clean_separate_dirty()
941 r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root, in blocks_are_clean_separate_dirty()
942 from_cblock(cmd->cache_blocks), &cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
948 r = dm_bitset_cursor_skip(&cmd->dirty_cursor, from_cblock(begin)); in blocks_are_clean_separate_dirty()
951 dm_bitset_cursor_end(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
960 dirty_flag = dm_bitset_cursor_get_value(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
964 dm_bitset_cursor_end(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
973 r = dm_bitset_cursor_next(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
976 dm_bitset_cursor_end(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
981 dm_bitset_cursor_end(&cmd->dirty_cursor); in blocks_are_clean_separate_dirty()
998 down_write(&cmd->root_lock); in cmd_write_lock()
999 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { in cmd_write_lock()
1000 up_write(&cmd->root_lock); in cmd_write_lock()
1009 return -EINVAL; \
1019 up_write(&(cmd)->root_lock)
1023 down_read(&cmd->root_lock); in cmd_read_lock()
1024 if (cmd->fail_io) { in cmd_read_lock()
1025 up_read(&cmd->root_lock); in cmd_read_lock()
1034 return -EINVAL; \
1044 up_read(&(cmd)->root_lock)
1055 if (from_cblock(new_cache_size) < from_cblock(cmd->cache_blocks)) { in dm_cache_resize()
1056 r = blocks_are_unmapped_or_clean(cmd, new_cache_size, cmd->cache_blocks, &clean); in dm_cache_resize()
1064 r = -EINVAL; in dm_cache_resize()
1070 r = dm_array_resize(&cmd->info, cmd->root, from_cblock(cmd->cache_blocks), in dm_cache_resize()
1072 &null_mapping, &cmd->root); in dm_cache_resize()
1077 r = dm_bitset_resize(&cmd->dirty_info, cmd->dirty_root, in dm_cache_resize()
1078 from_cblock(cmd->cache_blocks), from_cblock(new_cache_size), in dm_cache_resize()
1079 false, &cmd->dirty_root); in dm_cache_resize()
1084 cmd->cache_blocks = new_cache_size; in dm_cache_resize()
1085 cmd->changed = true; in dm_cache_resize()
1100 r = dm_bitset_resize(&cmd->discard_info, in dm_cache_discard_bitset_resize()
1101 cmd->discard_root, in dm_cache_discard_bitset_resize()
1102 from_dblock(cmd->discard_nr_blocks), in dm_cache_discard_bitset_resize()
1104 false, &cmd->discard_root); in dm_cache_discard_bitset_resize()
1106 cmd->discard_block_size = discard_block_size; in dm_cache_discard_bitset_resize()
1107 cmd->discard_nr_blocks = new_nr_entries; in dm_cache_discard_bitset_resize()
1110 cmd->changed = true; in dm_cache_discard_bitset_resize()
1118 return dm_bitset_set_bit(&cmd->discard_info, cmd->discard_root, in __set_discard()
1119 from_dblock(b), &cmd->discard_root); in __set_discard()
1124 return dm_bitset_clear_bit(&cmd->discard_info, cmd->discard_root, in __clear_discard()
1125 from_dblock(b), &cmd->discard_root); in __clear_discard()
1137 cmd->changed = true; in __discard()
1160 if (from_dblock(cmd->discard_nr_blocks) == 0) in __load_discards()
1164 if (cmd->clean_when_opened) { in __load_discards()
1165 r = dm_bitset_flush(&cmd->discard_info, cmd->discard_root, &cmd->discard_root); in __load_discards()
1169 r = dm_bitset_cursor_begin(&cmd->discard_info, cmd->discard_root, in __load_discards()
1170 from_dblock(cmd->discard_nr_blocks), &c); in __load_discards()
1175 r = fn(context, cmd->discard_block_size, to_dblock(b), in __load_discards()
1180 if (b >= (from_dblock(cmd->discard_nr_blocks) - 1)) in __load_discards()
1191 for (b = 0; b < from_dblock(cmd->discard_nr_blocks); b++) { in __load_discards()
1192 r = fn(context, cmd->discard_block_size, to_dblock(b), false); in __load_discards()
1216 *result = cmd->cache_blocks; in dm_cache_size()
1228 r = dm_array_set_value(&cmd->info, cmd->root, from_cblock(cblock), in __remove()
1229 &value, &cmd->root); in __remove()
1233 cmd->changed = true; in __remove()
1255 r = dm_array_set_value(&cmd->info, cmd->root, from_cblock(cblock), in __insert()
1256 &value, &cmd->root); in __insert()
1260 cmd->changed = true; in __insert()
1295 if (strncmp(cmd->policy_name, policy_name, sizeof(cmd->policy_name))) in policy_unchanged()
1301 if (cmd->policy_version[0] != policy_version[0]) in policy_unchanged()
1307 if (cmd->policy_hint_size != policy_hint_size) in policy_unchanged()
1315 return cmd->hint_root && cmd->policy_hint_size; in hints_array_initialized()
1321 return cmd->clean_when_opened && policy_unchanged(cmd, policy) && in hints_array_available()
1352 if (cmd->clean_when_opened) in __load_mapping_v1()
1394 if (cmd->clean_when_opened) in __load_mapping_v2()
1417 if (from_cblock(cmd->cache_blocks) == 0) in __load_mappings()
1421 r = dm_array_cursor_begin(&cmd->info, cmd->root, &cmd->mapping_cursor); in __load_mappings()
1426 r = dm_array_cursor_begin(&cmd->hint_info, cmd->hint_root, &cmd->hint_cursor); in __load_mappings()
1428 dm_array_cursor_end(&cmd->mapping_cursor); in __load_mappings()
1434 r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root, in __load_mappings()
1435 from_cblock(cmd->cache_blocks), in __load_mappings()
1436 &cmd->dirty_cursor); in __load_mappings()
1438 dm_array_cursor_end(&cmd->hint_cursor); in __load_mappings()
1439 dm_array_cursor_end(&cmd->mapping_cursor); in __load_mappings()
1447 &cmd->mapping_cursor, in __load_mappings()
1448 &cmd->hint_cursor, in __load_mappings()
1449 &cmd->dirty_cursor, in __load_mappings()
1453 &cmd->mapping_cursor, &cmd->hint_cursor, in __load_mappings()
1461 if (cb >= (from_cblock(cmd->cache_blocks) - 1)) in __load_mappings()
1464 r = dm_array_cursor_next(&cmd->mapping_cursor); in __load_mappings()
1471 r = dm_array_cursor_next(&cmd->hint_cursor); in __load_mappings()
1473 dm_array_cursor_end(&cmd->hint_cursor); in __load_mappings()
1479 r = dm_bitset_cursor_next(&cmd->dirty_cursor); in __load_mappings()
1487 dm_array_cursor_end(&cmd->mapping_cursor); in __load_mappings()
1489 dm_array_cursor_end(&cmd->hint_cursor); in __load_mappings()
1492 dm_bitset_cursor_end(&cmd->dirty_cursor); in __load_mappings()
1525 return dm_array_walk(&cmd->info, cmd->root, __dump_mapping, NULL); in __dump_mappings()
1540 r = cmd->changed; in dm_cache_changed_this_transaction()
1553 r = dm_array_get_value(&cmd->info, cmd->root, from_cblock(cblock), &value); in __dirty()
1566 r = dm_array_set_value(&cmd->info, cmd->root, from_cblock(cblock), in __dirty()
1567 &value, &cmd->root); in __dirty()
1571 cmd->changed = true; in __dirty()
1601 if (nr_bits != from_cblock(cmd->cache_blocks)) { in __set_dirty_bits_v2()
1603 return -EINVAL; in __set_dirty_bits_v2()
1606 r = dm_bitset_del(&cmd->dirty_info, cmd->dirty_root); in __set_dirty_bits_v2()
1610 cmd->changed = true; in __set_dirty_bits_v2()
1611 return dm_bitset_new(&cmd->dirty_info, &cmd->dirty_root, nr_bits, is_dirty_callback, bits); in __set_dirty_bits_v2()
1634 *stats = cmd->stats; in dm_cache_metadata_get_stats()
1642 cmd->stats = *stats; in dm_cache_metadata_set_stats()
1648 int r = -EINVAL; in dm_cache_commit()
1653 if (cmd->fail_io) in dm_cache_commit()
1669 int r = -EINVAL; in dm_cache_get_free_metadata_block_count()
1672 if (!cmd->fail_io) in dm_cache_get_free_metadata_block_count()
1673 r = dm_sm_get_nr_free(cmd->metadata_sm, result); in dm_cache_get_free_metadata_block_count()
1682 int r = -EINVAL; in dm_cache_get_metadata_dev_size()
1685 if (!cmd->fail_io) in dm_cache_get_metadata_dev_size()
1686 r = dm_sm_get_nr_blocks(cmd->metadata_sm, result); in dm_cache_get_metadata_dev_size()
1692 /*----------------------------------------------------------------*/
1717 (strlen(policy_name) > sizeof(cmd->policy_name) - 1)) in write_hints()
1718 return -EINVAL; in write_hints()
1720 strncpy(cmd->policy_name, policy_name, sizeof(cmd->policy_name)); in write_hints()
1721 memcpy(cmd->policy_version, policy_version, sizeof(cmd->policy_version)); in write_hints()
1725 return 0; /* short-circuit hints initialization */ in write_hints()
1726 cmd->policy_hint_size = hint_size; in write_hints()
1728 if (cmd->hint_root) { in write_hints()
1729 r = dm_array_del(&cmd->hint_info, cmd->hint_root); in write_hints()
1734 return dm_array_new(&cmd->hint_info, &cmd->hint_root, in write_hints()
1735 from_cblock(cmd->cache_blocks), in write_hints()
1755 r = blocks_are_unmapped_or_clean(cmd, 0, cmd->cache_blocks, result); in dm_cache_metadata_all_clean()
1764 dm_bm_set_read_only(cmd->bm); in dm_cache_metadata_set_read_only()
1771 dm_bm_set_read_write(cmd->bm); in dm_cache_metadata_set_read_write()
1782 set_bit(NEEDS_CHECK, &cmd->flags); in dm_cache_metadata_set_needs_check()
1791 disk_super->flags = cpu_to_le32(cmd->flags); in dm_cache_metadata_set_needs_check()
1803 *result = !!test_bit(NEEDS_CHECK, &cmd->flags); in dm_cache_metadata_needs_check()
1817 cmd->fail_io = true; in dm_cache_metadata_abort()