master - dumpconfig: fix dumpconfig --type diff used in lvm shell as second and later command
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=24f32721a9e6a6...
Commit: 24f32721a9e6a61943122f3d06d2329f5f81597c
Parent: 9a324df3b329f1a28462f246219522da62a022ce
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 19 14:51:11 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon May 19 15:41:25 2014 +0200
dumpconfig: fix dumpconfig --type diff used in lvm shell as second and later command
The dumpconfig reuses existing config_def_check results in case
the check is done during general lvm command context initialization
(when enabled by config/checks=1) so dumpconfig does not need to run
the same check again during its execution, hence saving some time.
However, we don't check for differences from defaults during general
lvm command initialization as it's useless at that time. It makes
sense only in case when such a check is directly requested (like in
the case of lvm dumpconfig --type diff). We need to take care that
the reused information was already produced with this "diff" checking
before and if not, we need to force the check so the check status also
gathers the new "diff" info now.
Also, do not do diff checking for any other dumpconfig command that
is run after dumpconfig --type diff.
---
WHATS_NEW | 1 +
tools/dumpconfig.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 06d0854..6cbd622 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Fix dumpconfig --type diff when run as second and later cmd in lvm shell.
Fix wrong profile reuse from previous run if another cmd is run in lvm shell.
Move cache description from lvm(8) to lvmcache(7) man page.
Display skipped prompt in silent mode.
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 49a6a68..141a030 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -41,10 +41,14 @@ static int _do_def_check(struct config_def_tree_spec *spec,
handle->force_check = 1;
handle->suppress_messages = 1;
- if (spec->type == CFG_DEF_TREE_DIFF)
+ if (spec->type == CFG_DEF_TREE_DIFF) {
+ if (!handle->check_diff)
+ handle->skip_if_checked = 0;
handle->check_diff = 1;
- else
+ } else {
handle->skip_if_checked = 1;
+ handle->check_diff = 0;
+ }
config_def_check(handle);
*cft_check_handle = handle;
10 years
master - config: fix incorrect profile initialization on cmd context refresh
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a324df3b329f1...
Commit: 9a324df3b329f1a28462f246219522da62a022ce
Parent: c42f72867a653974f07e6e1db52f41691356e5b7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 19 13:59:23 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon May 19 15:39:55 2014 +0200
config: fix incorrect profile initialization on cmd context refresh
When cmd refresh is called, we need to move any already loaded profiles
to profiles_to_load list which will cause their reload on subsequent
use. In addition to that, we need to take into account any change
in config/profile configuration setting on cmd context refresh
since this setting could be overriden with --config.
Also, when running commands in the shell, we need to remove the
global profile used from the configuration cascade so the profile
is not incorrectly reused next time when the --profile option is
not specified anymore for the next command in the shell.
This bug only affected profile specified by --profile cmd line
arg, not profiles referenced from LVM metadata.
---
WHATS_NEW | 1 +
lib/commands/toolcontext.c | 50 ++++++++++++++++++++++++++++++++++---------
lib/config/config.h | 2 +-
tools/lvmcmdline.c | 18 +++++++++------
4 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 72834a8..06d0854 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Fix wrong profile reuse from previous run if another cmd is run in lvm shell.
Move cache description from lvm(8) to lvmcache(7) man page.
Display skipped prompt in silent mode.
Make reporting commands show help about possible sort keys on '-O help'.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 03b06d2..904ae83 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -630,8 +630,9 @@ static int _init_profiles(struct cmd_context *cmd)
{
const char *dir;
struct profile_params *pp;
+ int initialized = cmd->profile_params != NULL;
- if (!(pp = dm_pool_zalloc(cmd->libmem, sizeof(*pp)))) {
+ if (!initialized && !(pp = dm_pool_zalloc(cmd->libmem, sizeof(*pp)))) {
log_error("profile_params alloc failed");
return 0;
}
@@ -639,11 +640,15 @@ static int _init_profiles(struct cmd_context *cmd)
if (!(dir = find_config_tree_str(cmd, config_profile_dir_CFG, NULL)))
return_0;
- pp->dir = dm_pool_strdup(cmd->libmem, dir);
- dm_list_init(&pp->profiles_to_load);
- dm_list_init(&pp->profiles);
+ if (initialized) {
+ dm_strncpy(cmd->profile_params->dir, dir, sizeof(pp->dir));
+ } else {
+ dm_strncpy(pp->dir, dir, sizeof(pp->dir));
+ dm_list_init(&pp->profiles_to_load);
+ dm_list_init(&pp->profiles);
+ cmd->profile_params = pp;
+ }
- cmd->profile_params = pp;
return 1;
}
@@ -693,7 +698,7 @@ static void _destroy_config(struct cmd_context *cmd)
{
struct config_tree_list *cfl;
struct dm_config_tree *cft;
- struct profile *profile;
+ struct profile *profile, *tmp_profile;
/*
* Configuration cascade:
@@ -713,12 +718,17 @@ static void _destroy_config(struct cmd_context *cmd)
/* CONFIG_PROFILE */
if (cmd->profile_params) {
remove_config_tree_by_source(cmd, CONFIG_PROFILE);
- dm_list_iterate_items(profile, &cmd->profile_params->profiles_to_load)
- config_destroy(profile->cft);
- dm_list_iterate_items(profile, &cmd->profile_params->profiles)
+ /*
+ * Destroy config trees for any loaded profiles and
+ * move these profiles to profile_to_load list.
+ * Whenever these profiles are referenced later,
+ * they will get loaded again automatically.
+ */
+ dm_list_iterate_items_safe(profile, tmp_profile, &cmd->profile_params->profiles) {
config_destroy(profile->cft);
- dm_list_init(&cmd->profile_params->profiles_to_load);
- dm_list_init(&cmd->profile_params->profiles);
+ profile->cft = NULL;
+ dm_list_move(&cmd->profile_params->profiles_to_load, &profile->list);
+ }
}
/* CONFIG_STRING */
@@ -1595,6 +1605,8 @@ int refresh_filters(struct cmd_context *cmd)
int refresh_toolcontext(struct cmd_context *cmd)
{
struct dm_config_tree *cft_cmdline, *cft_tmp;
+ const char *profile_name;
+ struct profile *profile;
log_verbose("Reloading config files");
@@ -1617,7 +1629,13 @@ int refresh_toolcontext(struct cmd_context *cmd)
_destroy_dev_types(cmd);
_destroy_tags(cmd);
+ /* save config string passed on the command line */
cft_cmdline = remove_config_tree_by_source(cmd, CONFIG_STRING);
+
+ /* save the global profile name used */
+ profile_name = cmd->profile_params->global_profile ?
+ cmd->profile_params->global_profile->name : NULL;
+
_destroy_config(cmd);
cmd->config_initialized = 0;
@@ -1634,6 +1652,13 @@ int refresh_toolcontext(struct cmd_context *cmd)
if (cft_cmdline)
cmd->cft = dm_config_insert_cascaded_tree(cft_cmdline, cft_tmp);
+ /* Reload the global profile. */
+ if (profile_name) {
+ if (!(profile = add_profile(cmd, profile_name)) ||
+ !override_config_tree_from_profile(cmd, profile))
+ return_0;
+ }
+
/* Uses cmd->cft i.e. cft_cmdline + lvm.conf */
_init_logging(cmd);
@@ -1657,6 +1682,9 @@ int refresh_toolcontext(struct cmd_context *cmd)
if (!_process_config(cmd))
return_0;
+ if (!_init_profiles(cmd))
+ return_0;
+
if (!(cmd->dev_types = create_dev_types(cmd->proc_dir,
find_config_tree_node(cmd, devices_types_CFG, NULL))))
return_0;
diff --git a/lib/config/config.h b/lib/config/config.h
index 4967b27..df5841c 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -41,7 +41,7 @@ struct profile {
};
struct profile_params {
- const char *dir; /* subdir in LVM_SYSTEM_DIR where LVM looks for profiles */
+ char dir[PATH_MAX]; /* subdir in LVM_SYSTEM_DIR where LVM looks for profiles */
struct profile *global_profile; /* profile that overrides any other VG/LV-based profile ('--profile' cmd line arg) */
struct dm_list profiles_to_load;/* list of profiles which are only added, but still need to be loaded for any use */
struct dm_list profiles; /* list of profiles which are loaded already and which are ready for use */
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 7e4d9a6..69e5781 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1081,11 +1081,11 @@ static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **
int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
+ struct dm_config_tree *config_string_cft, *config_profile_cft;
+ struct profile *profile;
int ret = 0;
int locking_type;
int monitoring;
- struct dm_config_tree *old_cft;
- struct profile *profile;
init_error_message_produced(0);
@@ -1124,9 +1124,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, config_ARG) || !cmd->config_initialized || config_files_changed(cmd)) {
/* Reinitialise various settings inc. logging, filters */
if (!refresh_toolcontext(cmd)) {
- old_cft = remove_config_tree_by_source(cmd, CONFIG_STRING);
- if (old_cft)
- dm_config_destroy(old_cft);
+ if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))
+ dm_config_destroy(config_string_cft);
log_error("Updated config file invalid. Aborting.");
return ECMD_FAILED;
}
@@ -1204,8 +1203,13 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
lvmcache_destroy(cmd, 1, 0);
}
- if ((old_cft = remove_config_tree_by_source(cmd, CONFIG_STRING))) {
- dm_config_destroy(old_cft);
+ if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))
+ dm_config_destroy(config_string_cft);
+
+ config_profile_cft = remove_config_tree_by_source(cmd, CONFIG_PROFILE);
+ cmd->profile_params->global_profile = NULL;
+
+ if (config_string_cft || config_profile_cft) {
/* Move this? */
if (!refresh_toolcontext(cmd))
stack;
10 years
master - config: attach cft_check_handle to each config tree instead of global cmd_context
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c42f72867a6539...
Commit: c42f72867a653974f07e6e1db52f41691356e5b7
Parent: ff9d27a1c71785abd6aa71eddc7018dd56807517
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 19 13:23:12 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon May 19 15:38:04 2014 +0200
config: attach cft_check_handle to each config tree instead of global cmd_context
Before, the cft_check_handle used to direct configuration checking
was part of cmd_context. It's better to attach this as part of the
exact config tree against which the check is done. This patch moves
the cft_check_handle out of cmd_context and it attaches it to the
config tree directly as dm_config_tree->custom->config_source->check_handle.
This change makes it easier to track the config tree check results
and provides less space for bugs as the results are directly attached
to the tree and we don't need to be cautious whether the global value
is correct or not (and whether it needs reinitialization) as it was
in the case when the cft_check_handle was part of cmd_context.
---
lib/commands/toolcontext.c | 34 +++++++++++++++++-----------
lib/commands/toolcontext.h | 1 -
lib/config/config.c | 51 +++++++++++++++++++++++++++++++++++++++++-
lib/config/config.h | 5 +++-
tools/dumpconfig.c | 52 +++++++++++++------------------------------
5 files changed, 90 insertions(+), 53 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index b2f8293..03b06d2 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -256,24 +256,32 @@ static int _check_disable_udev(const char *msg) {
return 0;
}
+static int _check_config_by_source(struct cmd_context *cmd, config_source_t source)
+{
+ struct dm_config_tree *cft;
+ struct cft_check_handle *handle;
+
+ if (!(cft = get_config_tree_by_source(cmd, source)) ||
+ !(handle = get_config_tree_check_handle(cmd, cft)))
+ return 1;
+
+ return config_def_check(handle);
+}
+
static int _check_config(struct cmd_context *cmd)
{
+ int abort_on_error;
+
if (!find_config_tree_bool(cmd, config_checks_CFG, NULL))
return 1;
- if (!cmd->cft_check_handle) {
- if (!(cmd->cft_check_handle = dm_pool_zalloc(cmd->libmem, sizeof(*cmd->cft_check_handle)))) {
- log_error("Configuration check handle allocation failed.");
- return 0;
- }
- }
-
- cmd->cft_check_handle->cft = cmd->cft;
- cmd->cft_check_handle->cmd = cmd;
+ abort_on_error = find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL);
- if (!config_def_check(cmd->cft_check_handle) &&
- find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL)) {
- log_error("LVM configuration invalid.");
+ if ((!_check_config_by_source(cmd, CONFIG_STRING) ||
+ !_check_config_by_source(cmd, CONFIG_MERGED_FILES) ||
+ !_check_config_by_source(cmd, CONFIG_FILE)) &&
+ abort_on_error) {
+ log_error("LVM_ configuration invalid.");
return 0;
}
@@ -571,7 +579,7 @@ static int _load_config_file(struct cmd_context *cmd, const char *tag)
return 0;
}
- if (!(cfl->cft = config_file_open_and_read(config_file, CONFIG_FILE)))
+ if (!(cfl->cft = config_file_open_and_read(config_file, CONFIG_FILE, cmd)))
return_0;
dm_list_add(&cmd->config_files, &cfl->list);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 7694ee2..9023a6c 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -105,7 +105,6 @@ struct cmd_context {
int config_initialized; /* used to reinitialize config if previous init was not successful */
struct dm_hash_table *cft_def_hash; /* config definition hash used for validity check (item type + item recognized) */
- struct cft_check_handle *cft_check_handle;
/* selected settings with original default/configured value which can be changed during cmd processing */
struct config_info default_settings;
diff --git a/lib/config/config.c b/lib/config/config.c
index b0880a6..4b5c18c 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -57,6 +57,7 @@ struct config_source {
struct config_file *file;
struct config_file *profile;
} source;
+ struct cft_check_handle *check_handle;
};
/*
@@ -246,7 +247,8 @@ void config_destroy(struct dm_config_tree *cft)
}
struct dm_config_tree *config_file_open_and_read(const char *config_file,
- config_source_t source)
+ config_source_t source,
+ struct cmd_context *cmd)
{
struct dm_config_tree *cft;
struct stat info;
@@ -277,6 +279,22 @@ bad:
return NULL;
}
+struct dm_config_tree *get_config_tree_by_source(struct cmd_context *cmd,
+ config_source_t source)
+{
+ struct dm_config_tree *cft = cmd->cft;
+ struct config_source *cs;
+
+ while (cft) {
+ cs = dm_config_get_custom(cft);
+ if (cs && cs->type == source)
+ return cft;
+ cft = cft->cascade;
+ }
+
+ return NULL;
+}
+
/*
* Returns config tree if it was removed.
*/
@@ -305,6 +323,35 @@ struct dm_config_tree *remove_config_tree_by_source(struct cmd_context *cmd,
return cft;
}
+struct cft_check_handle *get_config_tree_check_handle(struct cmd_context *cmd,
+ struct dm_config_tree *cft)
+{
+ struct config_source *cs = dm_config_get_custom(cft);
+
+ if (!(cs = dm_config_get_custom(cft)))
+ return NULL;
+
+ if (cs->check_handle)
+ goto out;
+
+ /*
+ * Attach config check handle to all config types but
+ * CONFIG_FILE_SPECIAL - this one uses its own check
+ * methods and the cft_check_handle is not applicable here.
+ */
+ if (cs->type != CONFIG_FILE_SPECIAL) {
+ if (!(cs->check_handle = dm_pool_zalloc(cft->mem, sizeof(*cs->check_handle)))) {
+ log_error("Failed to allocate configuration check handle.");
+ return NULL;
+ }
+ cs->check_handle->cft = cft;
+ cs->check_handle->cmd = cmd;
+ }
+out:
+ return cs->check_handle;
+}
+
+
int override_config_tree_from_string(struct cmd_context *cmd,
const char *config_settings)
{
@@ -1646,7 +1693,7 @@ int load_profile(struct cmd_context *cmd, struct profile *profile) {
return 0;
}
- if (!(profile->cft = config_file_open_and_read(profile_path, CONFIG_PROFILE)))
+ if (!(profile->cft = config_file_open_and_read(profile_path, CONFIG_PROFILE, cmd)))
return 0;
dm_list_move(&cmd->profile_params->profiles, &profile->list);
diff --git a/lib/config/config.h b/lib/config/config.h
index d78ea43..4967b27 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -183,7 +183,9 @@ int config_def_check(struct cft_check_handle *handle);
int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings);
int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);
+struct dm_config_tree *get_config_tree_by_source(struct cmd_context *, config_source_t source);
struct dm_config_tree *remove_config_tree_by_source(struct cmd_context *cmd, config_source_t source);
+struct cft_check_handle *get_config_tree_check_handle(struct cmd_context *cmd, struct dm_config_tree *cft);
config_source_t config_get_source_type(struct dm_config_tree *cft);
typedef uint32_t (*checksum_fn_t) (uint32_t initial, const uint8_t *buf, uint32_t size);
@@ -193,7 +195,8 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev,
off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum);
int config_file_read(struct dm_config_tree *cft);
-struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source);
+struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source,
+ struct cmd_context *cmd);
int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec,
const char *file, int argc, char **argv);
struct dm_config_tree *config_def_create_tree(struct config_def_tree_spec *spec);
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 97863be..49a6a68 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -29,40 +29,13 @@ static int _get_vsn(struct cmd_context *cmd, uint16_t *version_int)
return 1;
}
-static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, struct dm_config_tree *cft)
-{
- struct cft_check_handle *handle;
- struct dm_pool *mem;
-
- if (cft == cmd->cft) {
- mem = cmd->libmem;
- handle = cmd->cft_check_handle;
- } else {
- mem = cft->mem;
- handle = NULL;
- }
-
- if (!handle) {
- if (!(handle = dm_pool_zalloc(mem, sizeof(struct cft_check_handle)))) {
- log_error("Configuration check handle allocation failed.");
- return NULL;
- }
- handle->cmd = cmd;
- handle->cft = cft;
- if (cft == cmd->cft)
- cmd->cft_check_handle = handle;
- }
-
- return handle;
-}
-
static int _do_def_check(struct config_def_tree_spec *spec,
struct dm_config_tree *cft,
struct cft_check_handle **cft_check_handle)
{
struct cft_check_handle *handle;
- if (!(handle = _get_cft_check_handle(spec->cmd, cft)))
+ if (!(handle = get_config_tree_check_handle(spec->cmd, cft)))
return 0;
handle->force_check = 1;
@@ -94,6 +67,20 @@ static int _merge_config_cascade(struct cmd_context *cmd, struct dm_config_tree
return merge_config_tree(cmd, *cft_merged, cft_cascaded, CONFIG_MERGE_TYPE_RAW);
}
+static int _config_validate(struct cmd_context *cmd, struct dm_config_tree *cft)
+{
+ struct cft_check_handle *handle;
+
+ if (!(handle = get_config_tree_check_handle(cmd, cft)))
+ return 1;
+
+ handle->force_check = 1;
+ handle->skip_if_checked = 1;
+ handle->suppress_messages = 0;
+
+ return config_def_check(handle);
+}
+
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
@@ -154,14 +141,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
cft = cmd->cft;
if (arg_count(cmd, validate_ARG)) {
- if (!(cft_check_handle = _get_cft_check_handle(cmd, cft)))
- return ECMD_FAILED;
-
- cft_check_handle->force_check = 1;
- cft_check_handle->skip_if_checked = 1;
- cft_check_handle->suppress_messages = 0;
-
- if (config_def_check(cft_check_handle)) {
+ if (_config_validate(cmd, cft)) {
log_print("LVM configuration valid.");
goto out;
} else {
10 years
master - config: add CONFIG_FILE_SPECIAL config source id
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff9d27a1c71785...
Commit: ff9d27a1c71785abd6aa71eddc7018dd56807517
Parent: ecccb759048c143a4e9e2e1b96afb6b6178a9325
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 19 10:58:28 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon May 19 15:37:41 2014 +0200
config: add CONFIG_FILE_SPECIAL config source id
Add CONFIG_FILE_SPECIAL config source id to make a difference between
real configuration tree (like lvm.conf and tag configs) and special purpose
configuration tree (like LVM metadata, persistent filter).
This makes it easier to attach correct customized data to the config
tree that is created out of the source then.
---
lib/config/config.c | 29 ++++++++++++++++++++---------
lib/config/config.h | 3 ++-
lib/filters/filter-persistent.c | 2 +-
lib/format_text/import.c | 4 ++--
4 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 04f917d..b0880a6 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -38,7 +38,8 @@ static const char *_config_source_names[] = {
[CONFIG_FILE] = "file",
[CONFIG_MERGED_FILES] = "merged files",
[CONFIG_STRING] = "string",
- [CONFIG_PROFILE] = "profile"
+ [CONFIG_PROFILE] = "profile",
+ [CONFIG_FILE_SPECIAL] = "special purpose"
};
struct config_file {
@@ -100,7 +101,9 @@ struct dm_config_tree *config_open(config_source_t source,
goto fail;
}
- if ((source == CONFIG_FILE) || (source == CONFIG_PROFILE)) {
+ if ((source == CONFIG_FILE) ||
+ (source == CONFIG_FILE_SPECIAL) ||
+ (source == CONFIG_PROFILE)) {
if (!(cf = dm_pool_zalloc(cft->mem, sizeof(struct config_file)))) {
log_error("Failed to allocate config file.");
goto fail;
@@ -133,9 +136,12 @@ int config_file_check(struct dm_config_tree *cft, const char **filename, struct
struct config_file *cf;
struct stat _info;
- if ((cs->type != CONFIG_FILE) && (cs->type != CONFIG_PROFILE)) {
- log_error(INTERNAL_ERROR "config_file_check: expected file or profile config source, "
- "found %s config source.", _config_source_names[cs->type]);
+ if ((cs->type != CONFIG_FILE) &&
+ (cs->type != CONFIG_PROFILE) &&
+ (cs->type != CONFIG_FILE_SPECIAL)) {
+ log_error(INTERNAL_ERROR "config_file_check: expected file, special file or "
+ "profile config source, found %s config source.",
+ _config_source_names[cs->type]);
return 0;
}
@@ -227,7 +233,9 @@ void config_destroy(struct dm_config_tree *cft)
cs = dm_config_get_custom(cft);
- if ((cs->type == CONFIG_FILE) || (cs->type == CONFIG_PROFILE)) {
+ if ((cs->type == CONFIG_FILE) ||
+ (cs->type == CONFIG_PROFILE) ||
+ (cs->type == CONFIG_FILE_SPECIAL)) {
cf = cs->source.file;
if (cf && cf->dev)
if (!dev_close(cf->dev))
@@ -377,9 +385,12 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev,
char *buf = NULL;
struct config_source *cs = dm_config_get_custom(cft);
- if ((cs->type != CONFIG_FILE) && (cs->type != CONFIG_PROFILE)) {
- log_error(INTERNAL_ERROR "config_file_read_fd: expected file or profile config source, "
- "found %s config source.", _config_source_names[cs->type]);
+ if ((cs->type != CONFIG_FILE) &&
+ (cs->type != CONFIG_PROFILE) &&
+ (cs->type != CONFIG_FILE_SPECIAL)) {
+ log_error(INTERNAL_ERROR "config_file_read_fd: expected file, special file "
+ "or profile config source, found %s config source.",
+ _config_source_names[cs->type]);
return 0;
}
diff --git a/lib/config/config.h b/lib/config/config.h
index b258d55..d78ea43 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -30,7 +30,8 @@ typedef enum {
CONFIG_FILE, /* one file config */
CONFIG_MERGED_FILES, /* config that is a result of merging more config files */
CONFIG_STRING, /* config string typed on cmdline using '--config' arg */
- CONFIG_PROFILE /* profile config */
+ CONFIG_PROFILE, /* profile config */
+ CONFIG_FILE_SPECIAL /* special purpose file config (e.g. metadata, persistent filter...) */
} config_source_t;
struct profile {
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 14a3480..7eaae71 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -114,7 +114,7 @@ int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out
return_0;
}
- if (!(cft = config_open(CONFIG_FILE, pf->file, 1)))
+ if (!(cft = config_open(CONFIG_FILE_SPECIAL, pf->file, 1)))
return_0;
if (!config_file_read(cft))
diff --git a/lib/format_text/import.c b/lib/format_text/import.c
index 6b7d589..1b1f332 100644
--- a/lib/format_text/import.c
+++ b/lib/format_text/import.c
@@ -46,7 +46,7 @@ const char *text_vgname_import(const struct format_type *fmt,
_init_text_import();
- if (!(cft = config_open(CONFIG_FILE, NULL, 0)))
+ if (!(cft = config_open(CONFIG_FILE_SPECIAL, NULL, 0)))
return_NULL;
if ((!dev && !config_file_read(cft)) ||
@@ -92,7 +92,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
*desc = NULL;
*when = 0;
- if (!(cft = config_open(CONFIG_FILE, file, 0)))
+ if (!(cft = config_open(CONFIG_FILE_SPECIAL, file, 0)))
return_NULL;
if ((!dev && !config_file_read(cft)) ||
10 years
master - tests: drop nosync
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ecccb759048c14...
Commit: ecccb759048c143a4e9e2e1b96afb6b6178a9325
Parent: 477351fc4d2f2d0a55089fb6b6bc1f26e2605f7b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 19 13:22:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 19 13:22:46 2014 +0200
tests: drop nosync
Mirrors currently do not support any conversion,
when they are created no-sync.
---
test/shell/lvconvert-mirror-basic.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh
index 49d32aa..28258b2 100644
--- a/test/shell/lvconvert-mirror-basic.sh
+++ b/test/shell/lvconvert-mirror-basic.sh
@@ -77,7 +77,7 @@ test_lvconvert() {
fi
lvcreate -aey -l2 --type mirror -m $start_count --mirrorlog $start_log_type \
- --nosync -n $lv1 $vg $alloc
+ -n $lv1 $vg $alloc
check mirror_legs $vg $lv1 $start_count_p1
# FIXME: check mirror log
else
10 years
master - man: lvmcache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=477351fc4d2f2d...
Commit: 477351fc4d2f2d0a55089fb6b6bc1f26e2605f7b
Parent: 91284bd9b913f74a0071082d542c3c09d11524f2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun May 18 20:09:47 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 18 20:09:47 2014 +0200
man: lvmcache
separate man page for lvm cache
---
man/lvmcache.7.in | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 201 insertions(+), 0 deletions(-)
diff --git a/man/lvmcache.7.in b/man/lvmcache.7.in
new file mode 100644
index 0000000..5a09257
--- /dev/null
+++ b/man/lvmcache.7.in
@@ -0,0 +1,201 @@
+.TH "LVMCACHE" "7" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
+.SH NAME
+lvmcache - LVM caching
+
+.SH DESCRIPTION
+
+The \fIcache\fP logical volume type uses a small and fast LV to improve
+the performance of a large and slow LV. It does this by storing the
+frequently used blocks on the faster LV.
+LVM refers to the small fast LV as a \fBcache pool LV\fP. The large
+slow LV is called the \fBorigin LV\fP. Due to requirements from dm-cache
+(the kernel driver), LVM further splits the cache pool LV into two
+devices - the \fBcache data LV\fP and \fBcache metadata LV\fP. The cache
+data LV is where copies of data blocks are kept from the
+origin LV to increase speed. The cache metadata LV holds the
+accounting information that specifies where data blocks are stored (e.g.
+on the origin LV or on the cache data LV). Users should be familiar with
+these LVs if they wish to create the best and most robust cached
+logical volumes.
+
+.SS Cache Terms
+.nf
+origin LV OriginLV large slow LV
+cache data LV CacheDataLV small fast LV for cache pool data
+cache metadata LV CacheMetaLV small fast LV for cache pool metadata
+cache pool LV CachePoolLV CacheDataLV + CacheMetaLV
+cache LV CacheLV OriginLV + CachePoolLV
+.fi
+
+.SS Cache Steps
+The steps to create a logical volume of \fIcache\fP type are as follows:
+.TP
+0.
+Create an LV or identify an existing LV to be the origin LV.
+.TP
+1.
+Create the cache data LV. The size of this LV is the size of the cache
+and will be reported as the size of the cache pool LV.
+.TP
+2.
+Create the cache metadata LV.
+The size of this LV should be 1000 times smaller than the cache data LV
+with a minimum size of 8MiB.
+.TP
+3.
+Create the cache pool LV by combining the cache data LV (from step 1)
+and cache metadata LV (from step 2). When performing this step,
+behavioral characteristics of the cache pool LV can be set.
+The name of the cache pool LV takes the name of the cache data LV and
+the cache data LV and cache metadata LV are renamed
+to CachePoolLV_cdata and CachePoolLV_cmeta.
+.TP
+4.
+Create a cache LV by linking the cache pool LV to the origin LV.
+The user accessible cache LV takes the name of the origin LV,
+while the origin LV becomes a hidden LV with the name
+OriginLV_corig. Users can perform this step while the origin LV
+is in use.
+
+.P
+The steps above represent the best way to create a cache LV.
+They provide the most options and have the ability to create the
+most robust logical volumes. The examples below illustrate how these
+steps might be used in practice.
+
+.SS Cache Commands
+.nf
+0. create OriginLV
+lvcreate -L LargeSize -n OriginLV VG SlowPVs
+
+1. create CacheDataLV
+lvcreate -L CacheSize -n CacheDataLV VG FastPVs
+
+2. create CacheMetaLV
+lvcreate -L MetaSize -n CacheMetaLV VG FastPVs
+
+3. create CachePoolLV
+lvconvert --type cache-pool --poolmetadata VG/CacheMetaLV VG/CacheDataLV
+CachePoolLV takes the name of CacheDataLV.
+CacheDataLV is renamed CachePoolLV_cdata and becomes hidden.
+CacheMetaLV is renamed CachePoolLV_cmeta and becomes hidden.
+
+4. create CacheLV
+lvconvert --type cache --cachepool VG/CachePoolLV VG/OriginLV
+CacheLV takes the name of OriginLV.
+OriginLV is renamed OriginLV_corig and becomes hidden.
+.fi
+
+.SS Cache Examples
+
+.B Example 1:
+Creating a simple cache LV.
+.br
+
+.nf
+0. Create the origin LV
+# lvcreate -L 10G -n lvx vg /dev/slow_dev
+
+1. Create a cache data LV
+# lvcreate -L 1G -n lvx_cache vg /dev/fast_dev
+
+2. Create a cache metadata LV (~1/1000th size of CacheDataLV or 8MiB)
+# lvcreate -L 8M -n lvx_cache_meta vg /dev/fast_dev
+
+3. Create a cache pool LV, combining cache data LV and cache metadata LV
+# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
+ vg/lvx_cache
+
+4. Create a cached LV by combining the cache pool LV and origin LV
+# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
+.fi
+
+.B Example 2:
+Creating a cache LV with a fault tolerant cache pool LV.
+
+Users who are concerned about the possibility of failures in their fast devices
+that could lead to data loss might consider making their cache pool sub-LVs
+redundant. Example 2 illustrates how to do that. Note that only steps
+1 & 2 change.
+
+.nf
+0. Create an origin LV we wish to cache
+# lvcreate -L 10G -n lvx vg /dev/slow_devs
+
+1. Create a 2-way RAID1 cache data LV
+# lvcreate --type raid1 -m 1 -L 1G -n lvx_cache vg \\
+ /dev/fast1 /dev/fast2
+
+2. Create a 2-way RAID1 cache metadata LV
+# lvcreate --type raid1 -m 1 -L 8M -n lvx_cache_meta vg \\
+ /dev/fast1 /dev/fast2
+
+3. Create a cache pool LV combining cache data LV and cache metadata LV
+# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
+ vg/lvx_cache
+
+4. Create a cached LV by combining the cache pool LV and origin LV
+# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
+.fi
+
+.B Example 3:
+Creating a simple cache LV with \fIwritethough\fP caching.
+
+Some users wish to ensure that any data written will be stored both in the
+cache pool LV and on the origin LV. The loss of a device associated with
+the cache pool LV in this case would not mean the loss of any data. When
+combining the cache data LV and the cache metadata LV to form the cache pool
+LV, properties of the cache can be specified - in this case,
+\fIwritethrough\fP vs. \fIwriteback\fP. Note that only step 3 is affected
+in this case.
+
+.nf
+0. Create an origin LV we wish to cache (yours may already exist)
+# lvcreate -L 10G -n lvx vg /dev/slow
+
+1. Create a cache data LV
+# lvcreate -L 1G -n lvx_cache vg /dev/fast
+
+2. Create a cache metadata LV
+# lvcreate -L 8M -n lvx_cache_meta vg /dev/fast
+
+3. Create a cache pool LV specifying cache mode "writethrough"
+# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
+ --cachemode writethrough vg/lvx_cache
+
+4. Create a cache LV by combining the cache pool LV and origin LV
+# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
+.fi
+
+.SS Removing Cache Logical Volumes
+If you wish to remove all logical volumes associated with a cache
+LV, you must remove both top-level, user-visible devices.
+The cache metadata LV and cache data LV cannot be removed
+directly. If only the cache pool LV is specfied for removal, any cached
+blocks not yet on the origin LV will be flush, the cache pool LV will be
+removed, and the now un-cached origin LV will remain. If the user
+specifies a cache LV for removal, then the origin LV is
+removed and only the cache pool LV will remain. The cache pool LV can then
+be used to create another cache LV with a different origin LV if desired.
+
+When users intend to remove all logical volumes associated with a
+cache LV, it is generally better to start with the origin LV and then
+remove the cache pool LV. If the operations are performed in the
+reverse order, the user will have to wait for the contents of the
+cache pool LV to be flushed before the origin LV is removed. This
+could take some time.
+
+.SH SEE ALSO
+.BR lvm.conf (5),
+.BR lvchange (8),
+.BR lvcreate (8),
+.BR lvdisplay (8),
+.BR lvextend (8),
+.BR lvremove (8),
+.BR lvrename (8),
+.BR lvresize (8),
+.BR lvs (8),
+.BR vgchange (8),
+.BR vgmerge (8),
+.BR vgreduce (8),
+.BR vgsplit (8)
10 years
master - cleanup: device extent_size first
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=91284bd9b913f7...
Commit: 91284bd9b913f74a0071082d542c3c09d11524f2
Parent: 58777756e8453188d9d0aeb906bb74666e5bbecc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun May 18 20:08:07 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 18 20:08:07 2014 +0200
cleanup: device extent_size first
---
lib/metadata/lv_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6a24873..0eaa719 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3560,7 +3560,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
if (fcmd == FSADM_CMD_RESIZE) {
if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64 "K",
- (uint64_t) lp->extents * vg->extent_size / 2) < 0) {
+ (uint64_t) lp->extents * (vg->extent_size / 2)) < 0) {
log_error("Couldn't generate new LV size string");
return 0;
}
10 years
master - debug: backtrace error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=58777756e84531...
Commit: 58777756e8453188d9d0aeb906bb74666e5bbecc
Parent: b73a78675576c562b8bf510d16dab8a35bf4cb02
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun May 18 20:07:24 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 18 20:07:24 2014 +0200
debug: backtrace error path
Add backtrace for 'n' answer.
---
lib/metadata/lv_manip.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fa08c39..6a24873 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3166,9 +3166,10 @@ int lv_extend(struct logical_volume *lv,
/* FIXME Support --force */
if (yes_no_prompt("Do full resync of extended "
"portion of %s/%s? [y/n]: ",
- lv->vg->name, lv->name) == 'y')
- goto out;
- r = 0;
+ lv->vg->name, lv->name) == 'n') {
+ r = 0;
+ goto_out;
+ }
goto out;
}
10 years
master - man: lvmcache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b73a78675576c5...
Commit: b73a78675576c562b8bf510d16dab8a35bf4cb02
Parent: 11bedf1baf6dbc48c7abf9a14f8584d996d00a59
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 15 12:06:18 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 15 12:13:24 2014 +0200
man: lvmcache
Migrate cache description into man(7) entry
(like lvmthin).
---
WHATS_NEW | 1 +
man/Makefile.in | 11 ++-
man/lvm.8.in | 189 +---------------------------------------------------
spec/packages.inc | 1 +
4 files changed, 13 insertions(+), 189 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5900bc6..72834a8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Move cache description from lvm(8) to lvmcache(7) man page.
Display skipped prompt in silent mode.
Make reporting commands show help about possible sort keys on '-O help'.
Add metadata_percent to lvs_cols.
diff --git a/man/Makefile.in b/man/Makefile.in
index c6a27d0..dd59555 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -41,6 +41,7 @@ LVMETAD =
endif
MAN5=lvm.conf.5
+MAN7=
MAN8=lvm-dumpconfig.8 \
lvchange.8 lvconvert.8 lvcreate.8 lvdisplay.8 lvextend.8 lvm.8 \
lvmchange.8 lvmconf.8 lvmdiskscan.8 lvmdump.8 lvmsadc.8 lvmsar.8 \
@@ -61,10 +62,12 @@ ifeq ("@BUILD_CMIRRORD@", "yes")
MAN8CLUSTER+=cmirrord.8
endif
+ifneq ("@CACHE@", "none")
+ MAN7+=lvmcache.7
+endif
+
ifneq ("@THIN@", "none")
- MAN7=lvmthin.7
-else
- MAN7=
+ MAN7+=lvmthin.7
endif
MAN8DM=dmsetup.8 $(DMEVENTDMAN)
@@ -75,7 +78,7 @@ MAN8DIR=$(mandir)/man8
MAN8SYSTEMD_GENERATORS=lvm2-activation-generator.8
CLEAN_TARGETS=$(MAN5) $(MAN7) $(MAN8) $(MAN8CLUSTER) $(FSADMMAN) $(BLKDEACTIVATEMAN) $(DMEVENTDMAN) $(MAN8DM)
-DISTCLEAN_TARGETS=fsadm.8 clvmd.8 cmirrord.8 dmeventd.8 lvmthin.7 blkdeactivate.8
+DISTCLEAN_TARGETS=fsadm.8 clvmd.8 cmirrord.8 dmeventd.8 lvmcache.7 lvmthin.7 blkdeactivate.8
include $(top_builddir)/make.tmpl
diff --git a/man/lvm.8.in b/man/lvm.8.in
index e1063c6..41223b0 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -406,191 +406,8 @@ a command.
Some logical volume types are simple to create and can be done with a
single \fBlvcreate\fP(8) command. The linear and striped logical
volume types are an example of this. Other logical volume types may
-require more than one command to create. The cache and thin provisioning
-types are examples of this.
-
-.br
-.SS Cache
-The \fIcache\fP logical volume type uses a small and fast LV to improve
-the performance of a large and slow LV. It does this by storing the
-frequently used blocks on the faster LV.
-LVM refers to the small fast LV as a \fBcache pool LV\fP. The large
-slow LV is called the \fBorigin LV\fP. Due to requirements from dm-cache
-(the kernel driver), LVM further splits the cache pool LV into two
-devices - the \fBcache data LV\fP and \fBcache metadata LV\fP. The cache
-data LV is where copies of data blocks are kept from the
-origin LV to increase speed. The cache metadata LV holds the
-accounting information that specifies where data blocks are stored (e.g.
-on the origin LV or on the cache data LV). Users should be familiar with
-these LVs if they wish to create the best and most robust cached
-logical volumes.
-
-.SS Cache Terms
-.nf
-origin LV OriginLV large slow LV
-cache data LV CacheDataLV small fast LV for cache pool data
-cache metadata LV CacheMetaLV small fast LV for cache pool metadata
-cache pool LV CachePoolLV CacheDataLV + CacheMetaLV
-cache LV CacheLV OriginLV + CachePoolLV
-.fi
-
-.SS Cache Steps
-The steps to create a logical volume of \fIcache\fP type are as follows:
-.TP
-0.
-Create an LV or identify an existing LV to be the origin LV.
-.TP
-1.
-Create the cache data LV. The size of this LV is the size of the cache
-and will be reported as the size of the cache pool LV.
-.TP
-2.
-Create the cache metadata LV.
-The size of this LV should be 1000 times smaller than the cache data LV
-with a minimum size of 8MiB.
-.TP
-3.
-Create the cache pool LV by combining the cache data LV (from step 1)
-and cache metadata LV (from step 2). When performing this step,
-behavioral characteristics of the cache pool LV can be set.
-The name of the cache pool LV takes the name of the cache data LV and
-the cache data LV and cache metadata LV are renamed
-to CachePoolLV_cdata and CachePoolLV_cmeta.
-.TP
-4.
-Create a cache LV by linking the cache pool LV to the origin LV.
-The user accessible cache LV takes the name of the origin LV,
-while the origin LV becomes a hidden LV with the name
-OriginLV_corig. Users can perform this step while the origin LV
-is in use.
-
-.P
-The steps above represent the best way to create a cache LV.
-They provide the most options and have the ability to create the
-most robust logical volumes. The examples below illustrate how these
-steps might be used in practice.
-
-.SS Cache Commands
-.nf
-0. create OriginLV
-lvcreate -L LargeSize -n OriginLV VG SlowPVs
-
-1. create CacheDataLV
-lvcreate -L CacheSize -n CacheDataLV VG FastPVs
-
-2. create CacheMetaLV
-lvcreate -L MetaSize -n CacheMetaLV VG FastPVs
-
-3. create CachePoolLV
-lvconvert --type cache-pool --poolmetadata VG/CacheMetaLV VG/CacheDataLV
-CachePoolLV takes the name of CacheDataLV.
-CacheDataLV is renamed CachePoolLV_cdata and becomes hidden.
-CacheMetaLV is renamed CachePoolLV_cmeta and becomes hidden.
-
-4. create CacheLV
-lvconvert --type cache --cachepool VG/CachePoolLV VG/OriginLV
-CacheLV takes the name of OriginLV.
-OriginLV is renamed OriginLV_corig and becomes hidden.
-.fi
-
-.SS Cache Examples
-
-.B Example 1:
-Creating a simple cache LV.
-.br
-
-.nf
-0. Create the origin LV
-# lvcreate -L 10G -n lvx vg /dev/slow_dev
-
-1. Create a cache data LV
-# lvcreate -L 1G -n lvx_cache vg /dev/fast_dev
-
-2. Create a cache metadata LV (~1/1000th size of CacheDataLV or 8MiB)
-# lvcreate -L 8M -n lvx_cache_meta vg /dev/fast_dev
-
-3. Create a cache pool LV, combining cache data LV and cache metadata LV
-# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
- vg/lvx_cache
-
-4. Create a cached LV by combining the cache pool LV and origin LV
-# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
-.fi
-
-.B Example 2:
-Creating a cache LV with a fault tolerant cache pool LV.
-
-Users who are concerned about the possibility of failures in their fast devices
-that could lead to data loss might consider making their cache pool sub-LVs
-redundant. Example 2 illustrates how to do that. Note that only steps
-1 & 2 change.
-
-.nf
-0. Create an origin LV we wish to cache
-# lvcreate -L 10G -n lvx vg /dev/slow_devs
-
-1. Create a 2-way RAID1 cache data LV
-# lvcreate --type raid1 -m 1 -L 1G -n lvx_cache vg \\
- /dev/fast1 /dev/fast2
-
-2. Create a 2-way RAID1 cache metadata LV
-# lvcreate --type raid1 -m 1 -L 8M -n lvx_cache_meta vg \\
- /dev/fast1 /dev/fast2
-
-3. Create a cache pool LV combining cache data LV and cache metadata LV
-# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
- vg/lvx_cache
-
-4. Create a cached LV by combining the cache pool LV and origin LV
-# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
-.fi
-
-.B Example 3:
-Creating a simple cache LV with \fIwritethough\fP caching.
-
-Some users wish to ensure that any data written will be stored both in the
-cache pool LV and on the origin LV. The loss of a device associated with
-the cache pool LV in this case would not mean the loss of any data. When
-combining the cache data LV and the cache metadata LV to form the cache pool
-LV, properties of the cache can be specified - in this case,
-\fIwritethrough\fP vs. \fIwriteback\fP. Note that only step 3 is affected
-in this case.
-
-.nf
-0. Create an origin LV we wish to cache (yours may already exist)
-# lvcreate -L 10G -n lvx vg /dev/slow
-
-1. Create a cache data LV
-# lvcreate -L 1G -n lvx_cache vg /dev/fast
-
-2. Create a cache metadata LV
-# lvcreate -L 8M -n lvx_cache_meta vg /dev/fast
-
-3. Create a cache pool LV specifying cache mode "writethrough"
-# lvconvert --type cache-pool --poolmetadata vg/lvx_cache_meta \\
- --cachemode writethrough vg/lvx_cache
-
-4. Create a cache LV by combining the cache pool LV and origin LV
-# lvconvert --type cache --cachepool vg/lvx_cache vg/lvx
-.fi
-
-.SS Removing Cache Logical Volumes
-If you wish to remove all logical volumes associated with a cache
-LV, you must remove both top-level, user-visible devices.
-The cache metadata LV and cache data LV cannot be removed
-directly. If only the cache pool LV is specfied for removal, any cached
-blocks not yet on the origin LV will be flush, the cache pool LV will be
-removed, and the now un-cached origin LV will remain. If the user
-specifies a cache LV for removal, then the origin LV is
-removed and only the cache pool LV will remain. The cache pool LV can then
-be used to create another cache LV with a different origin LV if desired.
-
-When users intend to remove all logical volumes associated with a
-cache LV, it is generally better to start with the origin LV and then
-remove the cache pool LV. If the operations are performed in the
-reverse order, the user will have to wait for the contents of the
-cache pool LV to be flushed before the origin LV is removed. This
-could take some time.
+require more than one command to create. The cache (\fBlvmcache\fP(7))
+and thin provisioning (\fBlvmthin\fP(7)) types are examples of this.
.SH DIAGNOSTICS
All tools return a status code of zero on success or non-zero on failure.
@@ -600,6 +417,8 @@ All tools return a status code of zero on success or non-zero on failure.
.I $HOME/.lvm_history
.SH SEE ALSO
.BR lvm.conf (5),
+.BR lvmcache (7),
+.BR lvmthin (7),
.BR lvm\ dumpconfig (8),
.BR clvmd (8),
.BR lvchange (8),
diff --git a/spec/packages.inc b/spec/packages.inc
index 16b90e0..5999ab7 100644
--- a/spec/packages.inc
+++ b/spec/packages.inc
@@ -83,6 +83,7 @@ fi
%{_sbindir}/lvmetad
%endif
%{_mandir}/man5/lvm.conf.5.gz
+%{_mandir}/man7/lvmcache.7.gz
%{_mandir}/man7/lvmthin.7.gz
%{_mandir}/man8/fsadm.8.gz
%{_mandir}/man8/lvchange.8.gz
10 years
master - display: print skipped prompt
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11bedf1baf6dbc...
Commit: 11bedf1baf6dbc48c7abf9a14f8584d996d00a59
Parent: 76c06c72523201bdb478bd1735b2fcfbe49d3d38
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 15 11:58:49 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 15 12:11:35 2014 +0200
display: print skipped prompt
Since decisions in the silent mode may not be always obvious,
print skipped prompt with answer 'n'.
Also document '-qq' behaviour (single -q only shuts
logging, while -qq sets silent mode).
---
WHATS_NEW | 1 +
lib/display/display.c | 10 ++++++----
man/lvm.8.in | 1 +
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 090e914..5900bc6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Display skipped prompt in silent mode.
Make reporting commands show help about possible sort keys on '-O help'.
Add metadata_percent to lvs_cols.
Take account of parity areas with alloc anywhere in _calc_required_extents.
diff --git a/lib/display/display.c b/lib/display/display.c
index b808f25..3c47aa8 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -880,9 +880,6 @@ char yes_no_prompt(const char *prompt, ...)
int c = 0, ret = 0;
va_list ap;
- if (silent_mode())
- return 'n';
-
sigint_allow();
do {
if (c == '\n' || !c) {
@@ -890,6 +887,11 @@ char yes_no_prompt(const char *prompt, ...)
vfprintf(stderr, prompt, ap);
va_end(ap);
fflush(stderr);
+ if (silent_mode()) {
+ fputc('n', stderr);
+ ret = 'n';
+ break;
+ }
ret = 0;
}
@@ -911,7 +913,7 @@ char yes_no_prompt(const char *prompt, ...)
sigint_restore();
if (c != '\n')
- fprintf(stderr, "\n");
+ fputc('\n', stderr);
return ret;
}
diff --git a/man/lvm.8.in b/man/lvm.8.in
index e273935..e1063c6 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -174,6 +174,7 @@ Overrides config file setting.
.BR \-q ", " \-\-quiet
Suppress output and log messages.
Overrides \fB\-d\fP and \fB\-v\fP.
+Repeat once to also suppress any prompts with answer 'no'.
.TP
.BR \-\-yes
Don't prompt for confirmation interactively but instead always assume the
10 years