Lines Matching +full:low +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0-only
3 #include "persistent-data/dm-transaction-manager.h"
4 #include "persistent-data/dm-bitset.h"
5 #include "persistent-data/dm-space-map.h"
7 #include <linux/dm-io.h>
8 #include <linux/dm-kcopyd.h>
25 /*----------------------------------------------------------------
27 *--------------------------------------------------------------*/
49 vfree(ws->bits); in writeset_free()
50 ws->bits = NULL; in writeset_free()
75 ws->bits = vzalloc(bitset_size(nr_blocks)); in writeset_alloc()
76 if (!ws->bits) { in writeset_alloc()
78 return -ENOMEM; in writeset_alloc()
85 * Wipes the in-core bitset, and creates a new on disk bitset.
92 memset(ws->bits, 0, bitset_size(nr_blocks)); in writeset_init()
94 ws->md.nr_bits = nr_blocks; in writeset_init()
95 r = setup_on_disk_bitset(info, ws->md.nr_bits, &ws->md.root); in writeset_init()
106 return test_bit(block, ws->bits); in writeset_marked()
113 dm_block_t old = m->root; in writeset_marked_on_disk()
119 int r = dm_bitset_test_bit(info, m->root, block, &m->root, result); in writeset_marked_on_disk()
125 BUG_ON(m->root != old); in writeset_marked_on_disk()
138 if (!test_bit(block, ws->bits)) { in writeset_test_and_set()
139 r = dm_bitset_set_bit(info, ws->md.root, block, &ws->md.root); in writeset_test_and_set()
151 /*----------------------------------------------------------------
153 *--------------------------------------------------------------*/
189 /*----------------------------------------------------------------
191 *--------------------------------------------------------------*/
198 disk->blocknr = cpu_to_le64(dm_block_location(b)); in sb_prepare_for_write()
199 disk->csum = cpu_to_le32(dm_bm_checksum(&disk->flags, in sb_prepare_for_write()
200 sb_block_size - sizeof(__le32), in sb_prepare_for_write()
206 uint32_t metadata_version = le32_to_cpu(disk->version); in check_metadata_version()
210 return -EINVAL; in check_metadata_version()
223 if (dm_block_location(b) != le64_to_cpu(disk->blocknr)) { in sb_check()
225 le64_to_cpu(disk->blocknr), in sb_check()
227 return -ENOTBLK; in sb_check()
230 if (le64_to_cpu(disk->magic) != SUPERBLOCK_MAGIC) { in sb_check()
232 le64_to_cpu(disk->magic), in sb_check()
234 return -EILSEQ; in sb_check()
237 csum_le = cpu_to_le32(dm_bm_checksum(&disk->flags, in sb_check()
238 sb_block_size - sizeof(__le32), in sb_check()
240 if (csum_le != disk->csum) { in sb_check()
242 le32_to_cpu(csum_le), le32_to_cpu(disk->csum)); in sb_check()
243 return -EILSEQ; in sb_check()
255 /*----------------------------------------------------------------
256 * Low level metadata handling
257 *--------------------------------------------------------------*/
304 return dm_bm_read_lock(md->bm, SUPERBLOCK_LOCATION, in superblock_read_lock()
311 return dm_bm_write_lock_zero(md->bm, SUPERBLOCK_LOCATION, in superblock_lock_zero()
318 return dm_bm_write_lock(md->bm, SUPERBLOCK_LOCATION, in superblock_lock()
332 * We can't use a validator here - it may be all zeroes. in superblock_all_zeroes()
352 /*----------------------------------------------------------------*/
356 disk->nr_bits = cpu_to_le32(core->nr_bits); in ws_pack()
357 disk->root = cpu_to_le64(core->root); in ws_pack()
362 core->nr_bits = le32_to_cpu(disk->nr_bits); in ws_unpack()
363 core->root = le64_to_cpu(disk->root); in ws_unpack()
375 dm_tm_inc(md->tm, b); in ws_inc()
387 dm_bitset_del(&md->bitset_info, b); in ws_dec()
395 /*----------------------------------------------------------------*/
399 struct dm_btree_value_type *vt = &md->writeset_tree_info.value_type; in setup_writeset_tree_info() local
400 md->writeset_tree_info.tm = md->tm; in setup_writeset_tree_info()
401 md->writeset_tree_info.levels = 1; in setup_writeset_tree_info()
402 vt->context = md; in setup_writeset_tree_info()
403 vt->size = sizeof(struct writeset_disk); in setup_writeset_tree_info()
404 vt->inc = ws_inc; in setup_writeset_tree_info()
405 vt->dec = ws_dec; in setup_writeset_tree_info()
406 vt->equal = ws_eq; in setup_writeset_tree_info()
412 struct dm_btree_value_type vt; in setup_era_array_info() local
413 vt.context = NULL; in setup_era_array_info()
414 vt.size = sizeof(__le32); in setup_era_array_info()
415 vt.inc = NULL; in setup_era_array_info()
416 vt.dec = NULL; in setup_era_array_info()
417 vt.equal = NULL; in setup_era_array_info()
419 dm_array_info_init(&md->era_array_info, md->tm, &vt); in setup_era_array_info()
424 dm_disk_bitset_init(md->tm, &md->bitset_info); in setup_infos()
429 /*----------------------------------------------------------------*/
435 r = dm_tm_create_with_sm(md->bm, SUPERBLOCK_LOCATION, in create_fresh_metadata()
436 &md->tm, &md->sm); in create_fresh_metadata()
444 r = dm_btree_empty(&md->writeset_tree_info, &md->writeset_tree_root); in create_fresh_metadata()
450 r = dm_array_empty(&md->era_array_info, &md->era_array_root); in create_fresh_metadata()
459 dm_sm_destroy(md->sm); in create_fresh_metadata()
460 dm_tm_destroy(md->tm); in create_fresh_metadata()
470 r = dm_sm_root_size(md->sm, &metadata_len); in save_sm_root()
474 return dm_sm_copy_root(md->sm, &md->metadata_space_map_root, in save_sm_root()
480 memcpy(&disk->metadata_space_map_root, in copy_sm_root()
481 &md->metadata_space_map_root, in copy_sm_root()
482 sizeof(md->metadata_space_map_root)); in copy_sm_root()
492 disk->magic = cpu_to_le64(SUPERBLOCK_MAGIC); in prepare_superblock()
493 disk->flags = cpu_to_le32(0ul); in prepare_superblock()
496 memset(disk->uuid, 0, sizeof(disk->uuid)); in prepare_superblock()
497 disk->version = cpu_to_le32(MAX_ERA_VERSION); in prepare_superblock()
501 disk->data_block_size = cpu_to_le32(md->block_size); in prepare_superblock()
502 disk->metadata_block_size = cpu_to_le32(DM_ERA_METADATA_BLOCK_SIZE >> SECTOR_SHIFT); in prepare_superblock()
503 disk->nr_blocks = cpu_to_le32(md->nr_blocks); in prepare_superblock()
504 disk->current_era = cpu_to_le32(md->current_era); in prepare_superblock()
506 ws_pack(&md->current_writeset->md, &disk->current_writeset); in prepare_superblock()
507 disk->writeset_tree_root = cpu_to_le64(md->writeset_tree_root); in prepare_superblock()
508 disk->era_array_root = cpu_to_le64(md->era_array_root); in prepare_superblock()
509 disk->metadata_snap = cpu_to_le64(md->metadata_snap); in prepare_superblock()
531 return dm_tm_commit(md->tm, sblock); in write_superblock()
547 dm_sm_destroy(md->sm); in format_metadata()
548 dm_tm_destroy(md->tm); in format_metadata()
570 if (le32_to_cpu(disk->data_block_size) != md->block_size) { in open_metadata()
572 le32_to_cpu(disk->data_block_size), md->block_size); in open_metadata()
573 r = -EINVAL; in open_metadata()
577 r = dm_tm_open_with_sm(md->bm, SUPERBLOCK_LOCATION, in open_metadata()
578 disk->metadata_space_map_root, in open_metadata()
579 sizeof(disk->metadata_space_map_root), in open_metadata()
580 &md->tm, &md->sm); in open_metadata()
588 md->nr_blocks = le32_to_cpu(disk->nr_blocks); in open_metadata()
589 md->current_era = le32_to_cpu(disk->current_era); in open_metadata()
591 ws_unpack(&disk->current_writeset, &md->current_writeset->md); in open_metadata()
592 md->writeset_tree_root = le64_to_cpu(disk->writeset_tree_root); in open_metadata()
593 md->era_array_root = le64_to_cpu(disk->era_array_root); in open_metadata()
594 md->metadata_snap = le64_to_cpu(disk->metadata_snap); in open_metadata()
595 md->archived_writesets = true; in open_metadata()
612 r = superblock_all_zeroes(md->bm, &unformatted); in open_or_format_metadata()
617 return may_format ? format_metadata(md) : -EPERM; in open_or_format_metadata()
627 md->bm = dm_block_manager_create(md->bdev, DM_ERA_METADATA_BLOCK_SIZE, in create_persistent_data_objects()
629 if (IS_ERR(md->bm)) { in create_persistent_data_objects()
631 return PTR_ERR(md->bm); in create_persistent_data_objects()
636 dm_block_manager_destroy(md->bm); in create_persistent_data_objects()
643 dm_sm_destroy(md->sm); in destroy_persistent_data_objects()
644 dm_tm_destroy(md->tm); in destroy_persistent_data_objects()
645 dm_block_manager_destroy(md->bm); in destroy_persistent_data_objects()
653 rcu_assign_pointer(md->current_writeset, new_writeset); in swap_writeset()
657 /*----------------------------------------------------------------
663 *--------------------------------------------------------------*/
681 uint64_t key = d->era; in metadata_digest_remove_writeset()
683 r = dm_btree_remove(&md->writeset_tree_info, md->writeset_tree_root, in metadata_digest_remove_writeset()
684 &key, &md->writeset_tree_root); in metadata_digest_remove_writeset()
690 d->step = metadata_digest_lookup_writeset; in metadata_digest_remove_writeset()
701 unsigned b, e = min(d->current_bit + INSERTS_PER_STEP, d->nr_bits); in metadata_digest_transcribe_writeset()
703 for (b = d->current_bit; b < e; b++) { in metadata_digest_transcribe_writeset()
704 r = writeset_marked_on_disk(&d->info, &d->writeset, b, &marked); in metadata_digest_transcribe_writeset()
713 __dm_bless_for_disk(&d->value); in metadata_digest_transcribe_writeset()
714 r = dm_array_set_value(&md->era_array_info, md->era_array_root, in metadata_digest_transcribe_writeset()
715 b, &d->value, &md->era_array_root); in metadata_digest_transcribe_writeset()
722 if (b == d->nr_bits) in metadata_digest_transcribe_writeset()
723 d->step = metadata_digest_remove_writeset; in metadata_digest_transcribe_writeset()
725 d->current_bit = b; in metadata_digest_transcribe_writeset()
737 r = dm_btree_find_lowest_key(&md->writeset_tree_info, in metadata_digest_lookup_writeset()
738 md->writeset_tree_root, &key); in metadata_digest_lookup_writeset()
742 d->era = key; in metadata_digest_lookup_writeset()
744 r = dm_btree_lookup(&md->writeset_tree_info, in metadata_digest_lookup_writeset()
745 md->writeset_tree_root, &key, &disk); in metadata_digest_lookup_writeset()
747 if (r == -ENODATA) { in metadata_digest_lookup_writeset()
748 d->step = NULL; in metadata_digest_lookup_writeset()
756 ws_unpack(&disk, &d->writeset); in metadata_digest_lookup_writeset()
757 d->value = cpu_to_le32(key); in metadata_digest_lookup_writeset()
763 dm_disk_bitset_init(md->tm, &d->info); in metadata_digest_lookup_writeset()
765 d->nr_bits = min(d->writeset.nr_bits, md->nr_blocks); in metadata_digest_lookup_writeset()
766 d->current_bit = 0; in metadata_digest_lookup_writeset()
767 d->step = metadata_digest_transcribe_writeset; in metadata_digest_lookup_writeset()
774 if (d->step) in metadata_digest_start()
778 d->step = metadata_digest_lookup_writeset; in metadata_digest_start()
783 /*----------------------------------------------------------------
786 *--------------------------------------------------------------*/
797 md->bdev = bdev; in metadata_open()
798 md->block_size = block_size; in metadata_open()
800 md->writesets[0].md.root = INVALID_WRITESET_ROOT; in metadata_open()
801 md->writesets[1].md.root = INVALID_WRITESET_ROOT; in metadata_open()
802 md->current_writeset = &md->writesets[0]; in metadata_open()
815 writeset_free(&md->writesets[0]); in metadata_close()
816 writeset_free(&md->writesets[1]); in metadata_close()
825 * further to 2^31 - 1 in valid_nr_blocks()
839 return -EINVAL; in metadata_resize()
842 writeset_free(&md->writesets[0]); in metadata_resize()
843 writeset_free(&md->writesets[1]); in metadata_resize()
845 r = writeset_alloc(&md->writesets[0], *new_size); in metadata_resize()
851 r = writeset_alloc(&md->writesets[1], *new_size); in metadata_resize()
854 writeset_free(&md->writesets[0]); in metadata_resize()
860 r = dm_array_resize(&md->era_array_info, md->era_array_root, in metadata_resize()
861 md->nr_blocks, *new_size, in metadata_resize()
862 &value, &md->era_array_root); in metadata_resize()
865 writeset_free(&md->writesets[0]); in metadata_resize()
866 writeset_free(&md->writesets[1]); in metadata_resize()
870 md->nr_blocks = *new_size; in metadata_resize()
880 r = dm_bitset_flush(&md->bitset_info, md->current_writeset->md.root, in metadata_era_archive()
881 &md->current_writeset->md.root); in metadata_era_archive()
887 ws_pack(&md->current_writeset->md, &value); in metadata_era_archive()
889 keys[0] = md->current_era; in metadata_era_archive()
891 r = dm_btree_insert(&md->writeset_tree_info, md->writeset_tree_root, in metadata_era_archive()
892 keys, &value, &md->writeset_tree_root); in metadata_era_archive()
899 md->current_writeset->md.root = INVALID_WRITESET_ROOT; in metadata_era_archive()
900 md->archived_writesets = true; in metadata_era_archive()
907 return (md->current_writeset == &md->writesets[0]) ? in next_writeset()
908 &md->writesets[1] : &md->writesets[0]; in next_writeset()
916 r = writeset_init(&md->bitset_info, new_writeset, md->nr_blocks); in metadata_new_era()
923 md->current_era++; in metadata_new_era()
932 if (md->current_writeset->md.root != INVALID_WRITESET_ROOT) { in metadata_era_rollover()
957 ws = rcu_dereference(md->current_writeset); in metadata_current_marked()
969 if (md->current_writeset->md.root != INVALID_WRITESET_ROOT) { in metadata_commit()
970 r = dm_bitset_flush(&md->bitset_info, md->current_writeset->md.root, in metadata_commit()
971 &md->current_writeset->md.root); in metadata_commit()
978 r = dm_tm_pre_commit(md->tm); in metadata_commit()
998 return dm_tm_commit(md->tm, sblock); in metadata_commit()
1018 if (md->metadata_snap != SUPERBLOCK_LOCATION) { in metadata_take_snap()
1020 return -EINVAL; in metadata_take_snap()
1035 r = dm_sm_inc_block(md->sm, SUPERBLOCK_LOCATION); in metadata_take_snap()
1041 r = dm_tm_shadow_block(md->tm, SUPERBLOCK_LOCATION, in metadata_take_snap()
1045 dm_sm_dec_block(md->sm, SUPERBLOCK_LOCATION); in metadata_take_snap()
1050 r = dm_sm_inc_block(md->sm, md->writeset_tree_root); in metadata_take_snap()
1053 dm_tm_unlock(md->tm, clone); in metadata_take_snap()
1057 r = dm_sm_inc_block(md->sm, md->era_array_root); in metadata_take_snap()
1060 dm_sm_dec_block(md->sm, md->writeset_tree_root); in metadata_take_snap()
1061 dm_tm_unlock(md->tm, clone); in metadata_take_snap()
1065 md->metadata_snap = dm_block_location(clone); in metadata_take_snap()
1067 dm_tm_unlock(md->tm, clone); in metadata_take_snap()
1079 if (md->metadata_snap == SUPERBLOCK_LOCATION) { in metadata_drop_snap()
1081 return -EINVAL; in metadata_drop_snap()
1084 r = dm_tm_read_lock(md->tm, md->metadata_snap, &sb_validator, &clone); in metadata_drop_snap()
1094 md->metadata_snap = SUPERBLOCK_LOCATION; in metadata_drop_snap()
1097 r = dm_btree_del(&md->writeset_tree_info, in metadata_drop_snap()
1098 le64_to_cpu(disk->writeset_tree_root)); in metadata_drop_snap()
1101 dm_tm_unlock(md->tm, clone); in metadata_drop_snap()
1105 r = dm_array_del(&md->era_array_info, le64_to_cpu(disk->era_array_root)); in metadata_drop_snap()
1108 dm_tm_unlock(md->tm, clone); in metadata_drop_snap()
1113 dm_tm_unlock(md->tm, clone); in metadata_drop_snap()
1115 return dm_sm_dec_block(md->sm, location); in metadata_drop_snap()
1131 r = dm_sm_get_nr_free(md->sm, &nr_free); in metadata_get_stats()
1137 r = dm_sm_get_nr_blocks(md->sm, &nr_total); in metadata_get_stats()
1143 s->used = nr_total - nr_free; in metadata_get_stats()
1144 s->total = nr_total; in metadata_get_stats()
1145 s->snap = md->metadata_snap; in metadata_get_stats()
1146 s->era = md->current_era; in metadata_get_stats()
1151 /*----------------------------------------------------------------*/
1188 /*----------------------------------------------------------------
1190 *---------------------------------------------------------------*/
1193 return era->sectors_per_block_shift >= 0; in block_size_is_power_of_two()
1198 sector_t block_nr = bio->bi_iter.bi_sector; in get_block()
1201 (void) sector_div(block_nr, era->sectors_per_block); in get_block()
1203 block_nr >>= era->sectors_per_block_shift; in get_block()
1210 bio_set_dev(bio, era->origin_dev->bdev); in remap_to_origin()
1213 /*----------------------------------------------------------------
1215 *--------------------------------------------------------------*/
1218 if (!atomic_read(&era->suspended)) in wake_worker()
1219 queue_work(era->wq, &era->worker); in wake_worker()
1226 if (!era->digest.step) in process_old_eras()
1229 r = era->digest.step(era->md, &era->digest); in process_old_eras()
1232 era->digest.step = NULL; in process_old_eras()
1234 } else if (era->digest.step) in process_old_eras()
1246 struct writeset *ws = era->md->current_writeset; in process_deferred_bios()
1251 spin_lock(&era->deferred_lock); in process_deferred_bios()
1252 bio_list_merge(&deferred_bios, &era->deferred_bios); in process_deferred_bios()
1253 bio_list_init(&era->deferred_bios); in process_deferred_bios()
1254 spin_unlock(&era->deferred_lock); in process_deferred_bios()
1260 r = writeset_test_and_set(&era->md->bitset_info, ws, in process_deferred_bios()
1275 r = metadata_commit(era->md); in process_deferred_bios()
1287 * Only update the in-core writeset if the on-disk one in process_deferred_bios()
1291 set_bit(get_block(era, bio), ws->bits); in process_deferred_bios()
1306 spin_lock(&era->rpc_lock); in process_rpc_calls()
1307 list_splice_init(&era->rpc_calls, &calls); in process_rpc_calls()
1308 spin_unlock(&era->rpc_lock); in process_rpc_calls()
1311 rpc->result = rpc->fn0 ? rpc->fn0(era->md) : rpc->fn1(era->md, rpc->arg); in process_rpc_calls()
1316 r = metadata_commit(era->md); in process_rpc_calls()
1319 rpc->result = r; in process_rpc_calls()
1323 complete(&rpc->complete); in process_rpc_calls()
1328 if (era->md->archived_writesets) { in kick_off_digest()
1329 era->md->archived_writesets = false; in kick_off_digest()
1330 metadata_digest_start(era->md, &era->digest); in kick_off_digest()
1346 spin_lock(&era->deferred_lock); in defer_bio()
1347 bio_list_add(&era->deferred_bios, bio); in defer_bio()
1348 spin_unlock(&era->deferred_lock); in defer_bio()
1358 rpc->result = 0; in perform_rpc()
1359 init_completion(&rpc->complete); in perform_rpc()
1361 spin_lock(&era->rpc_lock); in perform_rpc()
1362 list_add(&rpc->list, &era->rpc_calls); in perform_rpc()
1363 spin_unlock(&era->rpc_lock); in perform_rpc()
1366 wait_for_completion(&rpc->complete); in perform_rpc()
1368 return rpc->result; in perform_rpc()
1393 atomic_set(&era->suspended, 0); in start_worker()
1398 atomic_set(&era->suspended, 1); in stop_worker()
1399 drain_workqueue(era->wq); in stop_worker()
1402 /*----------------------------------------------------------------
1404 *--------------------------------------------------------------*/
1407 if (era->md) in era_destroy()
1408 metadata_close(era->md); in era_destroy()
1410 if (era->wq) in era_destroy()
1411 destroy_workqueue(era->wq); in era_destroy()
1413 if (era->origin_dev) in era_destroy()
1414 dm_put_device(era->ti, era->origin_dev); in era_destroy()
1416 if (era->metadata_dev) in era_destroy()
1417 dm_put_device(era->ti, era->metadata_dev); in era_destroy()
1424 return dm_sector_div_up(era->ti->len, era->sectors_per_block); in calc_nr_blocks()
1430 bool multiple_of_min_block_size = (block_size & (MIN_BLOCK_SIZE - 1)) == 0; in valid_block_size()
1446 ti->error = "Invalid argument count"; in era_ctr()
1447 return -EINVAL; in era_ctr()
1452 ti->error = "Error allocating era structure"; in era_ctr()
1453 return -ENOMEM; in era_ctr()
1456 era->ti = ti; in era_ctr()
1458 r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &era->metadata_dev); in era_ctr()
1460 ti->error = "Error opening metadata device"; in era_ctr()
1462 return -EINVAL; in era_ctr()
1465 r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &era->origin_dev); in era_ctr()
1467 ti->error = "Error opening data device"; in era_ctr()
1469 return -EINVAL; in era_ctr()
1472 r = sscanf(argv[2], "%u%c", &era->sectors_per_block, &dummy); in era_ctr()
1474 ti->error = "Error parsing block size"; in era_ctr()
1476 return -EINVAL; in era_ctr()
1479 r = dm_set_target_max_io_len(ti, era->sectors_per_block); in era_ctr()
1481 ti->error = "could not set max io len"; in era_ctr()
1483 return -EINVAL; in era_ctr()
1486 if (!valid_block_size(era->sectors_per_block)) { in era_ctr()
1487 ti->error = "Invalid block size"; in era_ctr()
1489 return -EINVAL; in era_ctr()
1491 if (era->sectors_per_block & (era->sectors_per_block - 1)) in era_ctr()
1492 era->sectors_per_block_shift = -1; in era_ctr()
1494 era->sectors_per_block_shift = __ffs(era->sectors_per_block); in era_ctr()
1496 md = metadata_open(era->metadata_dev->bdev, era->sectors_per_block, true); in era_ctr()
1498 ti->error = "Error reading metadata"; in era_ctr()
1502 era->md = md; in era_ctr()
1504 era->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM); in era_ctr()
1505 if (!era->wq) { in era_ctr()
1506 ti->error = "could not create workqueue for metadata object"; in era_ctr()
1508 return -ENOMEM; in era_ctr()
1510 INIT_WORK(&era->worker, do_work); in era_ctr()
1512 spin_lock_init(&era->deferred_lock); in era_ctr()
1513 bio_list_init(&era->deferred_bios); in era_ctr()
1515 spin_lock_init(&era->rpc_lock); in era_ctr()
1516 INIT_LIST_HEAD(&era->rpc_calls); in era_ctr()
1518 ti->private = era; in era_ctr()
1519 ti->num_flush_bios = 1; in era_ctr()
1520 ti->flush_supported = true; in era_ctr()
1522 ti->num_discard_bios = 1; in era_ctr()
1529 era_destroy(ti->private); in era_dtr()
1534 struct era *era = ti->private; in era_map()
1547 if (!(bio->bi_opf & REQ_PREFLUSH) && in era_map()
1549 !metadata_current_marked(era->md, block)) { in era_map()
1560 struct era *era = ti->private; in era_postsuspend()
1570 r = metadata_commit(era->md); in era_postsuspend()
1580 struct era *era = ti->private; in era_preresume()
1583 if (era->nr_blocks != new_size) { in era_preresume()
1584 r = metadata_resize(era->md, &new_size); in era_preresume()
1590 r = metadata_commit(era->md); in era_preresume()
1596 era->nr_blocks = new_size; in era_preresume()
1614 * <current era> <held metadata root | '-'>
1620 struct era *era = ti->private; in era_status()
1640 DMEMIT(" -"); in era_status()
1644 format_dev_t(buf, era->metadata_dev->bdev->bd_dev); in era_status()
1646 format_dev_t(buf, era->origin_dev->bdev->bd_dev); in era_status()
1647 DMEMIT("%s %u", buf, era->sectors_per_block); in era_status()
1660 struct era *era = ti->private; in era_message()
1664 return -EINVAL; in era_message()
1677 return -EINVAL; in era_message()
1682 return i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT; in get_dev_size()
1688 struct era *era = ti->private; in era_iterate_devices()
1689 return fn(ti, era->origin_dev, 0, get_dev_size(era->origin_dev), data); in era_iterate_devices()
1694 struct era *era = ti->private; in era_io_hints()
1695 uint64_t io_opt_sectors = limits->io_opt >> SECTOR_SHIFT; in era_io_hints()
1698 * If the system-determined stacked limits are compatible with the in era_io_hints()
1701 if (io_opt_sectors < era->sectors_per_block || in era_io_hints()
1702 do_div(io_opt_sectors, era->sectors_per_block)) { in era_io_hints()
1704 blk_limits_io_opt(limits, era->sectors_per_block << SECTOR_SHIFT); in era_io_hints()
1708 /*----------------------------------------------------------------*/