1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cache: introduce allocation/cache_metadata_format

Add new profilable configation setting to let user select
which metadata format of a created cache pool he wish to use.

By default the 'best' available format is autodetected at runtime,
but user may enforce format 1 or 2 ATM.

Code also detects availability for metadata2 supporting cache target.

In case of troubles user may easily Disable usage of this feature
by placing 'metadata2' into global/cache_disabled_features list.
This commit is contained in:
Zdenek Kabelac 2017-02-26 20:19:07 +01:00
parent bb20fac4ab
commit 4a394f410d
7 changed files with 48 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.169 - Version 2.02.169 -
===================================== =====================================
Add allocation/cache_metadata_format profilable setttings.
Use function cache_set_params() for both lvcreate and lvconvert. Use function cache_set_params() for both lvcreate and lvconvert.
Skip rounding on cache chunk size boudary when create cache LV. Skip rounding on cache chunk size boudary when create cache LV.
Improve cache_set_params support for chunk_size selection. Improve cache_set_params support for chunk_size selection.

View File

@ -403,9 +403,20 @@ allocation {
# This configuration option has an automatic default value. # This configuration option has an automatic default value.
# cache_mode = "writethrough" # cache_mode = "writethrough"
# Configuration option allocation/cache_metadata_format.
# Sets default metadata format for new cache.
#
# Accepted values:
# 0 Automatically detected best available format
# 1 Original format
# 2 Improved 2nd. generation format
#
# This configuration option has an automatic default value.
# cache_metadata_format = 0
# Configuration option allocation/cache_policy. # Configuration option allocation/cache_policy.
# The default cache policy used for new cache volume. # The default cache policy used for new cache volume.
# Since kernel 4.2 the default policy is smq (Stochastic multique), # Since kernel 4.2 the default policy is smq (Stochastic multiqueue),
# otherwise the older mq (Multiqueue) policy is selected. # otherwise the older mq (Multiqueue) policy is selected.
# This configuration option does not have a default value defined. # This configuration option does not have a default value defined.
@ -1013,7 +1024,7 @@ global {
# Configuration option global/cache_disabled_features. # Configuration option global/cache_disabled_features.
# Features to not use in the cache driver. # Features to not use in the cache driver.
# This can be helpful for testing, or to avoid using a feature that is # This can be helpful for testing, or to avoid using a feature that is
# causing problems. Features include: policy_mq, policy_smq. # causing problems. Features include: policy_mq, policy_smq, metadata2.
# #
# Example # Example
# cache_disabled_features = [ "policy_smq" ] # cache_disabled_features = [ "policy_smq" ]
@ -1277,8 +1288,9 @@ activation {
# Configuration option activation/raid_region_size. # Configuration option activation/raid_region_size.
# Size in KiB of each raid or mirror synchronization region. # Size in KiB of each raid or mirror synchronization region.
# For raid or mirror segment types, this is the amount of data that is # The clean/dirty state of data is tracked for each region.
# copied at once when initializing, or moved at once by pvmove. # The value is rounded down to a power of two if necessary, and
# is ignored if it is not a multiple of the machine memory page size.
raid_region_size = 512 raid_region_size = 512
# Configuration option activation/error_when_full. # Configuration option activation/error_when_full.

View File

@ -213,6 +213,7 @@ static int _target_present(struct cmd_context *cmd,
const char *aliasing; const char *aliasing;
} _features[] = { } _features[] = {
/* Assumption: cache >=1.9 always aliases MQ policy */ /* Assumption: cache >=1.9 always aliases MQ policy */
{ 1, 10, CACHE_FEATURE_METADATA2, 0, "metadata2" },
{ 1, 9, CACHE_FEATURE_POLICY_SMQ, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq", { 1, 9, CACHE_FEATURE_POLICY_SMQ, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq",
" and aliases cache-mq" }, " and aliases cache-mq" },
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq" }, { 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq" },
@ -250,6 +251,16 @@ static int _target_present(struct cmd_context *cmd,
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) { for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) {
if (_attrs & _features[i].cache_feature) if (_attrs & _features[i].cache_feature)
continue; /* already present */ continue; /* already present */
if (!_features[i].module[0]) {
if ((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) {
log_debug_activation("Cache supports %s.",
_features[i].feature);
_attrs |= _features[i].cache_feature;
}
continue;
}
if (((maj > _features[i].maj) || if (((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) && (maj == _features[i].maj && min >= _features[i].min)) &&
module_present(cmd, _features[i].module)) { module_present(cmd, _features[i].module)) {

View File

@ -480,6 +480,15 @@ cfg(allocation_cache_pool_cachemode_CFG, "cache_pool_cachemode", allocation_CFG_
"This has been replaced by the allocation/cache_mode setting.\n", "This has been replaced by the allocation/cache_mode setting.\n",
"Cache mode.\n") "Cache mode.\n")
cfg(allocation_cache_metadata_format_CFG, "cache_metadata_format", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_CACHE_METADATA_FORMAT, vsn(2, 2, 169), NULL, 0, NULL,
"Sets default metadata format for new cache.\n"
"#\n"
"Accepted values:\n"
" 0 Automatically detected best available format\n"
" 1 Original format\n"
" 2 Improved 2nd. generation format\n"
"#\n")
cfg(allocation_cache_mode_CFG, "cache_mode", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_MODE, vsn(2, 2, 128), NULL, 0, NULL, cfg(allocation_cache_mode_CFG, "cache_mode", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_MODE, vsn(2, 2, 128), NULL, 0, NULL,
"The default cache mode used for new cache.\n" "The default cache mode used for new cache.\n"
"#\n" "#\n"
@ -494,7 +503,7 @@ cfg(allocation_cache_mode_CFG, "cache_mode", allocation_CFG_SECTION, CFG_PROFILA
cfg(allocation_cache_policy_CFG, "cache_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, 0, vsn(2, 2, 128), NULL, 0, NULL, cfg(allocation_cache_policy_CFG, "cache_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, 0, vsn(2, 2, 128), NULL, 0, NULL,
"The default cache policy used for new cache volume.\n" "The default cache policy used for new cache volume.\n"
"Since kernel 4.2 the default policy is smq (Stochastic multique),\n" "Since kernel 4.2 the default policy is smq (Stochastic multiqueue),\n"
"otherwise the older mq (Multiqueue) policy is selected.\n") "otherwise the older mq (Multiqueue) policy is selected.\n")
cfg_section(allocation_cache_settings_CFG_SECTION, "cache_settings", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, vsn(2, 2, 128), 0, NULL, cfg_section(allocation_cache_settings_CFG_SECTION, "cache_settings", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, vsn(2, 2, 128), 0, NULL,
@ -992,7 +1001,7 @@ cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CF
cfg_array(global_cache_disabled_features_CFG, "cache_disabled_features", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 128), NULL, 0, NULL, cfg_array(global_cache_disabled_features_CFG, "cache_disabled_features", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 128), NULL, 0, NULL,
"Features to not use in the cache driver.\n" "Features to not use in the cache driver.\n"
"This can be helpful for testing, or to avoid using a feature that is\n" "This can be helpful for testing, or to avoid using a feature that is\n"
"causing problems. Features include: policy_mq, policy_smq.\n" "causing problems. Features include: policy_mq, policy_smq, metadata2.\n"
"#\n" "#\n"
"Example\n" "Example\n"
"cache_disabled_features = [ \"policy_smq\" ]\n" "cache_disabled_features = [ \"policy_smq\" ]\n"

View File

@ -132,6 +132,7 @@
#define DEFAULT_CACHE_POOL_MIN_METADATA_SIZE 2048 /* KB */ #define DEFAULT_CACHE_POOL_MIN_METADATA_SIZE 2048 /* KB */
#define DEFAULT_CACHE_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */ #define DEFAULT_CACHE_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */
#define DEFAULT_CACHE_POLICY "mq" #define DEFAULT_CACHE_POLICY "mq"
#define DEFAULT_CACHE_METADATA_FORMAT CACHE_METADATA_FORMAT_UNSELECTED /* Autodetect */
#define DEFAULT_CACHE_MODE "writethrough" #define DEFAULT_CACHE_MODE "writethrough"
#define DEFAULT_UMASK 0077 #define DEFAULT_UMASK 0077

View File

@ -294,6 +294,13 @@ typedef enum {
CACHE_MODE_PASSTHROUGH, CACHE_MODE_PASSTHROUGH,
} cache_mode_t; } cache_mode_t;
/* ATM used for cache only */
typedef enum {
CACHE_METADATA_FORMAT_UNSELECTED = 0, /* On input means 'auto' */
CACHE_METADATA_FORMAT_1,
CACHE_METADATA_FORMAT_2,
} cache_metadata_format_t;
typedef enum { typedef enum {
LOCK_TYPE_INVALID = -1, LOCK_TYPE_INVALID = -1,
LOCK_TYPE_NONE = 0, LOCK_TYPE_NONE = 0,

View File

@ -315,6 +315,7 @@ int init_cache_segtypes(struct cmd_context *cmd, struct segtype_library *seglib)
#define CACHE_FEATURE_POLICY_MQ (1U << 0) #define CACHE_FEATURE_POLICY_MQ (1U << 0)
#define CACHE_FEATURE_POLICY_SMQ (1U << 1) #define CACHE_FEATURE_POLICY_SMQ (1U << 1)
#define CACHE_FEATURE_METADATA2 (1U << 2)
#define SNAPSHOT_FEATURE_FIXED_LEAK (1U << 0) /* version 1.12 */ #define SNAPSHOT_FEATURE_FIXED_LEAK (1U << 0) /* version 1.12 */