master - man: add note about 'lastlog' built-in command
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94141c7797caab...
Commit: 94141c7797caabe23607a554fa7c6f44a4d570fc
Parent: 5397837a9f334fa91973e36acf38655a19b88b28
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 25 15:05:08 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 25 15:05:08 2016 +0200
man: add note about 'lastlog' built-in command
---
WHATS_NEW | 1 +
man/lvm.8.in | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ca12e8c..f5b8306 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.162 -
=================================
+ Add note about lastlog built-in command to lvm man page.
Fix unrecognised segtype flag message.
lvconvert reuse cachepool metadade now ONLY with -Zn and clear otherwise.
Enabled lvconvert --uncache to work with partial VG.
diff --git a/man/lvm.8.in b/man/lvm.8.in
index f0d094d..0215783 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -68,6 +68,10 @@ Display recognised metadata formats.
.B help
Display the help text.
.TP
+.B lastlog
+Display log report of last command run in LVM shell
+if command log reporting is enabled.
+.TP
.B lvpoll
Complete lvmpolld operations (Internal command).
.TP
6 years, 8 months
master - segtype: Fix unrecognised flag message.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5397837a9f334f...
Commit: 5397837a9f334fa91973e36acf38655a19b88b28
Parent: e4e29add685fce5473bec3c23013a1ddb72fd4b6
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Jul 25 12:56:25 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Jul 25 12:59:50 2016 +0100
segtype: Fix unrecognised flag message.
Show in hex not decimal.
---
WHATS_NEW | 1 +
lib/metadata/segtype.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0d6d010..ca12e8c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.162 -
=================================
+ Fix unrecognised segtype flag message.
lvconvert reuse cachepool metadade now ONLY with -Zn and clear otherwise.
Enabled lvconvert --uncache to work with partial VG.
diff --git a/lib/metadata/segtype.c b/lib/metadata/segtype.c
index 2b060da..35823d9 100644
--- a/lib/metadata/segtype.c
+++ b/lib/metadata/segtype.c
@@ -47,7 +47,7 @@ struct segment_type *get_segtype_from_flag(struct cmd_context *cmd, uint64_t fla
if (flag & segtype->flags)
return segtype;
- log_error(INTERNAL_ERROR "Unrecognised segment type flag 0x%" PRIu64, flag);
+ log_error(INTERNAL_ERROR "Unrecognised segment type flag 0x%" PRIx64, flag);
return NULL;
}
6 years, 8 months
master - conf: regenerate example.conf.in
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e4e29add685fce...
Commit: e4e29add685fce5473bec3c23013a1ddb72fd4b6
Parent: 3bc1adc4048def6dd58f1232bea1f388f9456ef9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 25 13:54:59 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 25 13:54:59 2016 +0200
conf: regenerate example.conf.in
---
conf/example.conf.in | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 8b79d7d..1dcbf52 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -377,6 +377,12 @@ allocation {
# The default setting changed in version 2.02.85.
mirror_logs_require_separate_pvs = 0
+ # Configuration option allocation/raid_stripe_all_devices.
+ # Stripe across all PVs when RAID stripes are not specified.
+ # If enabled, all PVs in the VG or on the command line are used for raid0/4/5/6/10
+ # when the command does not specify the number of stripes to use.
+ raid_stripe_all_devices = 0
+
# Configuration option allocation/cache_pool_metadata_require_separate_pvs.
# Cache pool metadata and data will always use different PVs.
cache_pool_metadata_require_separate_pvs = 0
@@ -472,13 +478,6 @@ allocation {
# Default physical extent size in KiB to use for new VGs.
# This configuration option has an automatic default value.
# physical_extent_size = 4096
-
- # Configuration option striping across all PVs when RAID stripes are not specified.
- # If enabled, all PVs in the VG or on the command line are used for raid0/4/5/6/10
- # when the command does not specify the number of stripes to use.
- #
- # This configuration option has an automatic default value.
- # raid_stripe_all_devices = 0
}
# Configuration section log.
6 years, 8 months
master - raid_manip: Some validation functions.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3bc1adc4048def...
Commit: 3bc1adc4048def6dd58f1232bea1f388f9456ef9
Parent: ea543b5c6f2f7fd9e7c54d8e33abc32049aafc6d
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sun Jul 24 01:40:24 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sun Jul 24 01:40:24 2016 +0100
raid_manip: Some validation functions.
---
lib/metadata/raid_manip.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index ee05ae7..0364f2f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -33,6 +33,40 @@ static int _check_restriping(uint32_t new_stripes, struct logical_volume *lv)
return 1;
}
+/* Check that all lv has segments have exactly the required number of areas */
+static int _check_num_areas_in_lv_segments(struct logical_volume *lv, unsigned num_areas)
+{
+ struct lv_segment *seg;
+
+ dm_list_iterate_items(seg, &lv->segments)
+ if (seg->area_count != num_areas) {
+ log_error("For this operation LV %s needs exactly %u data areas per segment.",
+ display_lvname(lv), num_areas);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Ensure region size exceeds the minimum for lv */
+static void _ensure_min_region_size(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = first_seg(lv);
+ uint32_t min_region_size, region_size;
+
+ /* MD's bitmap is limited to tracking 2^21 regions */
+ min_region_size = lv->size / (1 << 21);
+ region_size = seg->region_size;
+
+ while (region_size < min_region_size)
+ region_size *= 2;
+
+ if (seg->region_size != region_size) {
+ log_very_verbose("Setting region_size to %u for %s", seg->region_size, display_lvname(lv));
+ seg->region_size = region_size;
+ }
+}
+
/*
* Check for maximum number of raid devices.
* Constrained by kernel MD maximum device limits _and_ dm-raid superblock
@@ -41,13 +75,38 @@ static int _check_restriping(uint32_t new_stripes, struct logical_volume *lv)
static int _check_max_raid_devices(uint32_t image_count)
{
if (image_count > DEFAULT_RAID_MAX_IMAGES) {
- log_error("Unable to handle arrays with more than %u devices",
+ log_error("Unable to handle raid arrays with more than %u devices",
DEFAULT_RAID_MAX_IMAGES);
return 0;
}
+
+ return 1;
+}
+
+static int _check_max_mirror_devices(uint32_t image_count)
+{
+ if (image_count > DEFAULT_MIRROR_MAX_IMAGES) {
+ log_error("Unable to handle mirrors with more than %u devices",
+ DEFAULT_MIRROR_MAX_IMAGES);
+ return 0;
+ }
+
return 1;
}
+/*
+ * Fix up LV region_size if not yet set.
+ */
+/* FIXME Check this happens exactly once at the right place. */
+static void _check_and_adjust_region_size(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = first_seg(lv);
+
+ seg->region_size = seg->region_size ? : get_default_region_size(lv->vg->cmd);
+
+ return _ensure_min_region_size(lv);
+}
+
static int _lv_is_raid_with_tracking(const struct logical_volume *lv,
struct logical_volume **tracking)
{
6 years, 8 months
master - raid_manip: Fix stripe_size type to uint32_t.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea543b5c6f2f7f...
Commit: ea543b5c6f2f7fd9e7c54d8e33abc32049aafc6d
Parent: 4a544ae272c172d0ba63096c488688a69f997e98
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sun Jul 24 01:35:04 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sun Jul 24 01:35:04 2016 +0100
raid_manip: Fix stripe_size type to uint32_t.
---
lib/metadata/raid_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 2470532..ee05ae7 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -2171,7 +2171,7 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
int force, \
unsigned new_image_count, \
const unsigned new_stripes, \
- unsigned new_stripe_size, \
+ uint32_t new_stripe_size, \
struct dm_list *allocate_pvs
typedef int (*takeover_fn_t)(TAKEOVER_FN_ARGS);
6 years, 8 months
master - raid_manip: Reorder some functions.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a544ae272c172...
Commit: 4a544ae272c172d0ba63096c488688a69f997e98
Parent: f6acf922e625912e88e064fb03a5188bdcc8bb43
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sun Jul 24 01:31:30 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sun Jul 24 01:31:30 2016 +0100
raid_manip: Reorder some functions.
---
lib/metadata/raid_manip.c | 858 +++++++++++++++++++++++----------------------
1 files changed, 433 insertions(+), 425 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 2dbbbe4..2470532 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -33,6 +33,21 @@ static int _check_restriping(uint32_t new_stripes, struct logical_volume *lv)
return 1;
}
+/*
+ * Check for maximum number of raid devices.
+ * Constrained by kernel MD maximum device limits _and_ dm-raid superblock
+ * bitfield constraints.
+ */
+static int _check_max_raid_devices(uint32_t image_count)
+{
+ if (image_count > DEFAULT_RAID_MAX_IMAGES) {
+ log_error("Unable to handle arrays with more than %u devices",
+ DEFAULT_RAID_MAX_IMAGES);
+ return 0;
+ }
+ return 1;
+}
+
static int _lv_is_raid_with_tracking(const struct logical_volume *lv,
struct logical_volume **tracking)
{
@@ -85,6 +100,37 @@ static int _activate_sublv_preserving_excl(struct logical_volume *top_lv,
return 1;
}
+static int _avoid_pvs_of_lv(struct logical_volume *lv, void *data)
+{
+ struct dm_list *allocate_pvs = (struct dm_list *) data;
+ struct pv_list *pvl;
+
+ dm_list_iterate_items(pvl, allocate_pvs)
+ if (!lv_is_partial(lv) && lv_is_on_pv(lv, pvl->pv))
+ pvl->pv->status |= PV_ALLOCATION_PROHIBITED;
+
+ return 1;
+}
+
+/*
+ * Prevent any PVs holding other image components of @lv from being used for allocation
+ * by setting the internal PV_ALLOCATION_PROHIBITED flag to use it to avoid generating
+ * pv maps for those PVs.
+ */
+static int _avoid_pvs_with_other_images_of_lv(struct logical_volume *lv, struct dm_list *allocate_pvs)
+{
+ return for_each_sub_lv(lv, _avoid_pvs_of_lv, allocate_pvs);
+}
+
+static void _clear_allocation_prohibited(struct dm_list *pvs)
+{
+ struct pv_list *pvl;
+
+ if (pvs)
+ dm_list_iterate_items(pvl, pvs)
+ pvl->pv->status &= ~PV_ALLOCATION_PROHIBITED;
+}
+
/*
* _raid_in_sync
* @lv
@@ -1387,103 +1433,57 @@ int lv_raid_merge(struct logical_volume *image_lv)
}
/*
- * General conversion functions
+ * Deactivate and remove the LVs on removal_lvs list from vg.
*/
-static int _convert_mirror_to_raid1(struct logical_volume *lv,
- const struct segment_type *new_segtype)
+static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *removal_lvs)
{
- uint32_t s;
- struct lv_segment *seg = first_seg(lv);
- struct lv_list lvl_array[seg->area_count], *lvl;
- struct dm_list meta_lvs;
- struct lv_segment_area *meta_areas;
- char *new_name;
+ struct lv_list *lvl;
- dm_list_init(&meta_lvs);
+ dm_list_iterate_items(lvl, removal_lvs)
+ if (!deactivate_lv(vg->cmd, lvl->lv) ||
+ !lv_remove(lvl->lv))
+ return_0;
- if (!_raid_in_sync(lv)) {
- log_error("Unable to convert %s/%s while it is not in-sync",
- lv->vg->name, lv->name);
- return 0;
- }
+ return 1;
+}
- if (!(meta_areas = dm_pool_zalloc(lv->vg->vgmem,
- lv_mirror_count(lv) * sizeof(*meta_areas)))) {
- log_error("Failed to allocate meta areas memory.");
- return 0;
- }
+/*
+ * Allocate metadata devs for all @new_data_devs and link them to list @new_meta_lvs
+ */
+static int _alloc_rmeta_devs_for_rimage_devs(struct logical_volume *lv,
+ struct dm_list *new_data_lvs,
+ struct dm_list *new_meta_lvs,
+ struct dm_list *allocate_pvs)
+{
+ uint32_t a = 0, raid_devs = dm_list_size(new_data_lvs);
+ struct lv_list *lvl, *lvl1, *lvl_array;
- if (!archive(lv->vg))
+ if (!raid_devs)
return_0;
- for (s = 0; s < seg->area_count; s++) {
- log_debug_metadata("Allocating new metadata LV for %s",
- seg_lv(seg, s)->name);
- if (!_alloc_rmeta_for_lv(seg_lv(seg, s), &(lvl_array[s].lv), NULL)) {
- log_error("Failed to allocate metadata LV for %s in %s",
- seg_lv(seg, s)->name, lv->name);
- return 0;
- }
- dm_list_add(&meta_lvs, &(lvl_array[s].list));
- }
-
- log_debug_metadata("Clearing newly allocated metadata LVs");
- if (!_clear_lvs(&meta_lvs)) {
- log_error("Failed to initialize metadata LVs");
- return 0;
- }
-
- if (seg->log_lv) {
- log_debug_metadata("Removing mirror log, %s", seg->log_lv->name);
- if (!remove_mirror_log(lv->vg->cmd, lv, NULL, 0)) {
- log_error("Failed to remove mirror log");
- return 0;
- }
- }
-
- seg->meta_areas = meta_areas;
- s = 0;
-
- dm_list_iterate_items(lvl, &meta_lvs) {
- log_debug_metadata("Adding %s to %s", lvl->lv->name, lv->name);
+ if (!(lvl_array = dm_pool_zalloc(lv->vg->vgmem, raid_devs * sizeof(*lvl_array))))
+ return_0;
- /* Images are known to be in-sync */
- lvl->lv->status &= ~LV_REBUILD;
- first_seg(lvl->lv)->status &= ~LV_REBUILD;
- lv_set_hidden(lvl->lv);
+ dm_list_iterate_items(lvl, new_data_lvs) {
+ log_debug_metadata("Allocating new metadata LV for %s", lvl->lv->name);
- if (!set_lv_segment_area_lv(seg, s, lvl->lv, 0,
- lvl->lv->status)) {
- log_error("Failed to add %s to %s",
- lvl->lv->name, lv->name);
+ if (!_alloc_rmeta_for_lv(lvl->lv, &lvl_array[a].lv, allocate_pvs)) {
+ log_error("Failed to allocate metadata LV for %s in %s",
+ lvl->lv->name, lv->vg->name);
return 0;
}
- s++;
- }
- for (s = 0; s < seg->area_count; ++s) {
- if (!(new_name = _generate_raid_name(lv, "rimage", s)))
- return_0;
- log_debug_metadata("Renaming %s to %s", seg_lv(seg, s)->name, new_name);
- seg_lv(seg, s)->name = new_name;
- seg_lv(seg, s)->status &= ~MIRROR_IMAGE;
- seg_lv(seg, s)->status |= RAID_IMAGE;
+ dm_list_add(new_meta_lvs, &lvl_array[a++].list);
+
+ dm_list_iterate_items(lvl1, new_meta_lvs)
+ if (!_avoid_pvs_with_other_images_of_lv(lvl1->lv, allocate_pvs))
+ return_0;
}
- init_mirror_in_sync(1);
-
- log_debug_metadata("Setting new segtype for %s", lv->name);
- seg->segtype = new_segtype;
- lv->status &= ~MIRROR;
- lv->status &= ~MIRRORED;
- lv->status |= RAID;
- seg->status |= RAID;
- if (!lv_update_and_reload(lv))
- return_0;
+ _clear_allocation_prohibited(allocate_pvs);
return 1;
}
-
/* Add new @lvs to @lv at @area_offset */
static int _add_image_component_list(struct lv_segment *seg, int delete_from_list,
uint64_t lv_flags, struct dm_list *lvs, uint32_t area_offset)
@@ -1515,82 +1515,6 @@ static int _add_image_component_list(struct lv_segment *seg, int delete_from_lis
}
/*
- * All areas from LV segments are moved to new
- * segments allocated with area_count=1 for data_lvs.
- */
-static int _striped_to_raid0_move_segs_to_raid0_lvs(struct logical_volume *lv,
- struct dm_list *data_lvs)
-{
- uint32_t s = 0, le;
- struct logical_volume *dlv;
- struct lv_segment *seg_from, *seg_new;
- struct lv_list *lvl;
- struct segment_type *segtype;
- uint64_t status;
-
- if (!(segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_STRIPED)))
- return_0;
-
- /* Move segment areas across to the N data LVs of the new raid0 LV */
- dm_list_iterate_items(lvl, data_lvs) {
- dlv = lvl->lv;
- le = 0;
- dm_list_iterate_items(seg_from, &lv->segments) {
- status = RAID | SEG_RAID | (seg_from->status & (LVM_READ | LVM_WRITE));
-
- /* Allocate a data LV segment with one area for each segment in the striped LV */
- if (!(seg_new = alloc_lv_segment(segtype, dlv,
- le, seg_from->area_len,
- status,
- 0 /* stripe_size */, NULL, 1 /* area_count */,
- seg_from->area_len,
- 0 /* chunk_size */, 0 /* region_size */, 0, NULL)))
- return_0;
-
- seg_type(seg_new, 0) = AREA_UNASSIGNED;
- dm_list_add(&dlv->segments, &seg_new->list);
- le += seg_from->area_len;
-
- /* Move the respective area across to our new segment */
- if (!move_lv_segment_area(seg_new, 0, seg_from, s))
- return_0;
- }
-
- /* Adjust le count and LV size */
- dlv->le_count = le;
- dlv->size = (uint64_t) le * lv->vg->extent_size;
- s++;
- }
-
- /* Remove the empty segments from the striped LV */
- dm_list_init(&lv->segments);
-
- return 1;
-}
-
-/*
- * Find the smallest area across all the subLV segments at area_le.
- */
-static uint32_t _min_sublv_area_at_le(struct lv_segment *seg, uint32_t area_le)
-{
- uint32_t s, area_len = ~0U;
- struct lv_segment *seg1;
-
- /* Find smallest segment of each of the data image LVs at offset area_le */
- for (s = 0; s < seg->area_count; s++) {
- if (!(seg1 = find_seg_by_le(seg_lv(seg, s), area_le))) {
- log_error("Failed to find segment for %s extent %" PRIu32,
- seg_lv(seg, s)->name, area_le);
- return 0;
- }
-
- area_len = min(area_len, seg1->len);
- }
-
- return area_len;
-}
-
-/*
* Split segments in segment LVs in all areas of seg at offset area_le
*/
static int _split_area_lvs_segments(struct lv_segment *seg, uint32_t area_le)
@@ -1714,90 +1638,72 @@ static int _extract_image_component_list(struct lv_segment *seg,
}
/*
- * All areas from lv image component LV's segments are
- * being split at "striped" compatible boundaries and
- * moved to allocated new_segments.
- *
- * The data component LVs are mapped to an
- * error target and linked to removal_lvs for disposal
- * by the caller.
+ * Allocate metadata devs for all data devs of an LV
*/
-static int _raid0_to_striped_retrieve_segments_and_lvs(struct logical_volume *lv,
- struct dm_list *removal_lvs)
+static int _alloc_rmeta_devs_for_lv(struct logical_volume *lv,
+ struct dm_list *meta_lvs,
+ struct dm_list *allocate_pvs)
{
- uint32_t s, area_le, area_len, le;
- struct lv_segment *data_seg = NULL, *seg, *seg_to;
- struct dm_list new_segments;
+ uint32_t s;
+ struct lv_list *lvl_array;
+ struct dm_list data_lvs;
+ struct lv_segment *seg = first_seg(lv);
- seg = first_seg(lv);
+ dm_list_init(&data_lvs);
- dm_list_init(&new_segments);
-
- /*
- * Walk all segments of all data LVs splitting them up at proper boundaries
- * and create the number of new striped segments we need to move them across
- */
- area_le = le = 0;
- while (le < lv->le_count) {
- if (!(area_len = _min_sublv_area_at_le(seg, area_le)))
- return_0;
- area_le += area_len;
+ if (!(seg->meta_areas = dm_pool_zalloc(lv->vg->vgmem, seg->area_count * sizeof(*seg->meta_areas))))
+ return 0;
- if (!_split_area_lvs_segments(seg, area_le) ||
- !_alloc_and_add_new_striped_segment(lv, le, area_len, &new_segments))
- return_0;
+ if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, seg->area_count * sizeof(*lvl_array))))
+ return_0;
- le = area_le * seg->area_count;
+ for (s = 0; s < seg->area_count; s++) {
+ lvl_array[s].lv = seg_lv(seg, s);
+ dm_list_add(&data_lvs, &lvl_array[s].list);
}
- /* Now move the prepared split areas across to the new segments */
- area_le = 0;
- dm_list_iterate_items(seg_to, &new_segments) {
- for (s = 0; s < seg->area_count; s++) {
- if (!(data_seg = find_seg_by_le(seg_lv(seg, s), area_le))) {
- log_error("Failed to find segment for %s extent %" PRIu32,
- seg_lv(seg, s)->name, area_le);
- return 0;
- }
-
- /* Move the respective area across to our new segments area */
- if (!move_lv_segment_area(seg_to, s, data_seg, 0))
- return_0;
- }
-
- /* Presumes all data LVs have equal size */
- area_le += data_seg->len;
+ if (!_alloc_rmeta_devs_for_rimage_devs(lv, &data_lvs, meta_lvs, allocate_pvs)) {
+ log_error("Failed to allocate metadata LVs for %s", lv->name);
+ return 0;
}
- /* Extract any metadata LVs and the empty data LVs for disposal by the caller */
- if (!_extract_image_component_list(seg, RAID_IMAGE, 0, removal_lvs))
- return_0;
-
- /*
- * Remove the one segment holding the image component areas
- * from the top-level LV, then add the new segments to it
- */
- dm_list_del(&seg->list);
- dm_list_splice(&lv->segments, &new_segments);
-
return 1;
}
/*
- * Deactivate and remove the LVs on removal_lvs list from vg.
+ * Add metadata areas to raid0
*/
-static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *removal_lvs)
+static int _alloc_and_add_rmeta_devs_for_lv(struct logical_volume *lv, struct dm_list *allocate_pvs)
{
- struct lv_list *lvl;
+ struct lv_segment *seg = first_seg(lv);
+ struct dm_list meta_lvs;
- dm_list_iterate_items(lvl, removal_lvs)
- if (!deactivate_lv(vg->cmd, lvl->lv) ||
- !lv_remove(lvl->lv))
- return_0;
+ dm_list_init(&meta_lvs);
+
+ log_debug_metadata("Allocating metadata LVs for %s", display_lvname(lv));
+ if (!_alloc_rmeta_devs_for_lv(lv, &meta_lvs, allocate_pvs)) {
+ log_error("Failed to allocate metadata LVs for %s", display_lvname(lv));
+ return_0;
+ }
+
+ /* Metadata LVs must be cleared before being added to the array */
+ log_debug_metadata("Clearing newly allocated metadata LVs for %s", display_lvname(lv));
+ if (!_clear_lvs(&meta_lvs)) {
+ log_error("Failed to initialize metadata LVs for %s", display_lvname(lv));
+ return_0;
+ }
+
+ /* Set segment areas for metadata sub_lvs */
+ log_debug_metadata("Adding newly allocated metadata LVs to %s", display_lvname(lv));
+ if (!_add_image_component_list(seg, 1, 0, &meta_lvs, 0)) {
+ log_error("Failed to add newly allocated metadata LVs to %s", display_lvname(lv));
+ return_0;
+ }
return 1;
}
+
/* FIXME Move this out */
/* Write, commit and optionally backup metadata of vg */
static int _vg_write_commit_backup(struct volume_group *vg)
@@ -1846,207 +1752,292 @@ static int _eliminate_extracted_lvs(struct volume_group *vg, struct dm_list *rem
return _eliminate_extracted_lvs_optional_write_vg(vg, removal_lvs, 1);
}
-static int _avoid_pvs_of_lv(struct logical_volume *lv, void *data)
+/*
+ * Add/remove metadata areas to/from raid0
+ */
+static int _raid0_add_or_remove_metadata_lvs(struct logical_volume *lv,
+ int update_and_reload,
+ struct dm_list *allocate_pvs,
+ struct dm_list *removal_lvs)
{
- struct dm_list *allocate_pvs = (struct dm_list *) data;
- struct pv_list *pvl;
+ uint64_t new_raid_type_flag;
+ struct lv_segment *seg = first_seg(lv);
- dm_list_iterate_items(pvl, allocate_pvs)
- if (!lv_is_partial(lv) && lv_is_on_pv(lv, pvl->pv))
- pvl->pv->status |= PV_ALLOCATION_PROHIBITED;
+ if (removal_lvs) {
+ if (seg->meta_areas) {
+ if (!_extract_image_component_list(seg, RAID_META, 0, removal_lvs))
+ return_0;
+ seg->meta_areas = NULL;
+ }
+ new_raid_type_flag = SEG_RAID0;
+ } else {
+ if (!_alloc_and_add_rmeta_devs_for_lv(lv, allocate_pvs))
+ return 0;
+
+ new_raid_type_flag = SEG_RAID0_META;
+ }
+
+ if (!(seg->segtype = get_segtype_from_flag(lv->vg->cmd, new_raid_type_flag)))
+ return_0;
+
+ if (update_and_reload) {
+ if (!lv_update_and_reload_origin(lv))
+ return_0;
+
+ /* If any residual LVs, eliminate them, write VG, commit it and take a backup */
+ return _eliminate_extracted_lvs(lv->vg, removal_lvs);
+ }
return 1;
}
/*
- * Prevent any PVs holding other image components of @lv from being used for allocation
- * by setting the internal PV_ALLOCATION_PROHIBITED flag to use it to avoid generating
- * pv maps for those PVs.
+ * General conversion functions
*/
-static int _avoid_pvs_with_other_images_of_lv(struct logical_volume *lv, struct dm_list *allocate_pvs)
-{
- return for_each_sub_lv(lv, _avoid_pvs_of_lv, allocate_pvs);
-}
-
-static void _clear_allocation_prohibited(struct dm_list *pvs)
-{
- struct pv_list *pvl;
-
- if (pvs)
- dm_list_iterate_items(pvl, pvs)
- pvl->pv->status &= ~PV_ALLOCATION_PROHIBITED;
-}
/*
- * Allocate metadata devs for all @new_data_devs and link them to list @new_meta_lvs
+ * Convert a RAID0 set to striped
*/
-static int _alloc_rmeta_devs_for_rimage_devs(struct logical_volume *lv,
- struct dm_list *new_data_lvs,
- struct dm_list *new_meta_lvs,
- struct dm_list *allocate_pvs)
+static int _convert_mirror_to_raid1(struct logical_volume *lv,
+ const struct segment_type *new_segtype)
{
- uint32_t a = 0, raid_devs = dm_list_size(new_data_lvs);
- struct lv_list *lvl, *lvl1, *lvl_array;
+ uint32_t s;
+ struct lv_segment *seg = first_seg(lv);
+ struct lv_list lvl_array[seg->area_count], *lvl;
+ struct dm_list meta_lvs;
+ struct lv_segment_area *meta_areas;
+ char *new_name;
- if (!raid_devs)
- return_0;
+ dm_list_init(&meta_lvs);
- if (!(lvl_array = dm_pool_zalloc(lv->vg->vgmem, raid_devs * sizeof(*lvl_array))))
- return_0;
+ if (!_raid_in_sync(lv)) {
+ log_error("Unable to convert %s/%s while it is not in-sync",
+ lv->vg->name, lv->name);
+ return 0;
+ }
- dm_list_iterate_items(lvl, new_data_lvs) {
- log_debug_metadata("Allocating new metadata LV for %s", lvl->lv->name);
+ if (!(meta_areas = dm_pool_zalloc(lv->vg->vgmem,
+ lv_mirror_count(lv) * sizeof(*meta_areas)))) {
+ log_error("Failed to allocate meta areas memory.");
+ return 0;
+ }
- if (!_alloc_rmeta_for_lv(lvl->lv, &lvl_array[a].lv, allocate_pvs)) {
+ if (!archive(lv->vg))
+ return_0;
+
+ for (s = 0; s < seg->area_count; s++) {
+ log_debug_metadata("Allocating new metadata LV for %s",
+ seg_lv(seg, s)->name);
+ if (!_alloc_rmeta_for_lv(seg_lv(seg, s), &(lvl_array[s].lv), NULL)) {
log_error("Failed to allocate metadata LV for %s in %s",
- lvl->lv->name, lv->vg->name);
+ seg_lv(seg, s)->name, lv->name);
return 0;
}
+ dm_list_add(&meta_lvs, &(lvl_array[s].list));
+ }
- dm_list_add(new_meta_lvs, &lvl_array[a++].list);
-
- dm_list_iterate_items(lvl1, new_meta_lvs)
- if (!_avoid_pvs_with_other_images_of_lv(lvl1->lv, allocate_pvs))
- return_0;
+ log_debug_metadata("Clearing newly allocated metadata LVs");
+ if (!_clear_lvs(&meta_lvs)) {
+ log_error("Failed to initialize metadata LVs");
+ return 0;
}
- _clear_allocation_prohibited(allocate_pvs);
+ if (seg->log_lv) {
+ log_debug_metadata("Removing mirror log, %s", seg->log_lv->name);
+ if (!remove_mirror_log(lv->vg->cmd, lv, NULL, 0)) {
+ log_error("Failed to remove mirror log");
+ return 0;
+ }
+ }
+
+ seg->meta_areas = meta_areas;
+ s = 0;
+
+ dm_list_iterate_items(lvl, &meta_lvs) {
+ log_debug_metadata("Adding %s to %s", lvl->lv->name, lv->name);
+
+ /* Images are known to be in-sync */
+ lvl->lv->status &= ~LV_REBUILD;
+ first_seg(lvl->lv)->status &= ~LV_REBUILD;
+ lv_set_hidden(lvl->lv);
+
+ if (!set_lv_segment_area_lv(seg, s, lvl->lv, 0,
+ lvl->lv->status)) {
+ log_error("Failed to add %s to %s",
+ lvl->lv->name, lv->name);
+ return 0;
+ }
+ s++;
+ }
+
+ for (s = 0; s < seg->area_count; ++s) {
+ if (!(new_name = _generate_raid_name(lv, "rimage", s)))
+ return_0;
+ log_debug_metadata("Renaming %s to %s", seg_lv(seg, s)->name, new_name);
+ seg_lv(seg, s)->name = new_name;
+ seg_lv(seg, s)->status &= ~MIRROR_IMAGE;
+ seg_lv(seg, s)->status |= RAID_IMAGE;
+ }
+ init_mirror_in_sync(1);
+
+ log_debug_metadata("Setting new segtype for %s", lv->name);
+ seg->segtype = new_segtype;
+ lv->status &= ~MIRROR;
+ lv->status &= ~MIRRORED;
+ lv->status |= RAID;
+ seg->status |= RAID;
+
+ if (!lv_update_and_reload(lv))
+ return_0;
return 1;
}
/*
- * Allocate metadata devs for all data devs of an LV
+ * All areas from LV segments are moved to new
+ * segments allocated with area_count=1 for data_lvs.
*/
-static int _alloc_rmeta_devs_for_lv(struct logical_volume *lv,
- struct dm_list *meta_lvs,
- struct dm_list *allocate_pvs)
+static int _striped_to_raid0_move_segs_to_raid0_lvs(struct logical_volume *lv,
+ struct dm_list *data_lvs)
{
- uint32_t s;
- struct lv_list *lvl_array;
- struct dm_list data_lvs;
- struct lv_segment *seg = first_seg(lv);
+ uint32_t s = 0, le;
+ struct logical_volume *dlv;
+ struct lv_segment *seg_from, *seg_new;
+ struct lv_list *lvl;
+ struct segment_type *segtype;
+ uint64_t status;
- dm_list_init(&data_lvs);
+ if (!(segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_STRIPED)))
+ return_0;
- if (!(seg->meta_areas = dm_pool_zalloc(lv->vg->vgmem, seg->area_count * sizeof(*seg->meta_areas))))
- return 0;
+ /* Move segment areas across to the N data LVs of the new raid0 LV */
+ dm_list_iterate_items(lvl, data_lvs) {
+ dlv = lvl->lv;
+ le = 0;
+ dm_list_iterate_items(seg_from, &lv->segments) {
+ status = RAID | SEG_RAID | (seg_from->status & (LVM_READ | LVM_WRITE));
- if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, seg->area_count * sizeof(*lvl_array))))
- return_0;
+ /* Allocate a data LV segment with one area for each segment in the striped LV */
+ if (!(seg_new = alloc_lv_segment(segtype, dlv,
+ le, seg_from->area_len,
+ status,
+ 0 /* stripe_size */, NULL, 1 /* area_count */,
+ seg_from->area_len,
+ 0 /* chunk_size */, 0 /* region_size */, 0, NULL)))
+ return_0;
- for (s = 0; s < seg->area_count; s++) {
- lvl_array[s].lv = seg_lv(seg, s);
- dm_list_add(&data_lvs, &lvl_array[s].list);
- }
+ seg_type(seg_new, 0) = AREA_UNASSIGNED;
+ dm_list_add(&dlv->segments, &seg_new->list);
+ le += seg_from->area_len;
- if (!_alloc_rmeta_devs_for_rimage_devs(lv, &data_lvs, meta_lvs, allocate_pvs)) {
- log_error("Failed to allocate metadata LVs for %s", lv->name);
- return 0;
+ /* Move the respective area across to our new segment */
+ if (!move_lv_segment_area(seg_new, 0, seg_from, s))
+ return_0;
+ }
+
+ /* Adjust le count and LV size */
+ dlv->le_count = le;
+ dlv->size = (uint64_t) le * lv->vg->extent_size;
+ s++;
}
+ /* Remove the empty segments from the striped LV */
+ dm_list_init(&lv->segments);
+
return 1;
}
/*
- * Add metadata areas to raid0
+ * Find the smallest area across all the subLV segments at area_le.
*/
-static int _alloc_and_add_rmeta_devs_for_lv(struct logical_volume *lv, struct dm_list *allocate_pvs)
+static uint32_t _min_sublv_area_at_le(struct lv_segment *seg, uint32_t area_le)
{
- struct lv_segment *seg = first_seg(lv);
- struct dm_list meta_lvs;
-
- dm_list_init(&meta_lvs);
-
- log_debug_metadata("Allocating metadata LVs for %s", display_lvname(lv));
- if (!_alloc_rmeta_devs_for_lv(lv, &meta_lvs, allocate_pvs)) {
- log_error("Failed to allocate metadata LVs for %s", display_lvname(lv));
- return_0;
- }
+ uint32_t s, area_len = ~0U;
+ struct lv_segment *seg1;
- /* Metadata LVs must be cleared before being added to the array */
- log_debug_metadata("Clearing newly allocated metadata LVs for %s", display_lvname(lv));
- if (!_clear_lvs(&meta_lvs)) {
- log_error("Failed to initialize metadata LVs for %s", display_lvname(lv));
- return_0;
- }
+ /* Find smallest segment of each of the data image LVs at offset area_le */
+ for (s = 0; s < seg->area_count; s++) {
+ if (!(seg1 = find_seg_by_le(seg_lv(seg, s), area_le))) {
+ log_error("Failed to find segment for %s extent %" PRIu32,
+ seg_lv(seg, s)->name, area_le);
+ return 0;
+ }
- /* Set segment areas for metadata sub_lvs */
- log_debug_metadata("Adding newly allocated metadata LVs to %s", display_lvname(lv));
- if (!_add_image_component_list(seg, 1, 0, &meta_lvs, 0)) {
- log_error("Failed to add newly allocated metadata LVs to %s", display_lvname(lv));
- return_0;
+ area_len = min(area_len, seg1->len);
}
- return 1;
+ return area_len;
}
-
/*
- * Add/remove metadata areas to/from raid0
+ * All areas from lv image component LV's segments are
+ * being split at "striped" compatible boundaries and
+ * moved to allocated new_segments.
+ *
+ * The data component LVs are mapped to an
+ * error target and linked to removal_lvs for disposal
+ * by the caller.
*/
-static int _raid0_add_or_remove_metadata_lvs(struct logical_volume *lv,
- int update_and_reload,
- struct dm_list *allocate_pvs,
- struct dm_list *removal_lvs)
+static int _raid0_to_striped_retrieve_segments_and_lvs(struct logical_volume *lv,
+ struct dm_list *removal_lvs)
{
- uint64_t new_raid_type_flag;
- struct lv_segment *seg = first_seg(lv);
+ uint32_t s, area_le, area_len, le;
+ struct lv_segment *data_seg = NULL, *seg, *seg_to;
+ struct dm_list new_segments;
- if (removal_lvs) {
- if (seg->meta_areas) {
- if (!_extract_image_component_list(seg, RAID_META, 0, removal_lvs))
- return_0;
- seg->meta_areas = NULL;
- }
- new_raid_type_flag = SEG_RAID0;
- } else {
- if (!_alloc_and_add_rmeta_devs_for_lv(lv, allocate_pvs))
- return 0;
+ seg = first_seg(lv);
- new_raid_type_flag = SEG_RAID0_META;
- }
+ dm_list_init(&new_segments);
- if (!(seg->segtype = get_segtype_from_flag(lv->vg->cmd, new_raid_type_flag)))
- return_0;
+ /*
+ * Walk all segments of all data LVs splitting them up at proper boundaries
+ * and create the number of new striped segments we need to move them across
+ */
+ area_le = le = 0;
+ while (le < lv->le_count) {
+ if (!(area_len = _min_sublv_area_at_le(seg, area_le)))
+ return_0;
+ area_le += area_len;
- if (update_and_reload) {
- if (!lv_update_and_reload_origin(lv))
+ if (!_split_area_lvs_segments(seg, area_le) ||
+ !_alloc_and_add_new_striped_segment(lv, le, area_len, &new_segments))
return_0;
- /* If any residual LVs, eliminate them, write VG, commit it and take a backup */
- return _eliminate_extracted_lvs(lv->vg, removal_lvs);
+ le = area_le * seg->area_count;
}
- return 1;
-}
+ /* Now move the prepared split areas across to the new segments */
+ area_le = 0;
+ dm_list_iterate_items(seg_to, &new_segments) {
+ for (s = 0; s < seg->area_count; s++) {
+ if (!(data_seg = find_seg_by_le(seg_lv(seg, s), area_le))) {
+ log_error("Failed to find segment for %s extent %" PRIu32,
+ seg_lv(seg, s)->name, area_le);
+ return 0;
+ }
-static int _raid0_meta_change_wrapper(struct logical_volume *lv,
- const struct segment_type *new_segtype,
- uint32_t new_stripes,
- int yes, int force, int alloc_metadata_devs,
- struct dm_list *allocate_pvs)
-{
- struct dm_list removal_lvs;
+ /* Move the respective area across to our new segments area */
+ if (!move_lv_segment_area(seg_to, s, data_seg, 0))
+ return_0;
+ }
- dm_list_init(&removal_lvs);
+ /* Presumes all data LVs have equal size */
+ area_le += data_seg->len;
+ }
- if (!_check_restriping(new_stripes, lv))
+ /* Extract any metadata LVs and the empty data LVs for disposal by the caller */
+ if (!_extract_image_component_list(seg, RAID_IMAGE, 0, removal_lvs))
return_0;
- if (!archive(lv->vg))
- return_0;
+ /*
+ * Remove the one segment holding the image component areas
+ * from the top-level LV, then add the new segments to it
+ */
+ dm_list_del(&seg->list);
+ dm_list_splice(&lv->segments, &new_segments);
- if (alloc_metadata_devs)
- return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, NULL);
- else
- return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, &removal_lvs);
+ return 1;
}
-
-
-/*
- * Convert a RAID0 set to striped
- */
static int _convert_raid0_to_striped(struct logical_volume *lv,
int update_and_reload,
struct dm_list *removal_lvs)
@@ -2171,11 +2162,8 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
return raid0_seg;
}
-/************************************************/
+/***********************************************/
-/*
- * Individual takeover functions.
- */
#define TAKEOVER_FN_ARGS \
struct logical_volume *lv, \
const struct segment_type *new_segtype, \
@@ -2188,8 +2176,10 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
typedef int (*takeover_fn_t)(TAKEOVER_FN_ARGS);
+/***********************************************/
+
/*
- * Common takeover functions.
+ * Unsupported takeover functions.
*/
static int _takeover_noop(TAKEOVER_FN_ARGS)
{
@@ -2209,6 +2199,16 @@ static int _takeover_unsupported(TAKEOVER_FN_ARGS)
return 0;
}
+static int _takeover_unsupported_yet(const struct logical_volume *lv, const unsigned new_stripes, const struct segment_type *new_segtype)
+{
+ log_error("Converting the segment type for %s from %s to %s is not supported yet.",
+ display_lvname(lv), lvseg_name(first_seg(lv)),
+ (segtype_is_striped(new_segtype) && !segtype_is_any_raid0(new_segtype) &&
+ (new_stripes == 1)) ? SEG_TYPE_NAME_LINEAR : new_segtype->name);
+
+ return 0;
+}
+
/*
* Will this particular takeover combination be possible?
*/
@@ -2220,16 +2220,85 @@ static int _takeover_not_possible(takeover_fn_t takeover_fn)
return 0;
}
-static int _takeover_unsupported_yet(const struct logical_volume *lv, const unsigned new_stripes, const struct segment_type *new_segtype)
+/***********************************************/
+
+/*
+ * Wrapper functions that share conversion code.
+ */
+
+static int _raid0_meta_change_wrapper(struct logical_volume *lv,
+ const struct segment_type *new_segtype,
+ uint32_t new_stripes,
+ int yes, int force, int alloc_metadata_devs,
+ struct dm_list *allocate_pvs)
{
- log_error("Converting the segment type for %s from %s to %s is not supported yet.",
- display_lvname(lv), lvseg_name(first_seg(lv)),
- (segtype_is_striped(new_segtype) && !segtype_is_any_raid0(new_segtype) &&
- (new_stripes == 1)) ? SEG_TYPE_NAME_LINEAR : new_segtype->name);
+ struct dm_list removal_lvs;
- return 0;
+ dm_list_init(&removal_lvs);
+
+ if (!_check_restriping(new_stripes, lv))
+ return_0;
+
+ if (!archive(lv->vg))
+ return_0;
+
+ if (alloc_metadata_devs)
+ return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, NULL);
+ else
+ return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, &removal_lvs);
+}
+
+static int _raid0_to_striped_wrapper(struct logical_volume *lv,
+ const struct segment_type *new_segtype,
+ uint32_t new_stripes,
+ int yes, int force,
+ struct dm_list *allocate_pvs)
+{
+ struct dm_list removal_lvs;
+
+ dm_list_init(&removal_lvs);
+
+ if (!_check_restriping(new_stripes, lv))
+ return_0;
+
+ /* Archive metadata */
+ if (!archive(lv->vg))
+ return_0;
+
+ /* FIXME update_and_reload is only needed if the LV is already active */
+ /* FIXME Some of the validation in here needs moving before the archiving */
+ if (!_convert_raid0_to_striped(lv, 1 /* update_and_reload */, &removal_lvs))
+ return_0;
+
+ return 1;
+}
+
+static int _striped_to_raid0_wrapper(struct logical_volume *lv,
+ const struct segment_type *new_segtype,
+ uint32_t new_stripes,
+ int yes, int force, int alloc_metadata_devs,
+ struct dm_list *allocate_pvs)
+{
+ if (!_check_restriping(new_stripes, lv))
+ return_0;
+
+ /* Archive metadata */
+ if (!archive(lv->vg))
+ return_0;
+
+ /* FIXME update_and_reload is only needed if the LV is already active */
+ /* FIXME Some of the validation in here needs moving before the archiving */
+ if (!_convert_striped_to_raid0(lv, alloc_metadata_devs, 1 /* update_and_reload */, allocate_pvs))
+ return_0;
+
+ return 1;
}
+
+
+
+/************************************************/
+
/*
* Customised takeover functions
*/
@@ -2315,31 +2384,6 @@ static int _takeover_from_raid0_to_raid6(TAKEOVER_FN_ARGS)
return _takeover_unsupported_yet(lv, new_stripes, new_segtype);
}
-static int _raid0_to_striped_wrapper(struct logical_volume *lv,
- const struct segment_type *new_segtype,
- uint32_t new_stripes,
- int yes, int force,
- struct dm_list *allocate_pvs)
-{
- struct dm_list removal_lvs;
-
- dm_list_init(&removal_lvs);
-
- if (!_check_restriping(new_stripes, lv))
- return_0;
-
- /* Archive metadata */
- if (!archive(lv->vg))
- return_0;
-
- /* FIXME update_and_reload is only needed if the LV is already active */
- /* FIXME Some of the validation in here needs moving before the archiving */
- if (!_convert_raid0_to_striped(lv, 1 /* update_and_reload */, &removal_lvs))
- return_0;
-
- return 1;
-}
-
static int _takeover_from_raid0_to_striped(TAKEOVER_FN_ARGS)
{
if (!_raid0_to_striped_wrapper(lv, new_segtype, new_stripes, yes, force, allocate_pvs))
@@ -2494,27 +2538,6 @@ static int _takeover_from_raid6_to_striped(TAKEOVER_FN_ARGS)
return _takeover_unsupported_yet(lv, new_stripes, new_segtype);
}
-static int _striped_to_raid0_wrapper(struct logical_volume *lv,
- const struct segment_type *new_segtype,
- uint32_t new_stripes,
- int yes, int force, int alloc_metadata_devs,
- struct dm_list *allocate_pvs)
-{
- if (!_check_restriping(new_stripes, lv))
- return_0;
-
- /* Archive metadata */
- if (!archive(lv->vg))
- return_0;
-
- /* FIXME update_and_reload is only needed if the LV is already active */
- /* FIXME Some of the validation in here needs moving before the archiving */
- if (!_convert_striped_to_raid0(lv, alloc_metadata_devs, 1 /* update_and_reload */, allocate_pvs))
- return_0;
-
- return 1;
-}
-
static int _takeover_from_striped_to_raid0(TAKEOVER_FN_ARGS)
{
if (!_striped_to_raid0_wrapper(lv, new_segtype, new_stripes, yes, force, 0, allocate_pvs))
@@ -2637,21 +2660,6 @@ static takeover_fn_t _get_takeover_fn(const struct lv_segment *seg, const struct
return _takeover_fns[_segtype_ix(seg->segtype, seg->area_count)][_segtype_ix(new_segtype, new_image_count)];
}
-/*
- * Check for maximum number of raid devices.
- * Constrained by kernel MD maximum device limits _and_ dm-raid superblock
- * bitfield constraints.
- */
-static int _check_max_raid_devices(uint32_t image_count)
-{
- if (image_count > DEFAULT_RAID_MAX_IMAGES) {
- log_error("Unable to handle arrays with more than %u devices",
- DEFAULT_RAID_MAX_IMAGES);
- return 0;
- }
- return 1;
-}
-
/* Number of data (not parity) rimages */
static uint32_t _data_rimages_count(const struct lv_segment *seg, const uint32_t total_rimages)
{
6 years, 8 months
master - lvmlockd: improve activation locking error message
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f6acf922e62591...
Commit: f6acf922e625912e88e064fb03a5188bdcc8bb43
Parent: 2c3b92b550ee1ba0c165acb7da87cc5cd8cf3eb9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jul 22 14:50:33 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 22 14:50:33 2016 -0500
lvmlockd: improve activation locking error message
to include the LV type
---
lib/locking/lvmlockd.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index e025428..03d0014 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1971,8 +1971,9 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
mode = def_mode;
if (mode && !strcmp(mode, "sh") && (flags & LDLV_MODE_NO_SH)) {
- log_error("Shared activation not compatible with LV type: %s/%s",
- vg->name, lv_name);
+ struct logical_volume *lv = find_lv(vg, lv_name);
+ log_error("Shared activation not compatible with LV type %s of %s/%s",
+ lv ? lvseg_name(first_seg(lv)) : "", vg->name, lv_name);
return 0;
}
6 years, 8 months
master - lvconvert: change error message
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2c3b92b550ee1b...
Commit: 2c3b92b550ee1ba0c165acb7da87cc5cd8cf3eb9
Parent: 7fc1617819236d4d6f8b0ffbcd4980fcc5bc5de6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jul 22 10:00:24 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 22 10:00:24 2016 -0500
lvconvert: change error message
for implicit pool conversion since it's also used
when the lv is already a pool
---
tools/lvconvert.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 9dd7254..5d29cc4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3913,7 +3913,7 @@ static int _convert_striped_thin(struct cmd_context *cmd, struct logical_volume
{
/* lvconvert --thin includes an implicit conversion of the thinpool arg to type thin-pool. */
if (!_lvconvert_pool(cmd, lv, lp)) {
- log_error("Implicit conversion of --thinpool arg to type thin-pool failed.");
+ log_error("Conversion of --thinpool arg to type thin-pool failed.");
return 0;
}
@@ -3939,7 +3939,7 @@ static int _convert_striped_cache(struct cmd_context *cmd, struct logical_volume
{
/* lvconvert --cache includes an implicit conversion of the cachepool arg to type cache-pool. */
if (!_lvconvert_pool(cmd, lv, lp)) {
- log_error("Implicit conversion of --cachepool arg to type cache-pool failed.");
+ log_error("Conversion of --cachepool arg to type cache-pool failed.");
return 0;
}
6 years, 8 months
master - tests: check thin resize of raid10
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7fc1617819236d...
Commit: 7fc1617819236d4d6f8b0ffbcd4980fcc5bc5de6
Parent: 5bb113c20469aa5027098465ddeaa3c652d4f8e5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 22 11:07:54 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 22 14:41:47 2016 +0200
tests: check thin resize of raid10
---
test/shell/lvextend-thin-raid.sh | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvextend-thin-raid.sh b/test/shell/lvextend-thin-raid.sh
index 7014985..1688ffb 100644
--- a/test/shell/lvextend-thin-raid.sh
+++ b/test/shell/lvextend-thin-raid.sh
@@ -19,7 +19,7 @@ export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
aux have_thin 1 0 0 || skip
aux have_raid 1 3 0 || skip
-aux prepare_vg 3
+aux prepare_vg 6
lvcreate --type raid1 -l2 --nosync -n pool $vg
lvconvert --yes --thinpool $vg/pool "$dev3"
@@ -32,4 +32,20 @@ lvextend -l+3 $vg/pool
check lv_field $vg/pool seg_size_pe "5"
check lv_field $vg/pool_tdata seg_size_pe "5" -a
+lvremove -f $vg
+
+# check 'raid10' resize works for pool metadata resize
+# https://bugzilla.redhat.com/1075644
+lvcreate --type raid10 -m1 -L5 -i3 --nosync -n pool $vg
+lvcreate --type raid10 -m1 -L3 -i3 --nosync -n meta $vg
+lvconvert --yes --thinpool $vg/pool --poolmetadata $vg/meta
+
+check lv_field $vg/pool_tdata lv_size "6.00m" -a
+check lv_field $vg/pool_tmeta lv_size "3.00m" -a
+
+lvextend --poolmetadatasize +1 --size +1 $vg/pool
+
+check lv_field $vg/pool_tdata lv_size "7.50m" -a
+check lv_field $vg/pool_tmeta lv_size "4.50m" -a
+
vgremove -ff $vg
6 years, 8 months
master - man: drop .R
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5bb113c20469aa...
Commit: 5bb113c20469aa5027098465ddeaa3c652d4f8e5
Parent: 27a767d5e8cedf9cac31eb3562cf8fdd4aa88b7c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 21 14:56:30 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 22 14:41:47 2016 +0200
man: drop .R
Avoid using .R as its not a valid man macro.
---
man/lvconvert.8.in | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 95f7095..5ddea3d 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -92,9 +92,9 @@ OPTIONS:
.B \-\-type striped
.br
.B \-\-type snapshot
-.R |
+|
.B \-\-snapshot
-.R |
+|
.B \-s
.br
.B \-\-type mirror
@@ -102,15 +102,15 @@ OPTIONS:
.B \-\-type raid*
.br
.B \-\-type thin
-.R |
+|
.B \-\-thin
-.R |
+|
.B \-T
.br
.B \-\-type cache
-.R |
+|
.B \-\-cache
-.R |
+|
.B \-H
.br
.B \-\-type thin\-pool
6 years, 8 months