diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2018-06-29 11:08:51 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2018-07-09 15:28:35 +0200 |
commit | d8a41f22e9a68b0424ee18b1859fb6369c712622 (patch) | |
tree | e84b331da64e0a4497c8d0982bef7046e335171d /device_mapper/vdo | |
parent | 0d9a4c69896137f1b440ec6da187387f6394d1fb (diff) | |
download | lvm2-d8a41f22e9a68b0424ee18b1859fb6369c712622.tar.gz |
device_mapper: basic support for vdo dm target
Diffstat (limited to 'device_mapper/vdo')
-rw-r--r-- | device_mapper/vdo/target.h | 40 | ||||
-rw-r--r-- | device_mapper/vdo/vdo_target.c | 121 |
2 files changed, 161 insertions, 0 deletions
diff --git a/device_mapper/vdo/target.h b/device_mapper/vdo/target.h index 3d8722b3a..c597491ed 100644 --- a/device_mapper/vdo/target.h +++ b/device_mapper/vdo/target.h @@ -66,6 +66,46 @@ struct dm_pool; bool dm_vdo_status_parse(struct dm_pool *mem, const char *input, struct dm_vdo_status_parse_result *result); +enum dm_vdo_write_policy { + DM_VDO_WRITE_POLICY_AUTO = 0, + DM_VDO_WRITE_POLICY_SYNC, + DM_VDO_WRITE_POLICY_ASYNC +}; + +// FIXME: review whether we should use the createParams from the userlib +struct dm_vdo_target_params { + uint32_t block_map_cache_size_mb; + uint32_t block_map_period; + + uint32_t check_point_frequency; + uint32_t index_memory_size_mb; + + uint32_t read_cache_size_mb; + + uint32_t slab_size_mb; + + // threads + uint32_t ack_threads; + uint32_t bio_threads; + uint32_t bio_rotation; + uint32_t cpu_threads; + uint32_t hash_zone_threads; + uint32_t logical_threads; + uint32_t physical_threads; + + bool use_compression; + bool use_deduplication; + bool emulate_512_sectors; + bool use_sparse_index; + bool use_read_cache; + + // write policy + enum dm_vdo_write_policy write_policy; +}; + +bool dm_vdo_validate_target_params(const struct dm_vdo_target_params *vtp, + uint64_t vdo_size); + //---------------------------------------------------------------- #endif diff --git a/device_mapper/vdo/vdo_target.c b/device_mapper/vdo/vdo_target.c new file mode 100644 index 000000000..c488023b5 --- /dev/null +++ b/device_mapper/vdo/vdo_target.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2018 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "device_mapper/misc/dmlib.h" +#include "device_mapper/all.h" + +#include "vdo_limits.h" +#include "target.h" + +bool dm_vdo_validate_target_params(const struct dm_vdo_target_params *vtp, + uint64_t vdo_size) +{ + bool valid = true; + + if ((vtp->block_map_cache_size_mb < DM_VDO_BLOCK_MAP_CACHE_SIZE_MINIMUM_MB) || + (vtp->block_map_cache_size_mb > DM_VDO_BLOCK_MAP_CACHE_SIZE_MAXIMUM_MB)) { + log_error("VDO block map cache size %u out of range.", + vtp->block_map_cache_size_mb); + valid = false; + } + + if ((vtp->index_memory_size_mb < DM_VDO_INDEX_MEMORY_SIZE_MINIMUM_MB) || + (vtp->index_memory_size_mb > DM_VDO_INDEX_MEMORY_SIZE_MAXIMUM_MB)) { + log_error("VDO index memory size %u out of range.", + vtp->index_memory_size_mb); + valid = false; + } + + if (vtp->read_cache_size_mb > DM_VDO_READ_CACHE_SIZE_MAXIMUM_MB) { + log_error("VDO read cache size %u out of range.", + vtp->read_cache_size_mb); + valid = false; + } + + if ((vtp->slab_size_mb < DM_VDO_SLAB_SIZE_MINIMUM_MB) || + (vtp->slab_size_mb > DM_VDO_SLAB_SIZE_MAXIMUM_MB)) { + log_error("VDO slab size %u out of range.", + vtp->slab_size_mb); + valid = false; + } + + if (vtp->ack_threads > DM_VDO_ACK_THREADS_MAXIMUM) { + log_error("VDO ack threads %u out of range.", vtp->ack_threads); + valid = false; + } + + if ((vtp->bio_threads < DM_VDO_BIO_THREADS_MINIMUM) || + (vtp->bio_threads > DM_VDO_BIO_THREADS_MAXIMUM)) { + log_error("VDO bio threads %u out of range.", vtp->bio_threads); + valid = false; + } + + if ((vtp->bio_rotation < DM_VDO_BIO_ROTATION_MINIMUM) || + (vtp->bio_rotation > DM_VDO_BIO_ROTATION_MAXIMUM)) { + log_error("VDO bio rotation %u out of range.", vtp->bio_rotation); + valid = false; + } + + if ((vtp->cpu_threads < DM_VDO_CPU_THREADS_MINIMUM) || + (vtp->cpu_threads > DM_VDO_CPU_THREADS_MAXIMUM)) { + log_error("VDO cpu threads %u out of range.", vtp->cpu_threads); + valid = false; + } + + if (vtp->hash_zone_threads > DM_VDO_HASH_ZONE_THREADS_MAXIMUM) { + log_error("VDO hash zone threads %u out of range.", vtp->hash_zone_threads); + valid = false; + } + + if (vtp->logical_threads > DM_VDO_LOGICAL_THREADS_MAXIMUM) { + log_error("VDO logical threads %u out of range.", vtp->logical_threads); + valid = false; + } + + if (vtp->physical_threads > DM_VDO_PHYSICAL_THREADS_MAXIMUM) { + log_error("VDO physical threads %u out of range.", vtp->physical_threads); + valid = false; + } + + switch (vtp->write_policy) { + case DM_VDO_WRITE_POLICY_SYNC: + case DM_VDO_WRITE_POLICY_ASYNC: + case DM_VDO_WRITE_POLICY_AUTO: + break; + default: + log_error(INTERNAL_ERROR "VDO write policy %u is unknown.", vtp->write_policy); + valid = false; + } + + if ((vtp->hash_zone_threads || + vtp->logical_threads || + vtp->physical_threads) && + (!vtp->hash_zone_threads || + !vtp->logical_threads || + !vtp->physical_threads)) { + log_error("Value of vdo_hash_zone_threads(%u), vdo_logical_threads(%u), " + "vdo_physical_threads(%u) must be all zero or all non-zero.", + vtp->hash_zone_threads, vtp->logical_threads, vtp->physical_threads); + valid = false; + } + + if (vdo_size >= (DM_VDO_LOGICAL_SIZE_MAXIMUM_MB * UINT64_C(1024 * 2))) { + log_error("VDO logical size is by " FMTu64 "KiB bigger then limit " FMTu64 "TiB.", + (vdo_size - (DM_VDO_LOGICAL_SIZE_MAXIMUM_MB * UINT64_C(1024 * 2))) / 2, + DM_VDO_LOGICAL_SIZE_MAXIMUM_MB / UINT64_C(1024) / UINT64_C(1024)); + valid = false; + } + + return valid; +} |