dev-prajnoha-pv-ext-flag-used - toollib: get_cache_params
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=969ee25a74b50c...
Commit: 969ee25a74b50c42f9a2626b7b8991a3d60f750f
Parent: 6cde12a013f006c1b27b878593fe0f1e73a5f79a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 23 15:35:12 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:18 2015 +0200
toollib: get_cache_params
Enhance get_cache_params() to read common cache args.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 2 +-
tools/lvchange.c | 2 +-
tools/lvconvert.c | 31 +++++++++----------------------
tools/lvcreate.c | 19 +++++--------------
tools/toollib.c | 18 +++++++++++++++---
tools/toollib.h | 7 ++++---
7 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index da0ef4d..7c35d13 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Enhance toollib's get_cache_params().
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.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7c1752a..03a866a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -901,7 +901,7 @@ struct lvcreate_params {
uint32_t min_recovery_rate; /* RAID */
uint32_t max_recovery_rate; /* RAID */
- uint64_t feature_flags; /* cache */
+ const char *cache_mode; /* cache */
const char *policy_name; /* cache */
struct dm_config_tree *policy_settings; /* cache */
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 22a407a..a6ad343 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -690,7 +690,7 @@ static int _lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume
goto out;
}
- if (!get_cache_policy_params(cmd, &name, &settings))
+ if (!get_cache_params(cmd, NULL, &name, &settings))
goto_out;
if (!lv_cache_set_policy(lv, name, settings))
goto_out;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3a7f9ae..d48af62 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -50,7 +50,7 @@ struct lvconvert_params {
uint32_t stripes;
uint32_t stripe_size;
uint32_t read_ahead;
- uint64_t feature_flags; /* cache_pool */
+ const char *cache_mode; /* cache */
const char *policy_name; /* cache */
struct dm_config_tree *policy_settings; /* cache */
@@ -299,26 +299,14 @@ static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv,
} else if (!strcmp(type_str, "thin-pool"))
thinpool = 1;
- if (cachepool) {
- const char *cachemode = arg_str_value(cmd, cachemode_ARG, NULL);
- if (!cachemode)
- cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
-
- if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
- return_0;
-
- if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
- log_error("Failed to parse cache policy and/or settings.");
- return 0;
- }
- } else {
- if (arg_from_list_is_set(cmd, "is valid only with cache pools",
- cachepool_ARG, cachemode_ARG, -1))
- return_0;
- if (lp->cache) {
- log_error("--cache requires --cachepool.");
- return 0;
- }
+ if (lp->cache && !cachepool) {
+ log_error("--cache requires --cachepool.");
+ return 0;
+ }
+ if ((lp->cache || cachepool) &&
+ !get_cache_params(cmd, &lp->cache_mode, &lp->policy_name, &lp->policy_settings)) {
+ log_error("Failed to parse cache policy and/or settings.");
+ return 0;
}
if (thinpool) {
@@ -3080,7 +3068,6 @@ mda_write:
seg->chunk_size = lp->chunk_size;
seg->discards = lp->discards;
seg->zero_new_blocks = lp->zero ? 1 : 0;
- seg->feature_flags = lp->feature_flags; /* cache-pool */
if ((lp->policy_name || lp->policy_settings) &&
!lv_cache_set_policy(seg->lv, lp->policy_name, lp->policy_settings))
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 12b5166..cc4ef20 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -567,21 +567,14 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
static int _read_cache_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- const char *cachemode;
-
if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
return 1;
- if (!(cachemode = arg_str_value(cmd, cachemode_ARG, NULL)))
- cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
-
- if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
- return_0;
-
- if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
- log_error("Failed to parse cache policy and/or settings.");
- return 0;
- }
+ if (!get_cache_params(cmd,
+ &lp->cache_mode,
+ &lp->policy_name,
+ &lp->policy_settings))
+ return_NULL;
return 1;
}
@@ -1089,8 +1082,6 @@ static int _determine_cache_argument(struct volume_group *vg,
/* If cache args not given, use those from cache pool */
if (!arg_is_set(cmd, chunksize_ARG))
lp->chunk_size = first_seg(lv)->chunk_size;
- if (!arg_is_set(cmd, cachemode_ARG))
- lp->feature_flags = first_seg(lv)->feature_flags;
} else if (lv) {
/* Origin exists, create cache pool volume */
if (!validate_lv_cache_create_origin(lv))
diff --git a/tools/toollib.c b/tools/toollib.c
index 0d401e4..fde6c36 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1399,8 +1399,10 @@ static int _validate_cachepool_params(const char *name,
return 1;
}
-int get_cache_policy_params(struct cmd_context *cmd, const char **name,
- struct dm_config_tree **settings)
+int get_cache_params(struct cmd_context *cmd,
+ const char **mode,
+ const char **name,
+ struct dm_config_tree **settings)
{
const char *str;
struct arg_value_group_list *group;
@@ -1408,7 +1410,14 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
struct dm_config_node *cn;
int ok = 0;
- *name = arg_str_value(cmd, cachepolicy_ARG, DEFAULT_CACHE_POLICY);
+ if (mode)
+ *mode = arg_str_value(cmd, cachemode_ARG, NULL);
+
+ if (name)
+ *name = arg_str_value(cmd, cachepolicy_ARG, NULL);
+
+ if (!settings)
+ return 1;
dm_list_iterate_items(group, &cmd->arg_value_groups) {
if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
@@ -1429,6 +1438,9 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
goto_out;
}
+ if (!current)
+ return 1;
+
if (!(result = dm_config_flatten(current)))
goto_out;
diff --git a/tools/toollib.h b/tools/toollib.h
index c57cb84..2dc5ad7 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -190,9 +190,10 @@ int get_pool_params(struct cmd_context *cmd,
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);
-int get_cache_policy_params(struct cmd_context *cmd,
- const char **name,
- struct dm_config_tree **settings);
+int get_cache_params(struct cmd_context *cmd,
+ const char **mode,
+ const char **name,
+ struct dm_config_tree **settings);
int change_tag(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv, struct physical_volume *pv, int arg);
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - cache: man updates
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6cde12a013f006...
Commit: 6cde12a013f006c1b27b878593fe0f1e73a5f79a
Parent: feb8e9a7907c91bd55769b4e3ae625434f2ba589
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 20 11:55:43 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:17 2015 +0200
cache: man updates
Better man for cachepolicy and cachesettings.
---
man/lvconvert.8.in | 17 ++++++++++++++++-
man/lvcreate.8.in | 24 +++++++++++++++---------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 576859b..562de1e 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -162,6 +162,10 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-cachemode
.RI { writeback | writethrough }]
+.RB [ \-\-cachepolicy
+.IR policy ]
+.RB [ \-\-cachesettings
+.IR key=value ]
.RB [ \-\-poolmetadata
.IR CachePoolMetadataLogicalVolume { Name | Path }
|
@@ -222,10 +226,21 @@ Converts logical volume to a cached LV with the use of cache pool
specified with \fB\-\-cachepool\fP.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
.TP
+.B \-\-cachepolicy \fIpolicy
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache policy. \fImq\fP is the basic policy name. \fIsqm\fP is more advanced
+version available in newer kernels.
+.TP
.BR \-\-cachepool " " \fICachePoolLV
This argument is necessary when converting a logical volume to a cache LV.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
.TP
+.BR \-\-cachesettings " " \fIkey=value
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache tunable settings. In most use-cases, default values should be adequate.
+Special string value \fIdefault\fP switches setting back to its default kernel value
+and removes it from the list of settings stored in lvm2 metadata.
+.TP
.BR \-m ", " \-\-mirrors " " \fIMirrors
Specifies the degree of the mirror you wish to create.
For example, "\fB\-m 1\fP" would convert the original logical
@@ -496,7 +511,7 @@ See \fBlvmthin\fP(7) for more info about thin provisioning support.
Uncaches \fICacheLogicalVolume\fP.
Before the volume becomes uncached, cache is flushed.
Unlike with \fB\-\-splitcache\fP the cache pool volume is removed.
-This option could seen as an inverse of \fB\-\-cache\fP.
+This option could be seen as an inverse of \fB\-\-cache\fP.
.SH Examples
Converts the linear logical volume "vg00/lvol1" to a two-way mirror
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 5f5f74b..5f922b4 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -13,13 +13,13 @@ lvcreate \- create a logical volume in an existing volume group
.RI { y | n }]
.RB [ \-H | \-\-cache ]
.RB [ \-\-cachemode
-.RI { writeback | writethrough }]
+.RI { passthrough | writeback | writethrough }]
.RB [ \-\-cachepolicy
.IR policy ]
-.RB [ \-\-cachesettings
-.IR key=value ]
.RB [ \-\-cachepool
.IR CachePoolLogicalVolume { Name | Path }
+.RB [ \-\-cachesettings
+.IR key=value ]
.RB [ \-c | \-\-chunksize
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-commandprofile
@@ -188,7 +188,7 @@ See \fBlvmcache\fP(7) for more info about caching support.
Note that the cache segment type requires a dm-cache kernel module version
1.3.0 or greater.
.TP
-.IR \fB\-\-cachemode " {" writeback | writethrough }
+.IR \fB\-\-cachemode " {" passthrough | writeback | writethrough }
Specifying a cache mode determines when the writes to a cache LV
are considered complete. When \fIwriteback\fP is specified, a write is
considered complete as soon as it is stored in the cache pool LV.
@@ -198,10 +198,21 @@ While \fIwritethrough\fP may be slower for writes, it is more
resilient if something should happen to a device associated with the
cache pool LV.
.TP
+.B \-\-cachepolicy \fIpolicy
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache policy. \fImq\fP is the basic policy name. \fIsqm\fP is more advanced
+version available in newer kernels.
+.TP
.IR \fB\-\-cachepool " " CachePoolLogicalVolume { Name | Path }
Specifies the name of cache pool volume name. The other way to specify pool name
is to append name to Volume group name argument.
.TP
+.BR \-\-cachesettings " " \fIkey=value
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache tunable settings. In most use-cases, default values should be adequate.
+Special string value \fIdefault\fP switches setting back to its default kernel value
+and removes it from the list of settings stored in lvm2 metadata.
+.TP
.BR \-c ", " \-\-chunksize " " \fIChunkSize [ \fIbBsSkKmMgG ]
Gives the size of chunk for snapshot, cache pool and thin pool logical volumes.
Default unit is in kilobytes.
@@ -251,11 +262,6 @@ Ignore the flag to skip Logical Volumes during activation.
Use \fB\-\-setactivationskip\fP option to set or reset
activation skipping flag persistently for logical volume.
.TP
-.BR \-\-cachepolicy " " policy ", " \-\-cachesettings " " key=value
-Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
-the cache policy and its associated tunable settings. In most use-cases,
-default values should be adequate.
-.TP
.B \-\-ignoremonitoring
Make no attempt to interact with dmeventd unless \fB\-\-monitor\fP
is specified.
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - cache: runtime detect default policy
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=feb8e9a7907c91...
Commit: feb8e9a7907c91bd55769b4e3ae625434f2ba589
Parent: 8a74d1ec79d209aa8bce51821836179afe7d48f9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jul 26 23:05:11 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
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(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 347fcd4..da0ef4d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
diff --git a/lib/config/config.c b/lib/config/config.c
index 436efff..cd6c1d8 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -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;
}
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - cache: detect smq policy presence
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8a74d1ec79d209...
Commit: 8a74d1ec79d209aa8bce51821836179afe7d48f9
Parent: 694c88e031fb44f957c75bea369b898e1dedf932
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 23 11:32:09 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:17 2015 +0200
cache: detect smq policy presence
Add code to detect available cache features.
Support policy_mq & policy_smq features which might be disabled.
Introduce global_cache_disabled_features_CFG.
---
lib/cache_segtype/cache.c | 73 ++++++++++++++++++++++++++++++++++++++++--
lib/config/config_settings.h | 8 ++++
lib/metadata/segtype.h | 3 ++
3 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 18c0168..d74fbf1 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -25,6 +25,11 @@
#include "lv_alloc.h"
#include "defaults.h"
+static const char _cache_module[] = "cache";
+
+/* TODO: using static field here, maybe should be a part of segment_type */
+static unsigned _feature_mask;
+
#define SEG_LOG_ERROR(t, p...) \
log_error(t " segment %s of logical volume %s.", ## p, \
dm_config_parent_name(sn), seg->lv->name), 0;
@@ -168,9 +173,26 @@ static int _target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes __attribute__((unused)))
{
- uint32_t maj, min, patchlevel;
+ /* List of features with their kernel target version */
+ static const struct feature {
+ uint32_t maj;
+ uint32_t min;
+ unsigned cache_feature;
+ const char feature[12];
+ const char module[12]; /* check dm-%s */
+ } _features[] = {
+ { 1, 3, CACHE_FEATURE_POLICY_MQ, "policy_mq", "cache-mq" },
+ { 1, 8, CACHE_FEATURE_POLICY_SMQ, "policy_smq", "cache-smq" },
+ };
+ static const char _lvmconf[] = "global/cache_disabled_features";
+ static unsigned _attrs = 0;
static int _cache_checked = 0;
static int _cache_present = 0;
+ uint32_t maj, min, patchlevel;
+ unsigned i;
+ const struct dm_config_node *cn;
+ const struct dm_config_value *cv;
+ const char *str;
if (!_cache_checked) {
_cache_present = target_present(cmd, "cache", 1);
@@ -184,11 +206,53 @@ static int _target_present(struct cmd_context *cmd,
if ((maj < 1) ||
((maj == 1) && (min < 3))) {
- log_error("The cache kernel module is version %u.%u.%u."
- " Version 1.3.0+ is required.",
+ _cache_present = 0;
+ log_error("The cache kernel module is version %u.%u.%u. "
+ "Version 1.3.0+ is required.",
maj, min, patchlevel);
return 0;
}
+
+
+ for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) {
+ if (((maj > _features[i].maj) ||
+ (maj == _features[i].maj && min >= _features[i].min)) &&
+ (!_features[i].module[0] || module_present(cmd, _features[i].module)))
+ _attrs |= _features[i].cache_feature;
+ else
+ log_very_verbose("Target %s does not support %s.",
+ _cache_module, _features[i].feature);
+ }
+ }
+
+ if (attributes) {
+ if (!_feature_mask) {
+ /* Support runtime lvm.conf changes, N.B. avoid 32 feature */
+ if ((cn = find_config_tree_array(cmd, global_cache_disabled_features_CFG, NULL))) {
+ for (cv = cn->v; cv; cv = cv->next) {
+ if (cv->type != DM_CFG_STRING) {
+ log_error("Ignoring invalid string in config file %s.",
+ _lvmconf);
+ continue;
+ }
+ str = cv->v.str;
+ if (!*str)
+ continue;
+ for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
+ if (strcasecmp(str, _features[i].feature) == 0)
+ _feature_mask |= _features[i].cache_feature;
+ }
+ }
+
+ _feature_mask = ~_feature_mask;
+
+ for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
+ if ((_attrs & _features[i].cache_feature) &&
+ !(_feature_mask & _features[i].cache_feature))
+ log_very_verbose("Target %s %s support disabled by %s",
+ _cache_module, _features[i].feature, _lvmconf);
+ }
+ *attributes = _attrs & _feature_mask;
}
return _cache_present;
@@ -376,5 +440,8 @@ int init_cache_segtypes(struct cmd_context *cmd,
return_0;
log_very_verbose("Initialised segtype: %s", segtype->name);
+ /* Reset mask for recalc */
+ _feature_mask = 0;
+
return 1;
}
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index deb17ef..c8461f7 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -909,6 +909,14 @@ cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CF
"Example:\n"
"thin_disabled_features = [ \"discards\", \"block_size\" ]\n")
+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, 126), NULL, 0, NULL,
+ "Features to not use in the cache driver.\n"
+ "This can be helpful for testing, or to avoid\n"
+ "using a feature that is causing problems.\n"
+ "Features: policy_mq, policy_smq.\n"
+ "Example:\n"
+ "cache_disabled_features = [ \"policy_smq\" ]\n")
+
cfg(global_cache_check_executable_CFG, "cache_check_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, CACHE_CHECK_CMD, vsn(2, 2, 108), "@CACHE_CHECK_CMD@", 0, NULL,
"The full path to the cache_check command.\n"
"LVM uses this command to check that a cache metadata\n"
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 4b2df78..a80d5ed 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -191,6 +191,9 @@ int init_thin_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
int init_cache_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
#endif
+#define CACHE_FEATURE_POLICY_MQ (1U << 0)
+#define CACHE_FEATURE_POLICY_SMQ (1U << 1)
+
#define SNAPSHOT_FEATURE_FIXED_LEAK (1U << 0) /* version 1.12 */
#ifdef SNAPSHOT_INTERNAL
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - cache: add cache_policy cache_settings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=036d90bba6c1ac...
Commit: 036d90bba6c1ac76195302bc5c7f2f5ce8ad89b4
Parent: 664a9f4830925cc3f51934dc09f9e2f3963c0de2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 20 11:44:15 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:16 2015 +0200
cache: add cache_policy cache_settings
Add new profilable configurables:
allocation/cache_policy
allocation/cache_settings
and mark allocation/cache_pool_chunk_size as profilable as well.
Obsolete allocation/cache_pool_cachemode and
introduce new allocation/cache_mode instead.
Rename DEFAULT_CACHE_POOL_POLICY to DEFAULT_CACHE_POLICY.
---
WHATS_NEW | 1 +
lib/cache_segtype/cache.c | 2 +-
lib/config/config.c | 5 +++++
lib/config/config.h | 2 ++
lib/config/config_settings.h | 24 +++++++++++++++++++++---
lib/config/defaults.h | 4 ++--
tools/toollib.c | 2 +-
7 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d28e06c..9c8a103 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Add cmd profilable allocation/cache_policy,cache_settings,cache_mode.
Require cache_check 0.5.4 for use of --clear-needs-check-flag.
Fix lvmetad udev rules to not override SYSTEMD_WANTS, add the service instead.
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index ad356a9..18c0168 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -79,7 +79,7 @@ static int _cache_pool_text_import(struct lv_segment *seg,
return SEG_LOG_ERROR("Failed to duplicate policy in");
} else {
/* Cannot use 'just' default, so pick one */
- seg->policy_name = DEFAULT_CACHE_POOL_POLICY; /* FIXME make configurable */
+ seg->policy_name = DEFAULT_CACHE_POLICY; /* FIXME make configurable */
/* FIXME maybe here should be always 'mq' */
log_warn("WARNING: cache_policy undefined, using default \"%s\" policy.",
seg->policy_name);
diff --git a/lib/config/config.c b/lib/config/config.c
index eb8880e..436efff 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -2415,3 +2415,8 @@ int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, st
{
return DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
}
+
+const char *get_default_allocation_cache_policy_CFG(struct cmd_context *cmd, struct profile *profile)
+{
+ return DEFAULT_CACHE_POLICY;
+}
diff --git a/lib/config/config.h b/lib/config/config.h
index 7520fc0..fb39e6e 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -296,5 +296,7 @@ int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, str
#define get_default_unconfigured_allocation_thin_pool_chunk_size_CFG NULL
int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile);
#define get_default_unconfigured_allocation_cache_pool_chunk_size_CFG NULL
+const char *get_default_allocation_cache_policy_CFG(struct cmd_context *cmd, struct profile *profile);
+#define get_default_unconfigured_allocation_cache_policy_CFG NULL
#endif
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 5209531..deb17ef 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -462,15 +462,33 @@ cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separa
cfg(allocation_cache_pool_metadata_require_separate_pvs_CFG, "cache_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_CACHE_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 106), NULL, 0, NULL,
"Cache pool metadata and data will always use different PVs.\n")
-cfg(allocation_cache_pool_cachemode_CFG, "cache_pool_cachemode", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_POOL_CACHEMODE, vsn(2, 2, 113), NULL, 0, NULL,
- "The default cache mode used for new cache pools.\n"
+cfg(allocation_cache_pool_cachemode_CFG, "cache_pool_cachemode", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_CACHE_MODE, vsn(2, 2, 113), NULL, vsn(2, 2, 128),
+ "This has been replaced by the allocation/cache_mode setting.\n",
+ "Cache mode.\n")
+
+cfg(allocation_cache_mode_CFG, "cache_mode", allocation_CFG_SECTION, 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"
"Possible options are: writethrough, writeback.\n"
"writethrough - Data blocks are immediately written from\n"
"the cache to disk.\n"
"writeback - Data blocks are written from the cache back\n"
"to disk after some delay to improve performance.\n")
-cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", allocation_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 106), 0, NULL,
+cfg_runtime(allocation_cache_policy_CFG, "cache_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, vsn(2, 2, 127), 0, NULL,
+ "The default cache policy used for new cache volume.\n"
+ "Generally available policies are: mq, smq.\n"
+ "mq - Multiqueue policy with 88 bytes per block\n"
+ "smq - Stochastic multique with 25 bytes per block (kernel >= 4.2).\n")
+
+cfg_section(allocation_cache_settings_CFG_SECTION, "cache_settings", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, vsn(2, 2, 127), 0, NULL,
+ "Individual settings for policies.\n"
+ "See the help for individual policies for more info.\n")
+
+cfg_section(policy_settings_CFG_SUBSECTION, "policy_settings", allocation_cache_settings_CFG_SECTION, CFG_NAME_VARIABLE | CFG_SECTION_NO_CHECK | CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, vsn(2, 2, 127), 0, NULL,
+ "Replace this subsection name with a policy name.\n"
+ "Multiple subsections for different policies can be created.\n")
+
+cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 106), 0, NULL,
"The minimal chunk size (in kiB) for cache pool volumes.\n"
"Using a chunk_size that is too large can result in wasteful\n"
"use of the cache, where small reads and writes can cause\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 5ee9b1c..f84eb19 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -117,8 +117,8 @@
#define DEFAULT_CACHE_POOL_CHUNK_SIZE 64 /* 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_CACHEMODE "writethrough"
-#define DEFAULT_CACHE_POOL_POLICY "mq"
+#define DEFAULT_CACHE_POLICY "mq"
+#define DEFAULT_CACHE_MODE "writethrough"
#define DEFAULT_UMASK 0077
diff --git a/tools/toollib.c b/tools/toollib.c
index 5d5e4d6..0d401e4 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1408,7 +1408,7 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
struct dm_config_node *cn;
int ok = 0;
- *name = arg_str_value(cmd, cachepolicy_ARG, DEFAULT_CACHE_POOL_POLICY);
+ *name = arg_str_value(cmd, cachepolicy_ARG, DEFAULT_CACHE_POLICY);
dm_list_iterate_items(group, &cmd->arg_value_groups) {
if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - udev: use += for SYSTEMD_WANTS instead of =
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3ea396e9d220ce...
Commit: 3ea396e9d220cec55fd4e139be7ae486cb4ddb91
Parent: 819dc1845edcf48e0f3eb282a6d8b9ace8cb1a1b
Author: Thomas Bächler <thomas(a)archlinux.org>
AuthorDate: Wed Aug 12 09:29:04 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Aug 12 09:33:06 2015 +0200
udev: use += for SYSTEMD_WANTS instead of =
Instead of using = to override SYSTEMD_WANTS, use += to add
the pvscan service.
---
WHATS_NEW | 1 +
udev/Makefile.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 71c41d2..8241dc1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Fix lvmetad udev rules to not override SYSTEMD_WANTS, add the service instead.
Version 2.02.127 - 10th August 2015
===================================
diff --git a/udev/Makefile.in b/udev/Makefile.in
index 390069b..c4cc2bd 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -47,7 +47,7 @@ BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
endif
ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes")
-PVSCAN_RULE=ACTION\!=\"remove\", ENV{LVM_PV_GONE}==\"1\", RUN\+=\"@bindir@/systemd-run $(LVM_EXEC)\/lvm pvscan --cache \$$major\:\$$minor\", GOTO=\"lvm_end\"\nENV{SYSTEMD_ALIAS}=\"\/dev\/block\/\$$major:\$$minor\"\nENV{ID_MODEL}=\"LVM PV \$$env{ID_FS_UUID_ENC} on \/dev\/\$$name\"\nENV{SYSTEMD_WANTS}=\"lvm2-pvscan@\$$major:\$$minor.service\"
+PVSCAN_RULE=ACTION\!=\"remove\", ENV{LVM_PV_GONE}==\"1\", RUN\+=\"@bindir@/systemd-run $(LVM_EXEC)\/lvm pvscan --cache \$$major\:\$$minor\", GOTO=\"lvm_end\"\nENV{SYSTEMD_ALIAS}=\"\/dev\/block\/\$$major:\$$minor\"\nENV{ID_MODEL}=\"LVM PV \$$env{ID_FS_UUID_ENC} on \/dev\/\$$name\"\nENV{SYSTEMD_WANTS}+=\"lvm2-pvscan@\$$major:\$$minor.service\"
else
PVSCAN_RULE=RUN\+\=\"$(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major \$$major --minor \$$minor\", ENV{LVM_SCANNED}=\"1\"
endif
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - lvrename: fix lockd LV locking
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=53c08f0bba9f18...
Commit: 53c08f0bba9f18df80403eab67acb032f3049902
Parent: 597de9d58673f141bf21aa9db899d13ca2c97b7b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Aug 10 15:46:21 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Aug 10 15:46:21 2015 -0500
lvrename: fix lockd LV locking
lvrename should not be done if the LV is active on another host.
This check was mistakenly removed when the code was changed to
use LV uuids in locks rather than LV names.
---
lib/metadata/lv_manip.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 86411d5..b22773e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4205,6 +4205,18 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
+ /*
+ * The lvmlockd LV lock is only acquired here to ensure the LV is not
+ * active on another host. This requests a transient LV lock.
+ * If the LV is active, a persistent LV lock already exists in
+ * lvmlockd, and the transient lock request does nothing.
+ * If the LV is not active, then no LV lock exists and the transient
+ * lock request acquires the LV lock (or fails). The transient lock
+ * is automatically released when the command exits.
+ */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_0;
+
if (update_mda && !archive(vg))
return_0;
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - lvmlockd: add LV name to some debug logging
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=597de9d58673f1...
Commit: 597de9d58673f141bf21aa9db899d13ca2c97b7b
Parent: f072a7632655d0541b56858d5fbe172fa6075e68
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Aug 10 15:05:41 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Aug 10 15:07:10 2015 -0500
lvmlockd: add LV name to some debug logging
The LV uuid is used as the lock name, and including
the LV name in some log messages makes it easier to
follow log messages.
---
daemons/lvmlockd/lvmlockd-core.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 5e4e73f..86bb89b 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -1022,7 +1022,10 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
uint32_t r_version = 0;
int rv;
- log_debug("S %s R %s res_lock mode %s", ls->name, r->name, mode_str(act->mode));
+ if (r->type == LD_RT_LV)
+ log_debug("S %s R %s res_lock mode %s (%s)", ls->name, r->name, mode_str(act->mode), act->lv_name);
+ else
+ log_debug("S %s R %s res_lock mode %s", ls->name, r->name, mode_str(act->mode));
if (r->mode == LD_LK_SH && act->mode == LD_LK_SH)
goto add_lk;
@@ -1284,8 +1287,12 @@ static int res_unlock(struct lockspace *ls, struct resource *r,
return -ENOENT;
do_unlock:
- log_debug("S %s R %s res_unlock %s", ls->name, r->name,
- (act->op == LD_OP_CLOSE) ? "from close" : "");
+ if (act->op == LD_OP_CLOSE)
+ log_debug("S %s R %s res_unlock from close", ls->name, r->name);
+ else if (r->type == LD_RT_LV)
+ log_debug("S %s R %s res_unlock (%s)", ls->name, r->name, act->lv_name);
+ else
+ log_debug("S %s R %s res_unlock", ls->name, r->name);
/* send unlock to lm when last sh lock is unlocked */
if (lk->mode == LD_LK_SH) {
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - libdm: simplify stats nr_areas calculation (Coverity)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=856f9cced83078...
Commit: 856f9cced83078a90ca2291eff0758d42775f195
Parent: ec87e88c5264511576341286b474b453a15594ba
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Aug 10 19:18:16 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 10 20:26:07 2015 +0100
libdm: simplify stats nr_areas calculation (Coverity)
Remove an unneccessary conditional operator and simplify the logic
in _nr_areas:
libdm/libdm-stats.c: 501 in _nr_areas() - Control flow issues (DEADCODE)
---
libdm/libdm-stats.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index a672e05..192326e 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -503,8 +503,7 @@ static uint64_t _nr_areas(uint64_t len, uint64_t step)
* treat the entire region as a single area. Any partial area at the
* end of the region is treated as an additional complete area.
*/
- return (len && step)
- ? (len / (step ? step : len)) + !!(len % step) : 0;
+ return (len / (step ? : len)) + !!(len % step);
}
static uint64_t _nr_areas_region(struct dm_stats_region *region)
8 years, 10 months
dev-prajnoha-pv-ext-flag-used - dmsetup: don't free handle if dm_stats_create fails (Coverity)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ec87e88c526451...
Commit: ec87e88c5264511576341286b474b453a15594ba
Parent: f9f5aac123d2244daeff92a692a03da3fea6bd74
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Aug 10 19:05:10 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 10 20:25:59 2015 +0100
dmsetup: don't free handle if dm_stats_create fails (Coverity)
The error path of _stats_list frees the task and stats objects:
don't try to branch to it before they have been allocated.
tools/dmsetup.c: 4589 in _stats_help() - Null pointer dereferences (FORWARD_NULL)
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 2ee432b..ed3cbd1 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4253,7 +4253,7 @@ static int _stats_list(CMD_ARGS)
return 1;
if (!(dms = dm_stats_create(DM_STATS_PROGRAM_ID)))
- goto_out;
+ return_0;
if (!_bind_stats_device(dms, name))
goto_out;
8 years, 10 months