Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=52fd66210b120bf1185fb…
Commit: 52fd66210b120bf1185fbbc91b6bc487d99dd33a
Parent: 84aca4201e3588159e75fa8e047e997c2fad13d2
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Oct 27 22:42:00 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Oct 27 22:53:43 2017 +0100
metadata: Avoid accessing ignored metadata.
When an ignored metadata area gets flagged for use again, make sure the
code doesn't try to parse its old metadata. Firstly by trying to detect
this situation and skipping the read (while still remembering the
position reached in the circular buffer), and secondly by clearing the
invalid live metadata location on disk as a precaution when subsequently
writing out the precommitted metadata.
Problems showed up when a metadata area in one VG got moved to
another VG in ignored state (still holding metadata for the original
VG) and then later got brought into use in the new VG - only the header
should be read in this case, not any of the metadata content.
---
WHATS_NEW | 1 +
lib/format_text/format-text.c | 28 ++++++++++++++++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3e13d8c..4d1a6a8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Avoid reading ignored metadata when mda gets used again.
Fix detection of moved PVs in vgsplit. (2.02.175)
Ignore --stripes/--stripesize on RAID takeover
Improve used paths for generated systemd units and init shells.
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 3e1ca19..797ead0 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -414,12 +414,15 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
struct lvmcache_vgsummary vgsummary_orphan = {
.vgname = FMT_TEXT_ORPHAN_VG_NAME,
};
+ int rlocn_was_ignored;
memcpy(&vgsummary_orphan.vgid, FMT_TEXT_ORPHAN_VG_NAME, sizeof(FMT_TEXT_ORPHAN_VG_NAME));
rlocn = mdah->raw_locns; /* Slot 0 */
rlocn_precommitted = rlocn + 1; /* Slot 1 */
+ rlocn_was_ignored = rlocn_is_ignored(rlocn);
+
/* Should we use precommitted metadata? */
if (*precommitted && rlocn_precommitted->size &&
(rlocn_precommitted->offset != rlocn->offset)) {
@@ -438,6 +441,12 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
if (!*vgname)
return rlocn;
+ /*
+ * If live rlocn has ignored flag, data will be out-of-date so skip further checks.
+ */
+ if (rlocn_was_ignored)
+ return rlocn;
+
/* FIXME Loop through rlocns two-at-a-time. List null-terminated. */
/* FIXME Ignore if checksum incorrect!!! */
if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
@@ -448,8 +457,9 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
(isspace(vgnamebuf[len]) || vgnamebuf[len] == '{'))
return rlocn;
- log_debug_metadata("Volume group name found in metadata on %s at %" PRIu64 " does "
+ log_debug_metadata("Volume group name found in %smetadata on %s at %" PRIu64 " does "
"not match expected name %s.",
+ *precommitted ? "precommitted " : "",
dev_name(dev_area->dev), dev_area->start + rlocn->offset, vgname);
bad:
@@ -750,6 +760,14 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
mdah->raw_locns[2].size = 0;
mdah->raw_locns[2].checksum = 0;
rlocn = &mdah->raw_locns[0];
+ } else if (precommit && rlocn_is_ignored(rlocn) && !mda_is_ignored(mda)) {
+ /*
+ * If precommitting into a previously-ignored mda, wipe the live rlocn
+ * as a precaution so that nothing can use it by mistake.
+ */
+ mdah->raw_locns[0].offset = 0;
+ mdah->raw_locns[0].size = 0;
+ mdah->raw_locns[0].checksum = 0;
}
if (precommit)
@@ -766,12 +784,14 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
rlocn->offset = mdac->rlocn.offset;
rlocn->size = mdac->rlocn.size;
rlocn->checksum = mdac->rlocn.checksum;
- log_debug_metadata("%sCommitting %s metadata (%u) to %s header at %"
- PRIu64, precommit ? "Pre-" : "", vg->name, vg->seqno,
+ log_debug_metadata("%sCommitting %s %smetadata (%u) to %s header at %"
+ PRIu64, precommit ? "Pre-" : "", vg->name,
+ mda_is_ignored(mda) ? "(ignored) " : "", vg->seqno,
dev_name(mdac->area.dev), mdac->area.start);
} else
- log_debug_metadata("Wiping pre-committed %s metadata from %s "
+ log_debug_metadata("Wiping pre-committed %s %smetadata from %s "
"header at %" PRIu64, vg->name,
+ mda_is_ignored(mda) ? "(ignored) " : "",
dev_name(mdac->area.dev), mdac->area.start);
rlocn_set_ignored(mdah->raw_locns, mda_is_ignored(mda));
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4b0f6829f63d36b473f66…
Commit: 4b0f6829f63d36b473f6670a41ac7521ff82674d
Parent: fdcc709ed0e5051f471ee64ac51f6c8e2ed941fc
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Oct 26 17:47:13 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Oct 26 17:47:13 2017 +0100
dmsetup: Add unknown device error to dmsetup status.
Treat status the same way as info if provided device name doesn't exist.
---
WHATS_NEW_DM | 1 +
tools/dmsetup.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index b0dd01b..6475fbd 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.145 -
===================================
+ Issue a specific error with dmsetup status if device is unknown.
Fix RT_LIBS reference in generated libdevmapper.pc for pkg-config
Version 1.02.144 - 6th October 2017
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 661910f..53097b3 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -2431,9 +2431,14 @@ static int _status(CMD_ARGS)
if (!_task_run(dmt))
goto_out;
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!dm_task_get_info(dmt, &info))
goto_out;
+ if (!info.exists) {
+ fprintf(stderr, "Device does not exist.\n");
+ goto_out;
+ }
+
if (!name)
name = dm_task_get_name(dmt);
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4a3884245d02bcdad41e4…
Commit: 4a3884245d02bcdad41e4dd99f9201721c60158f
Parent: b765288bf242bbbdc93ef2f76ae4d3f7bdeb5868
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Oct 26 17:16:23 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Oct 26 17:16:23 2017 +0200
raid: ignore --stripes/--stripesize on takeover
Converting from one raid level to another, no changes
of stripes or stripesize can be requested because those
are subject to reshaping. I.e. the process requires to
takeover first and secondly request raid algorithm,
stripe or stripesize changes.
Ignore any related changes display warninngs
and proceed with the takeover.
Without this patch, a takeover requesting
stripesize change causes data corruption!
---
lib/metadata/raid_manip.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index f065a4c..f48169e 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -502,7 +502,6 @@ static int _reset_flags_passed_to_kernel(struct logical_volume *lv, int *flags_r
return 0;
if (slv->status & LV_RESHAPE_DELTA_DISKS_MINUS) {
- *flags_reset = 1;
slv->status |= LV_REMOVE_AFTER_RESHAPE;
seg_metalv(seg, s)->status |= LV_REMOVE_AFTER_RESHAPE;
}
@@ -6293,6 +6292,17 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
r = 0;
}
+ /* Can't reshape stripes or stripe size when performing a takeover! */
+ if (!_is_same_level(seg_from->segtype, *segtype_to)) {
+ if (stripes && stripes != _data_rimages_count(seg_from, seg_from->area_count))
+ log_warn("WARNING: ignoring --stripes option on takeover of %s (reshape afterwards).",
+ display_lvname(seg_from->lv));
+
+ if (!seg_is_raid1(seg_from) && new_stripe_size_supplied)
+ log_warn("WARNING: ignoring --stripesize option on takeover of %s (reshape afterwards).",
+ display_lvname(seg_from->lv));
+ }
+
if (r &&
!yes &&
strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */
@@ -6465,11 +6475,20 @@ int lv_raid_convert(struct logical_volume *lv,
return 0;
}
+ /*
+ * stripes and stripe_size can only be changed via reshape, not in a takeover!
+ *
+ * Ignore any of them here unless a takeover from raid1 to
+ * raid4/5 is requested when stripe size may be defined.
+ */
+ stripes = _data_rimages_count(seg, seg->area_count);
+ stripe_size = seg_is_raid1(seg) ? stripe_size : seg->stripe_size;
+
takeover_fn = _get_takeover_fn(first_seg(lv), new_segtype, new_image_count);
/* Exit without doing activation checks if the combination isn't possible */
if (_takeover_not_possible(takeover_fn))
- return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, new_stripes, stripe_size,
+ return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, stripes, stripe_size,
region_size, allocate_pvs);
/*
@@ -6498,7 +6517,7 @@ int lv_raid_convert(struct logical_volume *lv,
lv->status &= ~LV_RESHAPE;
- return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, new_stripes, stripe_size,
+ return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, stripes, stripe_size,
region_size, allocate_pvs);
}