Lines Matching +full:static +full:- +full:config

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/device-mapper.h>
16 #include "admin-state.h"
17 #include "block-map.h"
20 #include "data-vio.h"
26 #include "io-submitter.h"
28 #include "memory-alloc.h"
29 #include "message-stats.h"
30 #include "recovery-journal.h"
32 #include "slab-depot.h"
33 #include "status-codes.h"
34 #include "string-utils.h"
35 #include "thread-device.h"
36 #include "thread-registry.h"
37 #include "thread-utils.h"
91 static const char * const ADMIN_PHASE_NAMES[] = {
144 static const u8 REQUIRED_ARGC[] = { 10, 12, 9, 7, 6 };
146 static const u8 POOL_NAME_ARG_INDEX[] = { 8, 10, 8 };
149 * Track in-use instance numbers using a flat bit array.
156 * This minimum size for the bit array creates a numbering space of 0-999, which allows
158 * reasonably-sized test. Changing instances on restart allows vdoMonReport to detect that
172 static DEFINE_MUTEX(instances_lock);
173 static struct instance_tracker instances;
176 * free_device_config() - Free a device config created by parse_device_config().
177 * @config: The config to free.
179 static void free_device_config(struct device_config *config) in free_device_config() argument
181 if (config == NULL) in free_device_config()
184 if (config->owned_device != NULL) in free_device_config()
185 dm_put_device(config->owning_target, config->owned_device); in free_device_config()
187 vdo_free(config->parent_device_name); in free_device_config()
188 vdo_free(config->original_string); in free_device_config()
190 /* Reduce the chance a use-after-free (as in BZ 1669960) happens to work. */ in free_device_config()
191 memset(config, 0, sizeof(*config)); in free_device_config()
192 vdo_free(config); in free_device_config()
196 * get_version_number() - Decide the version number from argv.
205 static int get_version_number(int argc, char **argv, char **error_ptr, in get_version_number()
221 * config, even if it's a "." to show it's an empty list. in get_version_number()
241 /* Free a list of non-NULL string pointers, and then the list itself. */
242 static void free_string_array(char **string_array) in free_string_array()
253 * returning a null-terminated list of string pointers.
263 static int split_string(const char *string, char separator, char ***substring_array_ptr) in split_string()
276 result = vdo_allocate(substring_count + 1, char *, "string-splitting array", in split_string()
283 ptrdiff_t length = s - string; in split_string()
293 * more non-NUL bytes in the string. in split_string()
303 BUG_ON(current_substring != (substring_count - 1)); in split_string()
322 * is not NULL-terminated.
324 static int join_strings(char **substring_array, size_t array_length, char separator, in join_strings()
351 *(current_position - 1) = '\0'; in join_strings()
358 * parse_bool() - Parse a two-valued option into a bool.
366 static inline int __must_check parse_bool(const char *bool_str, const char *true_str, in parse_bool()
383 * process_one_thread_config_spec() - Process one component of a thread parameter configuration
387 * @config: The configuration data structure to update.
389 * If the thread count requested is invalid, a message is logged and -EINVAL returned. If the
392 * Return: VDO_SUCCESS or -EINVAL
394 static int process_one_thread_config_spec(const char *thread_param_type, in process_one_thread_config_spec()
396 struct thread_count_config *config) in process_one_thread_config_spec() argument
401 vdo_log_error("thread config string error: 'bioRotationInterval' of at least 1 is required"); in process_one_thread_config_spec()
402 return -EINVAL; in process_one_thread_config_spec()
404 vdo_log_error("thread config string error: 'bioRotationInterval' cannot be higher than %d", in process_one_thread_config_spec()
406 return -EINVAL; in process_one_thread_config_spec()
408 config->bio_rotation_interval = count; in process_one_thread_config_spec()
413 vdo_log_error("thread config string error: at most %d 'logical' threads are allowed", in process_one_thread_config_spec()
415 return -EINVAL; in process_one_thread_config_spec()
417 config->logical_zones = count; in process_one_thread_config_spec()
422 vdo_log_error("thread config string error: at most %d 'physical' threads are allowed", in process_one_thread_config_spec()
424 return -EINVAL; in process_one_thread_config_spec()
426 config->physical_zones = count; in process_one_thread_config_spec()
431 vdo_log_error("thread config string error: at most %d '%s' threads are allowed", in process_one_thread_config_spec()
433 return -EINVAL; in process_one_thread_config_spec()
436 config->hash_zones = count; in process_one_thread_config_spec()
441 vdo_log_error("thread config string error: at least one 'cpu' thread required"); in process_one_thread_config_spec()
442 return -EINVAL; in process_one_thread_config_spec()
444 config->cpu_threads = count; in process_one_thread_config_spec()
448 config->bio_ack_threads = count; in process_one_thread_config_spec()
453 vdo_log_error("thread config string error: at least one 'bio' thread required"); in process_one_thread_config_spec()
454 return -EINVAL; in process_one_thread_config_spec()
456 config->bio_threads = count; in process_one_thread_config_spec()
469 * parse_one_thread_config_spec() - Parse one component of a thread parameter configuration string
472 * @config: The configuration data to be updated.
474 static int parse_one_thread_config_spec(const char *spec, in parse_one_thread_config_spec()
475 struct thread_count_config *config) in parse_one_thread_config_spec() argument
486 vdo_log_error("thread config string error: expected thread parameter assignment, saw \"%s\"", in parse_one_thread_config_spec()
489 return -EINVAL; in parse_one_thread_config_spec()
494 vdo_log_error("thread config string error: integer value needed, found \"%s\"", in parse_one_thread_config_spec()
500 result = process_one_thread_config_spec(fields[0], count, config); in parse_one_thread_config_spec()
506 * parse_thread_config_string() - Parse the configuration string passed and update the specified
510 * @config: The thread configuration data to update.
512 * The configuration string should contain one or more comma-separated specs of the form
523 * Return: VDO_SUCCESS or -EINVAL or -ENOMEM
525 static int parse_thread_config_string(const char *string, in parse_thread_config_string()
526 struct thread_count_config *config) in parse_thread_config_string() argument
539 result = parse_one_thread_config_spec(specs[i], config); in parse_thread_config_string()
549 * process_one_key_value_pair() - Process one component of an optional parameter string and update
553 * @config: The configuration data structure to update.
555 * If the value requested is invalid, a message is logged and -EINVAL returned. If the key is
558 * Return: VDO_SUCCESS or -EINVAL
560 static int process_one_key_value_pair(const char *key, unsigned int value, in process_one_key_value_pair()
561 struct device_config *config) in process_one_key_value_pair() argument
567 return -EINVAL; in process_one_key_value_pair()
573 return -EINVAL; in process_one_key_value_pair()
575 config->max_discard_blocks = value; in process_one_key_value_pair()
579 return process_one_thread_config_spec(key, value, &config->thread_counts); in process_one_key_value_pair()
583 * parse_one_key_value_pair() - Parse one key/value pair and update the configuration data
587 * @config: The configuration data to be updated.
591 static int parse_one_key_value_pair(const char *key, const char *value, in parse_one_key_value_pair()
592 struct device_config *config) in parse_one_key_value_pair() argument
598 return parse_bool(value, "on", "off", &config->deduplication); in parse_one_key_value_pair()
601 return parse_bool(value, "on", "off", &config->compression); in parse_one_key_value_pair()
606 vdo_log_error("optional config string error: integer value needed, found \"%s\"", in parse_one_key_value_pair()
610 return process_one_key_value_pair(key, count, config); in parse_one_key_value_pair()
614 * parse_key_value_pairs() - Parse all key/value pairs from a list of arguments.
617 * @config: The device configuration data to update.
628 static int parse_key_value_pairs(int argc, char **argv, struct device_config *config) in parse_key_value_pairs() argument
633 result = parse_one_key_value_pair(argv[0], argv[1], config); in parse_key_value_pairs()
637 argc -= 2; in parse_key_value_pairs()
645 * parse_optional_arguments() - Parse the configuration string passed in for optional arguments.
648 * @config: Pointer to device configuration data to update.
651 * The configuration string should contain one or more comma-separated specs of the form
660 static int parse_optional_arguments(struct dm_arg_set *arg_set, char **error_ptr, in parse_optional_arguments()
661 struct device_config *config) in parse_optional_arguments() argument
665 if (config->version == 0 || config->version == 1) { in parse_optional_arguments()
666 result = parse_thread_config_string(arg_set->argv[0], in parse_optional_arguments()
667 &config->thread_counts); in parse_optional_arguments()
669 *error_ptr = "Invalid thread-count configuration"; in parse_optional_arguments()
673 if ((arg_set->argc % 2) != 0) { in parse_optional_arguments()
677 result = parse_key_value_pairs(arg_set->argc, arg_set->argv, config); in parse_optional_arguments()
687 * handle_parse_error() - Handle a parsing error.
688 * @config: The config to free.
692 static void handle_parse_error(struct device_config *config, char **error_ptr, in handle_parse_error() argument
695 free_device_config(config); in handle_parse_error()
700 * parse_device_config() - Convert the dmsetup table into a struct device_config.
704 * @config_ptr: A pointer to return the allocated config.
708 static int parse_device_config(int argc, char **argv, struct dm_target *ti, in parse_device_config()
712 size_t logical_bytes = to_bytes(ti->len); in parse_device_config()
714 char **error_ptr = &ti->error; in parse_device_config()
715 struct device_config *config = NULL; in parse_device_config() local
719 handle_parse_error(config, error_ptr, in parse_device_config()
725 handle_parse_error(config, error_ptr, "Incorrect number of arguments"); in parse_device_config()
729 result = vdo_allocate(1, struct device_config, "device_config", &config); in parse_device_config()
731 handle_parse_error(config, error_ptr, in parse_device_config()
732 "Could not allocate config structure"); in parse_device_config()
736 config->owning_target = ti; in parse_device_config()
737 config->logical_blocks = logical_bytes / VDO_BLOCK_SIZE; in parse_device_config()
738 INIT_LIST_HEAD(&config->config_list); in parse_device_config()
741 result = join_strings(argv, argc, ' ', &config->original_string); in parse_device_config()
743 handle_parse_error(config, error_ptr, "Could not populate string"); in parse_device_config()
747 vdo_log_info("table line: %s", config->original_string); in parse_device_config()
749 config->thread_counts = (struct thread_count_config) { in parse_device_config()
758 config->max_discard_blocks = 1; in parse_device_config()
759 config->deduplication = true; in parse_device_config()
760 config->compression = false; in parse_device_config()
765 result = get_version_number(argc, argv, error_ptr, &config->version); in parse_device_config()
768 handle_parse_error(config, error_ptr, *error_ptr); in parse_device_config()
772 if (config->version >= 1) in parse_device_config()
776 &config->parent_device_name); in parse_device_config()
778 handle_parse_error(config, error_ptr, in parse_device_config()
784 if (config->version >= 1) { in parse_device_config()
785 result = kstrtoull(dm_shift_arg(&arg_set), 10, &config->physical_blocks); in parse_device_config()
787 handle_parse_error(config, error_ptr, in parse_device_config()
796 handle_parse_error(config, error_ptr, "Invalid logical block size"); in parse_device_config()
799 config->logical_block_size = (enable_512e ? 512 : 4096); in parse_device_config()
802 if (config->version <= 1) in parse_device_config()
806 result = kstrtouint(dm_shift_arg(&arg_set), 10, &config->cache_size); in parse_device_config()
808 handle_parse_error(config, error_ptr, in parse_device_config()
814 result = kstrtouint(dm_shift_arg(&arg_set), 10, &config->block_map_maximum_age); in parse_device_config()
816 handle_parse_error(config, error_ptr, "Invalid block map maximum age"); in parse_device_config()
821 if (config->version <= 2) in parse_device_config()
825 if (config->version <= 3) in parse_device_config()
829 if (config->version <= 2) { in parse_device_config()
834 if (&arg_set.argv[0] != &argv[POOL_NAME_ARG_INDEX[config->version]]) { in parse_device_config()
835 handle_parse_error(config, error_ptr, in parse_device_config()
843 result = parse_optional_arguments(&arg_set, error_ptr, config); in parse_device_config()
846 handle_parse_error(config, error_ptr, *error_ptr); in parse_device_config()
852 * everything, our older configuration. If any zone count is non-zero, the others must be in parse_device_config()
855 if (((config->thread_counts.logical_zones == 0) != in parse_device_config()
856 (config->thread_counts.physical_zones == 0)) || in parse_device_config()
857 ((config->thread_counts.physical_zones == 0) != in parse_device_config()
858 (config->thread_counts.hash_zones == 0))) { in parse_device_config()
859 handle_parse_error(config, error_ptr, in parse_device_config()
860 "Logical, physical, and hash zones counts must all be zero or all non-zero"); in parse_device_config()
864 if (config->cache_size < in parse_device_config()
865 (2 * MAXIMUM_VDO_USER_VIOS * config->thread_counts.logical_zones)) { in parse_device_config()
866 handle_parse_error(config, error_ptr, in parse_device_config()
871 result = dm_get_device(ti, config->parent_device_name, in parse_device_config()
872 dm_table_get_mode(ti->table), &config->owned_device); in parse_device_config()
875 config->parent_device_name, result); in parse_device_config()
876 handle_parse_error(config, error_ptr, "Unable to open storage device"); in parse_device_config()
880 if (config->version == 0) { in parse_device_config()
881 u64 device_size = bdev_nr_bytes(config->owned_device->bdev); in parse_device_config()
883 config->physical_blocks = device_size / VDO_BLOCK_SIZE; in parse_device_config()
886 *config_ptr = config; in parse_device_config()
890 static struct vdo *get_vdo_for_target(struct dm_target *ti) in get_vdo_for_target()
892 return ((struct device_config *) ti->private)->vdo; in get_vdo_for_target()
896 static int vdo_map_bio(struct dm_target *ti, struct bio *bio) in vdo_map_bio()
900 const struct admin_state_code *code = vdo_get_admin_state_code(&vdo->admin.state); in vdo_map_bio()
902 VDO_ASSERT_LOG_ONLY(code->normal, "vdo should not receive bios while in state %s", in vdo_map_bio()
903 code->name); in vdo_map_bio()
906 vdo_count_bios(&vdo->stats.bios_in, bio); in vdo_map_bio()
910 if ((bio_op(bio) == REQ_OP_FLUSH) || ((bio->bi_opf & REQ_PREFLUSH) != 0)) { in vdo_map_bio()
918 (vdo == vdo_get_work_queue_owner(current_work_queue)->vdo)); in vdo_map_bio()
919 vdo_launch_bio(vdo->data_vio_pool, bio); in vdo_map_bio()
923 static void vdo_io_hints(struct dm_target *ti, struct queue_limits *limits) in vdo_io_hints()
927 limits->logical_block_size = vdo->device_config->logical_block_size; in vdo_io_hints()
928 limits->physical_block_size = VDO_BLOCK_SIZE; in vdo_io_hints()
931 limits->io_min = VDO_BLOCK_SIZE; in vdo_io_hints()
933 limits->io_opt = VDO_BLOCK_SIZE; in vdo_io_hints()
945 * The value is used by dm-thin to determine whether to pass down discards. The block layer in vdo_io_hints()
948 limits->max_hw_discard_sectors = in vdo_io_hints()
949 (vdo->device_config->max_discard_blocks * VDO_SECTORS_PER_BLOCK); in vdo_io_hints()
955 limits->discard_granularity = VDO_BLOCK_SIZE; in vdo_io_hints()
958 static int vdo_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, in vdo_iterate_devices()
961 struct device_config *config = get_vdo_for_target(ti)->device_config; in vdo_iterate_devices() local
963 return fn(ti, config->owned_device, 0, in vdo_iterate_devices()
964 config->physical_blocks * VDO_SECTORS_PER_BLOCK, data); in vdo_iterate_devices()
973 static void vdo_status(struct dm_target *ti, status_type_t status_type, in vdo_status()
985 mutex_lock(&vdo->stats_mutex); in vdo_status()
986 vdo_fetch_statistics(vdo, &vdo->stats_buffer); in vdo_status()
987 stats = &vdo->stats_buffer; in vdo_status()
990 vdo_get_backing_device(vdo), stats->mode, in vdo_status()
991 stats->in_recovery_mode ? "recovering" : "-", in vdo_status()
992 vdo_get_dedupe_index_state_name(vdo->hash_zones), in vdo_status()
994 stats->data_blocks_used + stats->overhead_blocks_used, in vdo_status()
995 stats->physical_blocks); in vdo_status()
996 mutex_unlock(&vdo->stats_mutex); in vdo_status()
1001 device_config = (struct device_config *) ti->private; in vdo_status()
1002 DMEMIT("%s", device_config->original_string); in vdo_status()
1012 static block_count_t __must_check get_underlying_device_block_count(const struct vdo *vdo) in get_underlying_device_block_count()
1017 static int __must_check process_vdo_message_locked(struct vdo *vdo, unsigned int argc, in process_vdo_message_locked()
1033 return -EINVAL; in process_vdo_message_locked()
1037 return -EINVAL; in process_vdo_message_locked()
1043 * Returns -EBUSY if another message is being processed
1045 static int __must_check process_vdo_message(struct vdo *vdo, unsigned int argc, in process_vdo_message()
1061 if (strcasecmp(argv[0], "dump-on-shutdown") == 0) { in process_vdo_message()
1062 vdo->dump_on_shutdown = true; in process_vdo_message()
1067 if ((strcasecmp(argv[0], "index-close") == 0) || in process_vdo_message()
1068 (strcasecmp(argv[0], "index-create") == 0) || in process_vdo_message()
1069 (strcasecmp(argv[0], "index-disable") == 0) || in process_vdo_message()
1070 (strcasecmp(argv[0], "index-enable") == 0)) in process_vdo_message()
1071 return vdo_message_dedupe_index(vdo->hash_zones, argv[0]); in process_vdo_message()
1074 if (atomic_cmpxchg(&vdo->processing_message, 0, 1) != 0) in process_vdo_message()
1075 return -EBUSY; in process_vdo_message()
1081 atomic_set(&vdo->processing_message, 0); in process_vdo_message()
1085 static int vdo_message(struct dm_target *ti, unsigned int argc, char **argv, in vdo_message()
1094 return -EINVAL; in vdo_message()
1099 vdo_register_thread_device_id(&instance_thread, &vdo->instance); in vdo_message()
1102 * Must be done here so we don't map return codes. The code in dm-ioctl expects a 1 for a in vdo_message()
1108 } else if ((argc == 1) && (strcasecmp(argv[0], "config") == 0)) { in vdo_message()
1120 static void configure_target_capabilities(struct dm_target *ti) in configure_target_capabilities()
1122 ti->discards_supported = 1; in configure_target_capabilities()
1123 ti->flush_supported = true; in configure_target_capabilities()
1124 ti->num_discard_bios = 1; in configure_target_capabilities()
1125 ti->num_flush_bios = 1; in configure_target_capabilities()
1137 static bool vdo_uses_device(struct vdo *vdo, const void *context) in vdo_uses_device()
1139 const struct device_config *config = context; in vdo_uses_device() local
1141 return vdo_get_backing_device(vdo)->bd_dev == config->owned_device->bdev->bd_dev; in vdo_uses_device()
1145 * get_thread_id_for_phase() - Get the thread id for the current phase of the admin operation in
1148 static thread_id_t __must_check get_thread_id_for_phase(struct vdo *vdo) in get_thread_id_for_phase()
1150 switch (vdo->admin.phase) { in get_thread_id_for_phase()
1155 return vdo->thread_config.packer_thread; in get_thread_id_for_phase()
1159 return vdo->thread_config.cpu_thread; in get_thread_id_for_phase()
1164 return vdo->thread_config.journal_thread; in get_thread_id_for_phase()
1167 return vdo->thread_config.admin_thread; in get_thread_id_for_phase()
1171 static struct vdo_completion *prepare_admin_completion(struct vdo *vdo, in prepare_admin_completion()
1175 struct vdo_completion *completion = &vdo->admin.completion; in prepare_admin_completion()
1181 completion->callback = callback; in prepare_admin_completion()
1182 completion->error_handler = error_handler; in prepare_admin_completion()
1183 completion->callback_thread_id = get_thread_id_for_phase(vdo); in prepare_admin_completion()
1184 completion->requeue = true; in prepare_admin_completion()
1189 * advance_phase() - Increment the phase of the current admin operation and prepare the admin
1195 static u32 advance_phase(struct vdo *vdo) in advance_phase()
1197 u32 phase = vdo->admin.phase++; in advance_phase()
1199 vdo->admin.completion.callback_thread_id = get_thread_id_for_phase(vdo); in advance_phase()
1200 vdo->admin.completion.requeue = true; in advance_phase()
1208 static int perform_admin_operation(struct vdo *vdo, u32 starting_phase, in perform_admin_operation()
1213 struct vdo_administrator *admin = &vdo->admin; in perform_admin_operation()
1215 if (atomic_cmpxchg(&admin->busy, 0, 1) != 0) { in perform_admin_operation()
1221 admin->phase = starting_phase; in perform_admin_operation()
1222 reinit_completion(&admin->callback_sync); in perform_admin_operation()
1223 vdo_reset_completion(&admin->completion); in perform_admin_operation()
1230 while (wait_for_completion_interruptible(&admin->callback_sync)) { in perform_admin_operation()
1231 /* However, if we get a signal in a user-mode process, we could spin... */ in perform_admin_operation()
1235 result = admin->completion.result; in perform_admin_operation()
1238 atomic_set(&admin->busy, 0); in perform_admin_operation()
1243 static void assert_admin_phase_thread(struct vdo *vdo, const char *what) in assert_admin_phase_thread()
1247 ADMIN_PHASE_NAMES[vdo->admin.phase]); in assert_admin_phase_thread()
1251 * finish_operation_callback() - Callback to finish an admin operation.
1254 static void finish_operation_callback(struct vdo_completion *completion) in finish_operation_callback()
1256 struct vdo_administrator *admin = &completion->vdo->admin; in finish_operation_callback()
1258 vdo_finish_operation(&admin->state, completion->result); in finish_operation_callback()
1259 complete(&admin->callback_sync); in finish_operation_callback()
1263 * decode_from_super_block() - Decode the VDO state from the super block and validate that it is
1272 static int __must_check decode_from_super_block(struct vdo *vdo) in decode_from_super_block()
1274 const struct device_config *config = vdo->device_config; in decode_from_super_block() local
1277 result = vdo_decode_component_states(vdo->super_block.buffer, &vdo->geometry, in decode_from_super_block()
1278 &vdo->states); in decode_from_super_block()
1282 vdo_set_state(vdo, vdo->states.vdo.state); in decode_from_super_block()
1283 vdo->load_state = vdo->states.vdo.state; in decode_from_super_block()
1286 * If the device config specifies a larger logical size than was recorded in the super in decode_from_super_block()
1289 if (vdo->states.vdo.config.logical_blocks < config->logical_blocks) { in decode_from_super_block()
1291 (unsigned long long) config->logical_blocks, in decode_from_super_block()
1292 (unsigned long long) vdo->states.vdo.config.logical_blocks); in decode_from_super_block()
1293 vdo->states.vdo.config.logical_blocks = config->logical_blocks; in decode_from_super_block()
1296 result = vdo_validate_component_states(&vdo->states, vdo->geometry.nonce, in decode_from_super_block()
1297 config->physical_blocks, in decode_from_super_block()
1298 config->logical_blocks); in decode_from_super_block()
1302 vdo->layout = vdo->states.layout; in decode_from_super_block()
1307 * decode_vdo() - Decode the component data portion of a super block and fill in the corresponding
1312 * asynchronous layer (i.e. a thread config which specifies at least one base thread), the block
1317 static int __must_check decode_vdo(struct vdo *vdo) in decode_vdo()
1325 vdo_destroy_component_states(&vdo->states); in decode_vdo()
1329 maximum_age = vdo_convert_maximum_age(vdo->device_config->block_map_maximum_age); in decode_vdo()
1331 vdo_get_recovery_journal_length(vdo->states.vdo.config.recovery_journal_size); in decode_vdo()
1348 partition = vdo_get_known_partition(&vdo->layout, in decode_vdo()
1350 result = vdo_decode_recovery_journal(vdo->states.recovery_journal, in decode_vdo()
1351 vdo->states.vdo.nonce, vdo, partition, in decode_vdo()
1352 vdo->states.vdo.complete_recoveries, in decode_vdo()
1353 vdo->states.vdo.config.recovery_journal_size, in decode_vdo()
1354 &vdo->recovery_journal); in decode_vdo()
1358 partition = vdo_get_known_partition(&vdo->layout, VDO_SLAB_SUMMARY_PARTITION); in decode_vdo()
1359 result = vdo_decode_slab_depot(vdo->states.slab_depot, vdo, partition, in decode_vdo()
1360 &vdo->depot); in decode_vdo()
1364 result = vdo_decode_block_map(vdo->states.block_map, in decode_vdo()
1365 vdo->states.vdo.config.logical_blocks, vdo, in decode_vdo()
1366 vdo->recovery_journal, vdo->states.vdo.nonce, in decode_vdo()
1367 vdo->device_config->cache_size, maximum_age, in decode_vdo()
1368 &vdo->block_map); in decode_vdo()
1372 result = vdo_make_physical_zones(vdo, &vdo->physical_zones); in decode_vdo()
1377 result = vdo_make_logical_zones(vdo, &vdo->logical_zones); in decode_vdo()
1381 return vdo_make_hash_zones(vdo, &vdo->hash_zones); in decode_vdo()
1385 * pre_load_callback() - Callback to initiate a pre-load, registered in vdo_initialize().
1388 static void pre_load_callback(struct vdo_completion *completion) in pre_load_callback()
1390 struct vdo *vdo = completion->vdo; in pre_load_callback()
1397 result = vdo_start_operation(&vdo->admin.state, in pre_load_callback()
1421 static void release_instance(unsigned int instance) in release_instance()
1432 instances.count -= 1; in release_instance()
1437 static void set_device_config(struct dm_target *ti, struct vdo *vdo, in set_device_config()
1438 struct device_config *config) in set_device_config() argument
1440 list_del_init(&config->config_list); in set_device_config()
1441 list_add_tail(&config->config_list, &vdo->device_config_list); in set_device_config()
1442 config->vdo = vdo; in set_device_config()
1443 ti->private = config; in set_device_config()
1447 static int vdo_initialize(struct dm_target *ti, unsigned int instance, in vdo_initialize()
1448 struct device_config *config) in vdo_initialize() argument
1453 u64 logical_size = to_bytes(ti->len); in vdo_initialize()
1457 vdo_log_debug("Logical block size = %llu", (u64) config->logical_block_size); in vdo_initialize()
1460 vdo_log_debug("Physical blocks = %llu", config->physical_blocks); in vdo_initialize()
1461 vdo_log_debug("Block map cache blocks = %u", config->cache_size); in vdo_initialize()
1462 vdo_log_debug("Block map maximum age = %u", config->block_map_maximum_age); in vdo_initialize()
1463 vdo_log_debug("Deduplication = %s", (config->deduplication ? "on" : "off")); in vdo_initialize()
1464 vdo_log_debug("Compression = %s", (config->compression ? "on" : "off")); in vdo_initialize()
1466 vdo = vdo_find_matching(vdo_uses_device, config); in vdo_initialize()
1469 vdo->device_config->parent_device_name); in vdo_initialize()
1470 ti->error = "Cannot share storage device with already-running VDO"; in vdo_initialize()
1474 result = vdo_make(instance, config, &ti->error, &vdo); in vdo_initialize()
1477 result, ti->error); in vdo_initialize()
1483 finish_operation_callback, "pre-load"); in vdo_initialize()
1485 ti->error = ((result == VDO_INVALID_ADMIN_STATE) ? in vdo_initialize()
1486 "Pre-load is only valid immediately after initialization" : in vdo_initialize()
1489 result, ti->error); in vdo_initialize()
1494 set_device_config(ti, vdo, config); in vdo_initialize()
1495 vdo->device_config = config; in vdo_initialize()
1500 static bool __must_check vdo_is_named(struct vdo *vdo, const void *context) in vdo_is_named()
1502 struct dm_target *ti = vdo->device_config->owning_target; in vdo_is_named()
1509 * get_bit_array_size() - Return the number of bytes needed to store a bit array of the specified
1515 static size_t get_bit_array_size(unsigned int bit_count) in get_bit_array_size()
1522 * grow_bit_array() - Re-allocate the bitmap word array so there will more instance numbers that
1530 static int grow_bit_array(void) in grow_bit_array()
1550 * allocate_instance() - Allocate an instance number.
1557 static int allocate_instance(unsigned int *instance_ptr) in allocate_instance()
1591 static int construct_new_vdo_registered(struct dm_target *ti, unsigned int argc, in construct_new_vdo_registered()
1595 struct device_config *config; in construct_new_vdo_registered() local
1597 result = parse_device_config(argc, argv, ti, &config); in construct_new_vdo_registered()
1599 vdo_log_error_strerror(result, "parsing failed: %s", ti->error); in construct_new_vdo_registered()
1601 return -EINVAL; in construct_new_vdo_registered()
1605 result = vdo_initialize(ti, instance, config); in construct_new_vdo_registered()
1608 free_device_config(config); in construct_new_vdo_registered()
1615 static int construct_new_vdo(struct dm_target *ti, unsigned int argc, char **argv) in construct_new_vdo()
1625 return -ENOMEM; in construct_new_vdo()
1634 * check_may_grow_physical() - Callback to check that we're not in recovery mode, used in
1638 static void check_may_grow_physical(struct vdo_completion *completion) in check_may_grow_physical()
1640 struct vdo *vdo = completion->vdo; in check_may_grow_physical()
1654 static block_count_t get_partition_size(struct layout *layout, enum partition_id id) in get_partition_size()
1656 return vdo_get_known_partition(layout, id)->count; in get_partition_size()
1660 * grow_layout() - Make the layout for growing a vdo.
1667 static int grow_layout(struct vdo *vdo, block_count_t old_size, block_count_t new_size) in grow_layout()
1672 if (vdo->next_layout.size == new_size) { in grow_layout()
1678 if (vdo->partition_copier == NULL) { in grow_layout()
1679 vdo->partition_copier = dm_kcopyd_client_create(NULL); in grow_layout()
1680 if (IS_ERR(vdo->partition_copier)) { in grow_layout()
1681 result = PTR_ERR(vdo->partition_copier); in grow_layout()
1682 vdo->partition_copier = NULL; in grow_layout()
1688 vdo_uninitialize_layout(&vdo->next_layout); in grow_layout()
1694 result = vdo_initialize_layout(new_size, vdo->layout.start, in grow_layout()
1695 get_partition_size(&vdo->layout, in grow_layout()
1697 get_partition_size(&vdo->layout, in grow_layout()
1699 get_partition_size(&vdo->layout, in grow_layout()
1701 &vdo->next_layout); in grow_layout()
1703 dm_kcopyd_client_destroy(vdo_forget(vdo->partition_copier)); in grow_layout()
1709 get_partition_size(&vdo->next_layout, in grow_layout()
1711 get_partition_size(&vdo->next_layout, in grow_layout()
1715 vdo_uninitialize_layout(&vdo->next_layout); in grow_layout()
1716 dm_kcopyd_client_destroy(vdo_forget(vdo->partition_copier)); in grow_layout()
1723 static int prepare_to_grow_physical(struct vdo *vdo, block_count_t new_physical_blocks) in prepare_to_grow_physical()
1726 block_count_t current_physical_blocks = vdo->states.vdo.config.physical_blocks; in prepare_to_grow_physical()
1735 "prepare grow-physical"); in prepare_to_grow_physical()
1743 result = vdo_prepare_to_grow_slab_depot(vdo->depot, in prepare_to_grow_physical()
1744 vdo_get_known_partition(&vdo->next_layout, in prepare_to_grow_physical()
1747 vdo_uninitialize_layout(&vdo->next_layout); in prepare_to_grow_physical()
1756 * validate_new_device_config() - Check whether a new device config represents a valid modification
1757 * to an existing config.
1758 * @to_validate: The new config to validate.
1759 * @config: The existing config.
1766 static int validate_new_device_config(struct device_config *to_validate, in validate_new_device_config()
1767 struct device_config *config, bool may_grow, in validate_new_device_config() argument
1770 if (to_validate->owning_target->begin != config->owning_target->begin) { in validate_new_device_config()
1775 if (to_validate->logical_block_size != config->logical_block_size) { in validate_new_device_config()
1780 if (to_validate->logical_blocks < config->logical_blocks) { in validate_new_device_config()
1785 if (to_validate->cache_size != config->cache_size) { in validate_new_device_config()
1790 if (to_validate->block_map_maximum_age != config->block_map_maximum_age) { in validate_new_device_config()
1795 if (memcmp(&to_validate->thread_counts, &config->thread_counts, in validate_new_device_config()
1801 if (to_validate->physical_blocks < config->physical_blocks) { in validate_new_device_config()
1806 if (!may_grow && (to_validate->physical_blocks > config->physical_blocks)) { in validate_new_device_config()
1814 static int prepare_to_modify(struct dm_target *ti, struct device_config *config, in prepare_to_modify() argument
1820 result = validate_new_device_config(config, vdo->device_config, may_grow, in prepare_to_modify()
1821 &ti->error); in prepare_to_modify()
1823 return -EINVAL; in prepare_to_modify()
1825 if (config->logical_blocks > vdo->device_config->logical_blocks) { in prepare_to_modify()
1826 block_count_t logical_blocks = vdo->states.vdo.config.logical_blocks; in prepare_to_modify()
1829 (unsigned long long) config->logical_blocks); in prepare_to_modify()
1830 VDO_ASSERT_LOG_ONLY((config->logical_blocks > logical_blocks), in prepare_to_modify()
1833 result = vdo_prepare_to_grow_block_map(vdo->block_map, in prepare_to_modify()
1834 config->logical_blocks); in prepare_to_modify()
1836 ti->error = "Device vdo_prepare_to_grow_logical failed"; in prepare_to_modify()
1843 if (config->physical_blocks > vdo->device_config->physical_blocks) { in prepare_to_modify()
1844 result = prepare_to_grow_physical(vdo, config->physical_blocks); in prepare_to_modify()
1849 * it to -EIO, which is misleading and ahistorical. in prepare_to_modify()
1851 result = -EINVAL; in prepare_to_modify()
1855 …ti->error = "Device vdo_prepare_to_grow_physical failed (specified physical size too big based on … in prepare_to_modify()
1857 ti->error = "Device vdo_prepare_to_grow_physical failed"; in prepare_to_modify()
1863 if (strcmp(config->parent_device_name, vdo->device_config->parent_device_name) != 0) { in prepare_to_modify()
1864 const char *device_name = vdo_get_device_name(config->owning_target); in prepare_to_modify()
1867 vdo->device_config->parent_device_name, in prepare_to_modify()
1868 config->parent_device_name); in prepare_to_modify()
1874 static int update_existing_vdo(const char *device_name, struct dm_target *ti, in update_existing_vdo()
1878 struct device_config *config; in update_existing_vdo() local
1880 result = parse_device_config(argc, argv, ti, &config); in update_existing_vdo()
1882 return -EINVAL; in update_existing_vdo()
1885 result = prepare_to_modify(ti, config, vdo); in update_existing_vdo()
1887 free_device_config(config); in update_existing_vdo()
1891 set_device_config(ti, vdo, config); in update_existing_vdo()
1895 static int vdo_ctr(struct dm_target *ti, unsigned int argc, char **argv) in vdo_ctr()
1908 vdo_register_thread_device_id(&instance_thread, &vdo->instance); in vdo_ctr()
1917 static void vdo_dtr(struct dm_target *ti) in vdo_dtr()
1919 struct device_config *config = ti->private; in vdo_dtr() local
1920 struct vdo *vdo = vdo_forget(config->vdo); in vdo_dtr()
1922 list_del_init(&config->config_list); in vdo_dtr()
1923 if (list_empty(&vdo->device_config_list)) { in vdo_dtr()
1926 /* This was the last config referencing the VDO. Free it. */ in vdo_dtr()
1927 unsigned int instance = vdo->instance; in vdo_dtr()
1935 if (vdo->dump_on_shutdown) in vdo_dtr()
1943 } else if (config == vdo->device_config) { in vdo_dtr()
1945 * The VDO still references this config. Give it a reference to a config that isn't in vdo_dtr()
1948 vdo->device_config = list_first_entry(&vdo->device_config_list, in vdo_dtr()
1952 free_device_config(config); in vdo_dtr()
1953 ti->private = NULL; in vdo_dtr()
1956 static void vdo_presuspend(struct dm_target *ti) in vdo_presuspend()
1958 get_vdo_for_target(ti)->suspend_type = in vdo_presuspend()
1963 * write_super_block_for_suspend() - Update the VDO state and save the super block.
1966 static void write_super_block_for_suspend(struct vdo_completion *completion) in write_super_block_for_suspend()
1968 struct vdo *vdo = completion->vdo; in write_super_block_for_suspend()
1993 * suspend_callback() - Callback to initiate a suspend, registered in vdo_postsuspend().
1994 * @completion: The sub-task completion.
1996 static void suspend_callback(struct vdo_completion *completion) in suspend_callback()
1998 struct vdo *vdo = completion->vdo; in suspend_callback()
1999 struct admin_state *state = &vdo->admin.state; in suspend_callback()
2006 if (vdo_get_admin_state_code(state)->quiescent) { in suspend_callback()
2012 vdo_start_operation(state, vdo->suspend_type)); in suspend_callback()
2017 * If the VDO was already resumed from a prior suspend while read-only, some of the in suspend_callback()
2018 * components may not have been resumed. By setting a read-only error here, we in suspend_callback()
2025 vdo_drain_packer(vdo->packer, completion); in suspend_callback()
2029 drain_data_vio_pool(vdo->data_vio_pool, completion); in suspend_callback()
2033 vdo_drain_hash_zones(vdo->hash_zones, completion); in suspend_callback()
2037 vdo_drain_flusher(vdo->flusher, completion); in suspend_callback()
2050 vdo_drain_logical_zones(vdo->logical_zones, in suspend_callback()
2055 vdo_drain_block_map(vdo->block_map, vdo_get_admin_state_code(state), in suspend_callback()
2060 vdo_drain_recovery_journal(vdo->recovery_journal, in suspend_callback()
2065 vdo_drain_slab_depot(vdo->depot, vdo_get_admin_state_code(state), in suspend_callback()
2074 if (vdo_is_state_suspending(state) || (completion->result != VDO_SUCCESS)) { in suspend_callback()
2092 static void vdo_postsuspend(struct dm_target *ti) in vdo_postsuspend()
2099 vdo_register_thread_device_id(&instance_thread, &vdo->instance); in vdo_postsuspend()
2100 device_name = vdo_get_device_name(vdo->device_config->owning_target); in vdo_postsuspend()
2104 * It's important to note any error here does not actually stop device-mapper from in vdo_postsuspend()
2112 * Treat VDO_READ_ONLY as a success since a read-only suspension still leaves the in vdo_postsuspend()
2118 vdo_get_admin_state(vdo)->name); in vdo_postsuspend()
2128 * was_new() - Check whether the vdo was new when it was loaded.
2133 static bool was_new(const struct vdo *vdo) in was_new()
2135 return (vdo->load_state == VDO_NEW); in was_new()
2139 * requires_repair() - Check whether a vdo requires recovery or rebuild.
2144 static bool __must_check requires_repair(const struct vdo *vdo) in requires_repair()
2159 * get_load_type() - Determine how the slab depot was loaded.
2164 static enum slab_depot_load_type get_load_type(struct vdo *vdo) in get_load_type()
2166 if (vdo_state_requires_read_only_rebuild(vdo->load_state)) in get_load_type()
2169 if (vdo_state_requires_recovery(vdo->load_state)) in get_load_type()
2176 * load_callback() - Callback to do the destructive parts of loading a VDO.
2177 * @completion: The sub-task completion.
2179 static void load_callback(struct vdo_completion *completion) in load_callback()
2181 struct vdo *vdo = completion->vdo; in load_callback()
2188 result = vdo_start_operation(&vdo->admin.state, VDO_ADMIN_STATE_LOADING); in load_callback()
2195 vdo_open_recovery_journal(vdo->recovery_journal, vdo->depot, in load_callback()
2196 vdo->block_map); in load_callback()
2201 vdo_set_dedupe_state_normal(vdo->hash_zones); in load_callback()
2204 * In read-only mode we don't use the allocator and it may not even be in load_callback()
2216 vdo_load_slab_depot(vdo->depot, in load_callback()
2228 vdo_initialize_block_map_from_journal(vdo->block_map, in load_callback()
2229 vdo->recovery_journal); in load_callback()
2230 vdo_prepare_slab_depot_to_allocate(vdo->depot, get_load_type(vdo), in load_callback()
2235 if (vdo_state_requires_recovery(vdo->load_state)) in load_callback()
2238 vdo_scrub_all_unrecovered_slabs(vdo->depot, completion); in load_callback()
2242 WRITE_ONCE(vdo->compressing, vdo->device_config->compression); in load_callback()
2243 if (vdo->device_config->deduplication) { in load_callback()
2246 * messages) if this is known to be a newly-formatted volume. in load_callback()
2248 vdo_start_dedupe_index(vdo->hash_zones, was_new(vdo)); in load_callback()
2251 vdo->allocations_allowed = false; in load_callback()
2258 vdo_drain_recovery_journal(vdo->recovery_journal, VDO_ADMIN_STATE_SAVING, in load_callback()
2264 completion->error_handler = NULL; in load_callback()
2265 vdo->admin.phase = LOAD_PHASE_FINISHED; in load_callback()
2277 * handle_load_error() - Handle an error during the load operation.
2280 * If at all possible, brings the vdo online in read-only mode. This handler is registered in
2283 static void handle_load_error(struct vdo_completion *completion) in handle_load_error()
2285 struct vdo *vdo = completion->vdo; in handle_load_error()
2288 vdo->thread_config.admin_thread)) in handle_load_error()
2291 if (vdo_state_requires_read_only_rebuild(vdo->load_state) && in handle_load_error()
2292 (vdo->admin.phase == LOAD_PHASE_MAKE_DIRTY)) { in handle_load_error()
2293 vdo_log_error_strerror(completion->result, "aborting load"); in handle_load_error()
2294 vdo->admin.phase = LOAD_PHASE_DRAIN_JOURNAL; in handle_load_error()
2299 if ((completion->result == VDO_UNSUPPORTED_VERSION) && in handle_load_error()
2300 (vdo->admin.phase == LOAD_PHASE_MAKE_DIRTY)) { in handle_load_error()
2302 vdo->admin.phase = LOAD_PHASE_FINISHED; in handle_load_error()
2307 vdo_log_error_strerror(completion->result, in handle_load_error()
2308 "Entering read-only mode due to load error"); in handle_load_error()
2309 vdo->admin.phase = LOAD_PHASE_WAIT_FOR_READ_ONLY; in handle_load_error()
2310 vdo_enter_read_only_mode(vdo, completion->result); in handle_load_error()
2311 completion->result = VDO_READ_ONLY; in handle_load_error()
2316 * write_super_block_for_resume() - Update the VDO state and save the super block.
2319 static void write_super_block_for_resume(struct vdo_completion *completion) in write_super_block_for_resume()
2321 struct vdo *vdo = completion->vdo; in write_super_block_for_resume()
2346 * resume_callback() - Callback to resume a VDO.
2349 static void resume_callback(struct vdo_completion *completion) in resume_callback()
2351 struct vdo *vdo = completion->vdo; in resume_callback()
2358 result = vdo_start_operation(&vdo->admin.state, in resume_callback()
2373 vdo_resume_hash_zones(vdo->hash_zones, completion); in resume_callback()
2377 vdo_resume_slab_depot(vdo->depot, completion); in resume_callback()
2381 vdo_resume_recovery_journal(vdo->recovery_journal, completion); in resume_callback()
2385 vdo_resume_block_map(vdo->block_map, completion); in resume_callback()
2389 vdo_resume_logical_zones(vdo->logical_zones, completion); in resume_callback()
2395 bool enable = vdo->device_config->compression; in resume_callback()
2398 WRITE_ONCE(vdo->compressing, enable); in resume_callback()
2401 vdo_resume_packer(vdo->packer, completion); in resume_callback()
2406 vdo_resume_flusher(vdo->flusher, completion); in resume_callback()
2410 resume_data_vio_pool(vdo->data_vio_pool, completion); in resume_callback()
2424 * grow_logical_callback() - Callback to initiate a grow logical.
2429 static void grow_logical_callback(struct vdo_completion *completion) in grow_logical_callback()
2431 struct vdo *vdo = completion->vdo; in grow_logical_callback()
2440 "Can't grow logical size of a read-only VDO"); in grow_logical_callback()
2445 result = vdo_start_operation(&vdo->admin.state, in grow_logical_callback()
2452 vdo->states.vdo.config.logical_blocks = vdo->block_map->next_entry_count; in grow_logical_callback()
2457 vdo_grow_block_map(vdo->block_map, completion); in grow_logical_callback()
2464 vdo_enter_read_only_mode(vdo, completion->result); in grow_logical_callback()
2475 * handle_logical_growth_error() - Handle an error during the grow physical process.
2478 static void handle_logical_growth_error(struct vdo_completion *completion) in handle_logical_growth_error()
2480 struct vdo *vdo = completion->vdo; in handle_logical_growth_error()
2482 if (vdo->admin.phase == GROW_LOGICAL_PHASE_GROW_BLOCK_MAP) { in handle_logical_growth_error()
2485 * config back to the old size. in handle_logical_growth_error()
2487 vdo->states.vdo.config.logical_blocks = vdo->block_map->entry_count; in handle_logical_growth_error()
2488 vdo_abandon_block_map_growth(vdo->block_map); in handle_logical_growth_error()
2491 vdo->admin.phase = GROW_LOGICAL_PHASE_ERROR; in handle_logical_growth_error()
2496 * perform_grow_logical() - Grow the logical size of the vdo.
2505 static int perform_grow_logical(struct vdo *vdo, block_count_t new_logical_blocks) in perform_grow_logical()
2509 if (vdo->device_config->logical_blocks == new_logical_blocks) { in perform_grow_logical()
2514 vdo_abandon_block_map_growth(vdo->block_map); in perform_grow_logical()
2520 if (vdo->block_map->next_entry_count != new_logical_blocks) in perform_grow_logical()
2533 static void copy_callback(int read_err, unsigned long write_err, void *context) in copy_callback()
2536 int result = (((read_err == 0) && (write_err == 0)) ? VDO_SUCCESS : -EIO); in copy_callback()
2541 static void partition_to_region(struct partition *partition, struct vdo *vdo, in partition_to_region()
2544 physical_block_number_t pbn = partition->offset - vdo->geometry.bio_offset; in partition_to_region()
2549 .count = partition->count * VDO_SECTORS_PER_BLOCK, in partition_to_region()
2554 * copy_partition() - Copy a partition from the location specified in the current layout to that in
2560 static void copy_partition(struct vdo *vdo, enum partition_id id, in copy_partition()
2564 struct partition *from = vdo_get_known_partition(&vdo->layout, id); in copy_partition()
2565 struct partition *to = vdo_get_known_partition(&vdo->next_layout, id); in copy_partition()
2569 dm_kcopyd_copy(vdo->partition_copier, &read_region, 1, write_regions, 0, in copy_partition()
2574 * grow_physical_callback() - Callback to initiate a grow physical.
2579 static void grow_physical_callback(struct vdo_completion *completion) in grow_physical_callback()
2581 struct vdo *vdo = completion->vdo; in grow_physical_callback()
2590 "Can't grow physical size of a read-only VDO"); in grow_physical_callback()
2595 result = vdo_start_operation(&vdo->admin.state, in grow_physical_callback()
2611 vdo_uninitialize_layout(&vdo->layout); in grow_physical_callback()
2612 vdo->layout = vdo->next_layout; in grow_physical_callback()
2613 vdo_forget(vdo->next_layout.head); in grow_physical_callback()
2614 vdo->states.vdo.config.physical_blocks = vdo->layout.size; in grow_physical_callback()
2615 vdo_update_slab_depot_size(vdo->depot); in grow_physical_callback()
2620 vdo_use_new_slabs(vdo->depot, completion); in grow_physical_callback()
2624 vdo->depot->summary_origin = in grow_physical_callback()
2625 vdo_get_known_partition(&vdo->layout, in grow_physical_callback()
2626 VDO_SLAB_SUMMARY_PARTITION)->offset; in grow_physical_callback()
2627 vdo->recovery_journal->origin = in grow_physical_callback()
2628 vdo_get_known_partition(&vdo->layout, in grow_physical_callback()
2629 VDO_RECOVERY_JOURNAL_PARTITION)->offset; in grow_physical_callback()
2633 vdo_enter_read_only_mode(vdo, completion->result); in grow_physical_callback()
2640 vdo_uninitialize_layout(&vdo->next_layout); in grow_physical_callback()
2645 * handle_physical_growth_error() - Handle an error during the grow physical process.
2646 * @completion: The sub-task completion.
2648 static void handle_physical_growth_error(struct vdo_completion *completion) in handle_physical_growth_error()
2650 completion->vdo->admin.phase = GROW_PHYSICAL_PHASE_ERROR; in handle_physical_growth_error()
2655 * perform_grow_physical() - Grow the physical size of the vdo.
2664 static int perform_grow_physical(struct vdo *vdo, block_count_t new_physical_blocks) in perform_grow_physical()
2668 block_count_t old_physical_blocks = vdo->states.vdo.config.physical_blocks; in perform_grow_physical()
2674 if (new_physical_blocks != vdo->next_layout.size) { in perform_grow_physical()
2680 vdo_uninitialize_layout(&vdo->next_layout); in perform_grow_physical()
2681 vdo_abandon_new_slabs(vdo->depot); in perform_grow_physical()
2687 vdo_get_known_partition(&vdo->next_layout, VDO_SLAB_DEPOT_PARTITION)->count; in perform_grow_physical()
2688 prepared_depot_size = (vdo->depot->new_slabs == NULL) ? 0 : vdo->depot->new_size; in perform_grow_physical()
2705 * apply_new_vdo_configuration() - Attempt to make any configuration changes from the table being
2708 * @config: The new device configuration derived from the table with which the vdo is being
2713 static int __must_check apply_new_vdo_configuration(struct vdo *vdo, in apply_new_vdo_configuration()
2714 struct device_config *config) in apply_new_vdo_configuration() argument
2718 result = perform_grow_logical(vdo, config->logical_blocks); in apply_new_vdo_configuration()
2724 result = perform_grow_physical(vdo, config->physical_blocks); in apply_new_vdo_configuration()
2731 static int vdo_preresume_registered(struct dm_target *ti, struct vdo *vdo) in vdo_preresume_registered()
2733 struct device_config *config = ti->private; in vdo_preresume_registered() local
2739 if (backing_blocks < config->physical_blocks) { in vdo_preresume_registered()
2743 (unsigned long long) config->physical_blocks); in vdo_preresume_registered()
2744 return -EINVAL; in vdo_preresume_registered()
2757 vdo->suspend_type = VDO_ADMIN_STATE_SUSPENDING; in vdo_preresume_registered()
2771 vdo->suspend_type = VDO_ADMIN_STATE_STOPPING; in vdo_preresume_registered()
2778 /* Even if the VDO is read-only, it is now able to handle read requests. */ in vdo_preresume_registered()
2785 result = apply_new_vdo_configuration(vdo, config); in vdo_preresume_registered()
2789 * Now that we've tried to modify the vdo, the new config *is* the config, whether the in vdo_preresume_registered()
2792 vdo->device_config = config; in vdo_preresume_registered()
2796 * it read-only in memory. Because we are suspended, the read-only state will not be in vdo_preresume_registered()
2807 if (vdo_get_admin_state(vdo)->normal) { in vdo_preresume_registered()
2816 /* Even if the vdo is read-only, it has still resumed. */ in vdo_preresume_registered()
2827 static int vdo_preresume(struct dm_target *ti) in vdo_preresume()
2833 vdo_register_thread_device_id(&instance_thread, &vdo->instance); in vdo_preresume()
2837 result = -EINVAL; in vdo_preresume()
2842 static void vdo_resume(struct dm_target *ti) in vdo_resume()
2847 &get_vdo_for_target(ti)->instance); in vdo_resume()
2857 static struct target_type vdo_target_bio = {
2875 static bool dm_registered;
2877 static void vdo_module_destroy(void) in vdo_module_destroy()
2891 static int __init vdo_init(void) in vdo_init()
2920 static void __exit vdo_exit(void) in vdo_exit()