2018-04-30 18:16:58 +03:00
/*
* Copyright ( C ) 2018 Red Hat , Inc . All rights reserved .
*
* This file is part of the device - mapper userspace tools .
*
* 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
*/
# ifndef DEVICE_MAPPER_VDO_TARGET_H
# define DEVICE_MAPPER_VDO_TARGET_H
# include <stdbool.h>
# include <stdint.h>
//----------------------------------------------------------------
2018-07-09 11:04:51 +03:00
enum dm_vdo_operating_mode {
DM_VDO_MODE_RECOVERING ,
DM_VDO_MODE_READ_ONLY ,
DM_VDO_MODE_NORMAL
2018-04-30 18:16:58 +03:00
} ;
2018-07-09 11:04:51 +03:00
enum dm_vdo_compression_state {
DM_VDO_COMPRESSION_ONLINE ,
DM_VDO_COMPRESSION_OFFLINE
2018-04-30 18:16:58 +03:00
} ;
2018-07-09 11:04:51 +03:00
enum dm_vdo_index_state {
DM_VDO_INDEX_ERROR ,
DM_VDO_INDEX_CLOSED ,
DM_VDO_INDEX_OPENING ,
DM_VDO_INDEX_CLOSING ,
DM_VDO_INDEX_OFFLINE ,
DM_VDO_INDEX_ONLINE ,
DM_VDO_INDEX_UNKNOWN
2018-04-30 18:16:58 +03:00
} ;
2018-07-09 11:04:51 +03:00
struct dm_vdo_status {
2018-05-02 13:15:35 +03:00
char * device ;
2018-07-09 11:04:51 +03:00
enum dm_vdo_operating_mode operating_mode ;
2018-04-30 18:16:58 +03:00
bool recovering ;
2018-07-09 11:04:51 +03:00
enum dm_vdo_index_state index_state ;
enum dm_vdo_compression_state compression_state ;
2018-04-30 18:16:58 +03:00
uint64_t used_blocks ;
uint64_t total_blocks ;
} ;
2018-07-09 11:04:51 +03:00
void dm_vdo_status_destroy ( struct dm_vdo_status * s ) ;
2018-04-30 18:16:58 +03:00
# define VDO_MAX_ERROR 256
2018-07-09 11:04:51 +03:00
struct dm_vdo_status_parse_result {
2018-04-30 18:16:58 +03:00
char error [ VDO_MAX_ERROR ] ;
2018-07-09 11:04:51 +03:00
struct dm_vdo_status * status ;
2018-04-30 18:16:58 +03:00
} ;
2018-06-27 17:18:53 +03:00
struct dm_pool ;
2018-04-30 18:16:58 +03:00
// Parses the status line from the kernel target.
2018-07-09 11:04:51 +03:00
bool dm_vdo_status_parse ( struct dm_pool * mem , const char * input ,
struct dm_vdo_status_parse_result * result ) ;
2018-04-30 18:16:58 +03:00
2018-06-29 12:08:51 +03:00
enum dm_vdo_write_policy {
DM_VDO_WRITE_POLICY_AUTO = 0 ,
DM_VDO_WRITE_POLICY_SYNC ,
2021-09-06 14:56:40 +03:00
DM_VDO_WRITE_POLICY_ASYNC ,
DM_VDO_WRITE_POLICY_ASYNC_UNSAFE
2018-06-29 12:08:51 +03:00
} ;
// FIXME: review whether we should use the createParams from the userlib
struct dm_vdo_target_params {
2019-10-04 15:58:18 +03:00
uint32_t minimum_io_size ; // in sectors
2018-06-29 12:08:51 +03:00
uint32_t block_map_cache_size_mb ;
2022-04-13 16:09:08 +03:00
union {
uint32_t block_map_era_length ; // format period
uint32_t block_map_period ; // supported alias
} ;
2018-06-29 12:08:51 +03:00
uint32_t check_point_frequency ;
2018-12-20 15:17:30 +03:00
uint32_t index_memory_size_mb ; // format
2018-06-29 12:08:51 +03:00
2018-12-20 15:17:30 +03:00
uint32_t slab_size_mb ; // format
2018-06-29 12:08:51 +03:00
2018-12-20 15:17:30 +03:00
uint32_t max_discard ;
2018-06-29 12:08:51 +03:00
// 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 ;
2018-12-20 15:17:30 +03:00
bool use_metadata_hints ;
bool use_sparse_index ; // format
2018-06-29 12:08:51 +03:00
// 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 ) ;
2022-10-26 15:33:09 +03:00
bool dm_vdo_parse_logical_size ( const char * vdo_path , uint64_t * logical_blocks ) ;
2018-04-30 18:16:58 +03:00
//----------------------------------------------------------------
# endif