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

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'.
This commit is contained in:
Zdenek Kabelac 2015-07-26 23:05:11 +02:00
parent 8a74d1ec79
commit feb8e9a790
2 changed files with 22 additions and 1 deletions

View File

@ -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.

View File

@ -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, st
const 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;
}