master - cache: runtime detect default policy
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=feb8e9a7907c91bd55769b4e3ae625434f2ba589 Commit: feb8e9a7907c91bd55769b4e3ae625434f2ba589 Parent: 8a74d1ec79d209aa8bce51821836179afe7d48f9 Author: Zdenek Kabelac <[email protected]> AuthorDate: Sun Jul 26 23:05:11 2015 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Aug 12 14:11:17 2015 +0200
cache: runtime detect default policy
When the policy is not preset in lvm.conf,
detect in runtime whether to use 'mq' or
new available 'smq'.
--- WHATS_NEW | 1 + lib/config/config.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.128 - =================================== + Runtime detect presence of cache smq policy. Add demo cache-mq and cache-smq profiles. Add cmd profilable allocation/cache_policy,cache_settings,cache_mode. Require cache_check 0.5.4 for use of --clear-needs-check-flag.
lib/config/config.c +21 -1
@@ -23,6 +23,7 @@#include "toolcontext.h" #include "lvm-file.h" #include "memlock.h" +#include "segtype.h" #include <sys/stat.h> #include <sys/mman.h>
@@ -2418,5 +2419,24 @@ int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, stconst char *get_default_allocation_cache_policy_CFG (struct cmd_context *cmd,struct profile *profile) { -return DEFAULT_CACHE_POLICY ; +const struct segment_type *segtype =get_segtype_from_string (cmd,"cache" ); +unsigned attr = ~0 ; + +if (!segtype || + !segtype->ops->target_present || + !segtype->ops->target_present (cmd,NULL , &attr)) { +log_warn ("WARNING: Cannot detect default cache policy, using \"" +DEFAULT_CACHE_POLICY "\"." ); +return DEFAULT_CACHE_POLICY ; + } + +if (attr &CACHE_FEATURE_POLICY_SMQ ) +return "smq" ; + +if (attr &CACHE_FEATURE_POLICY_MQ ) +return "mq" ; + +log_warn ("WARNING: Default cache policy not available." ); + +return NULL ; }