summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2016-10-18 12:58:22 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2016-11-11 16:58:16 +0100
commitd8fc4d093ee125e3667046b892c14e4a920a8da0 (patch)
treee9ea622344fef527dc87a126124f806aa17825b7
parente54cce245f2829107e1ed09221bca7ff7921d98b (diff)
downloadlvm2-d8fc4d093ee125e3667046b892c14e4a920a8da0.tar.gz
conf: support zero for missing_stripe_filler
Make it easier to replace missing segments with 'zero' returning target - otherwise user would have to create some extra target to provide zeros as /dev/zero can't be used (not a block device). Also break code loop when segment is found and make it an INTERNAL_ERROR where it's missing.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/activate/dev_manager.c24
-rw-r--r--lib/commands/toolcontext.c3
-rw-r--r--lib/config/config_settings.h3
4 files changed, 21 insertions, 10 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 2af299211..57c382f74 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.168 -
====================================
+ Missing stripe filler now could be also 'zero'.
lvconvert --repair accepts --interval and --background option.
More efficiently prepare _rmeta devices when creating a new raid LV.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 2dc0fd801..dcea359bf 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2250,8 +2250,8 @@ bad:
return NULL;
}
-static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
- struct lv_segment *seg, int s)
+static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *dtree,
+ struct lv_segment *seg, int s, int use_zero)
{
char *dlid, *name;
char errid[32];
@@ -2262,13 +2262,15 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
uint64_t size = (uint64_t) seg->len * seg->lv->vg->extent_size;
dm_list_iterate_items(seg_i, &seg->lv->segments) {
- if (seg == seg_i)
+ if (seg == seg_i) {
segno = i;
+ break;
+ }
++i;
}
if (segno < 0) {
- log_error("_add_error_device called with bad segment");
+ log_error(INTERNAL_ERROR "_add_error_or_zero_device called with bad segment.");
return NULL;
}
@@ -2291,8 +2293,13 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
/* Create new node */
if (!(node = dm_tree_add_new_dev(dtree, name, dlid, 0, 0, 0, 0, 0)))
return_NULL;
- if (!dm_tree_node_add_error_target(node, size))
- return_NULL;
+
+ if (use_zero) {
+ if (!dm_tree_node_add_zero_target(node, size))
+ return_NULL;
+ } else
+ if (!dm_tree_node_add_error_target(node, size))
+ return_NULL;
} else {
/* Already exists */
if (!dm_tree_add_dev(dtree, info.major, info.minor)) {
@@ -2310,14 +2317,15 @@ static int _add_error_area(struct dev_manager *dm, struct dm_tree_node *node,
{
char *dlid;
uint64_t extent_size = seg->lv->vg->extent_size;
+ int use_zero = !strcmp(dm->cmd->stripe_filler, TARGET_NAME_ZERO) ? 1 : 0;
- if (!strcmp(dm->cmd->stripe_filler, TARGET_NAME_ERROR)) {
+ if (!strcmp(dm->cmd->stripe_filler, TARGET_NAME_ERROR) || use_zero) {
/*
* FIXME, the tree pointer is first field of dm_tree_node, but
* we don't have the struct definition available.
*/
struct dm_tree **tree = (struct dm_tree **) node;
- if (!(dlid = _add_error_device(dm, *tree, seg, s)))
+ if (!(dlid = _add_error_or_zero_device(dm, *tree, seg, s, use_zero)))
return_0;
if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_le(seg, s)))
return_0;
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 002af05e7..bfb7c1b19 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -640,7 +640,8 @@ static int _process_config(struct cmd_context *cmd)
if (!strcmp(cmd->stripe_filler, "/dev/ioerror") &&
stat(cmd->stripe_filler, &st))
cmd->stripe_filler = "error";
- else if (strcmp(cmd->stripe_filler, "error")) {
+ else if (strcmp(cmd->stripe_filler, "error") &&
+ strcmp(cmd->stripe_filler, "zero")) {
if (stat(cmd->stripe_filler, &st)) {
log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
"is invalid,", cmd->stripe_filler);
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 9eed969c1..e0770b66a 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1111,7 +1111,8 @@ cfg(activation_retry_deactivation_CFG, "retry_deactivation", activation_CFG_SECT
cfg(activation_missing_stripe_filler_CFG, "missing_stripe_filler", activation_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_STRIPE_FILLER, vsn(1, 0, 0), NULL, 0, NULL,
"Method to fill missing stripes when activating an incomplete LV.\n"
"Using 'error' will make inaccessible parts of the device return I/O\n"
- "errors on access. You can instead use a device path, in which case,\n"
+ "errors on access. Using 'zero' will return success (and zero) on I/O\n"
+ "You can instead use a device path, in which case,\n"
"that device will be used in place of missing stripes. Using anything\n"
"other than 'error' with mirrored or snapshotted volumes is likely to\n"
"result in data corruption.\n")