master - test: add raid4 checks to respective tests
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a9651adc84210d...
Commit: a9651adc84210d88828f9c3c82a0f382a899a650
Parent: e611f82a11fb9c489e73de8c05447ebe2cc26d9a
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Oct 28 21:54:10 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Oct 28 21:54:10 2016 +0200
test: add raid4 checks to respective tests
Add missing checks for valid raid4 mapping to tests.
---
test/lib/aux.sh | 9 +++++++++
test/shell/lvchange-raid456.sh | 2 +-
test/shell/lvconvert-raid456.sh | 5 ++++-
test/shell/lvcreate-large-raid.sh | 5 ++++-
test/shell/lvcreate-raid-nosync.sh | 5 ++++-
test/shell/lvcreate-raid.sh | 7 +++++--
test/shell/lvresize-raid.sh | 7 +++++--
7 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index e523123..7187975 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1376,6 +1376,15 @@ have_raid() {
esac
}
+have_raid4 () {
+ local r=1
+
+ have_raid 1 8 0 && r=0
+ have_raid 1 9 1 && r=1
+
+ return $r
+}
+
have_cache() {
test "$CACHE" = shared -o "$CACHE" = internal || {
echo "Cache is not built-in." >&2
diff --git a/test/shell/lvchange-raid456.sh b/test/shell/lvchange-raid456.sh
index 13b19dd..5cdcbde 100644
--- a/test/shell/lvchange-raid456.sh
+++ b/test/shell/lvchange-raid456.sh
@@ -16,7 +16,7 @@ TEST_RAID=raid456
aux raid456_replace_works || skip
aux have_raid 1 5 2 || skip
-run_types raid4 -i 2 "$dev1" "$dev2" "$dev3" "$dev4"
+aux have_raid4 && run_types raid4 -i 2 "$dev1" "$dev2" "$dev3" "$dev4"
run_types raid5 -i 2 "$dev1" "$dev2" "$dev3" "$dev4"
run_types raid6 -i 3 "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
diff --git a/test/shell/lvconvert-raid456.sh b/test/shell/lvconvert-raid456.sh
index f7e6e56..358ceec 100644
--- a/test/shell/lvconvert-raid456.sh
+++ b/test/shell/lvconvert-raid456.sh
@@ -31,8 +31,11 @@ aux have_raid 1 3 0 || skip
aux prepare_pvs 7 # 7 devices for 2 dev replacement of 5-dev RAID6
vgcreate -s 256k $vg $(cat DEVICES)
+levels="5 6"
+aux have_raid4 && levels="4 5 6"
+
# RAID 4/5/6 (can replace up to 'parity' devices)
-for i in 4 5 6; do
+for i in $levels; do
lvcreate --type raid$i -i 3 -l 3 -n $lv1 $vg
if [ $i -eq 6 ]; then
diff --git a/test/shell/lvcreate-large-raid.sh b/test/shell/lvcreate-large-raid.sh
index 11a69d4..4e68b2c 100644
--- a/test/shell/lvcreate-large-raid.sh
+++ b/test/shell/lvcreate-large-raid.sh
@@ -21,6 +21,9 @@ aux can_use_16T || skip
aux have_raid 1 3 0 || skip
+segtypes="raid5"
+aux have_raid4 && segtypes="raid4 raid5"
+
# Prepare 5x ~1P sized devices
aux prepare_pvs 5 1000000000
@@ -53,7 +56,7 @@ check raid_leg_status $vg1 $lv1 "AA"
lvremove -ff $vg1
# 750 TiB raid4/5
-for segtype in raid4 raid5; do
+for segtype in $segtypes; do
lvcreate --type $segtype -i 3 -L 750T -n $lv1 $vg1 --nosync
check lv_field $vg1/$lv1 size "750.00t"
check raid_leg_status $vg1 $lv1 "AAAA"
diff --git a/test/shell/lvcreate-raid-nosync.sh b/test/shell/lvcreate-raid-nosync.sh
index fdb4f68..1343e8f 100644
--- a/test/shell/lvcreate-raid-nosync.sh
+++ b/test/shell/lvcreate-raid-nosync.sh
@@ -16,6 +16,9 @@ SKIP_WITH_LVMPOLLD=1
aux have_raid 1 7 0 || skip
+segtypes=raid5
+aux have_raid4 && segtypes="raid4 raid5"
+
aux prepare_vg 6
@@ -43,7 +46,7 @@ lvcreate --yes --type raid1 --nosync -m 2 -l 1 -n $lv1 $vg
check raid_leg_status $vg $lv1 "AAA"
lvremove --yes $vg/$lv1
-for r in raid4 raid5
+for r in $segtypes
do
# raid4/5 support resynchronization
lvcreate --yes --type $r -i 3 -l 2 -n $lv1 $vg
diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh
index 66434b0..f1a4a68 100644
--- a/test/shell/lvcreate-raid.sh
+++ b/test/shell/lvcreate-raid.sh
@@ -23,6 +23,9 @@ lv_devices() {
########################################################
aux have_raid 1 3 0 || skip
+RAID4=""
+aux have_raid4 && RAID4=raid4
+
aux prepare_pvs 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test
vgcreate -s 512k $vg $(cat DEVICES)
@@ -54,7 +57,7 @@ aux wait_for_sync $vg $lv1
lvremove -ff $vg
# Create RAID 4/5/6 (explicit 3-stripe + parity devs)
-for i in raid4 \
+for i in $RAID4 \
raid5 raid5_ls raid5_la raid5_rs raid5_ra \
raid6 raid6_zr raid6_nr raid6_nc; do
@@ -64,7 +67,7 @@ for i in raid4 \
done
# Create RAID 4/5/6 (explicit 3-stripe + parity devs) - Set min/max recovery
-for i in raid4 \
+for i in $RAID4 \
raid5 raid5_ls raid5_la raid5_rs raid5_ra \
raid6 raid6_zr raid6_nr raid6_nc; do
diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh
index 98eef28..4eabe4c 100644
--- a/test/shell/lvresize-raid.sh
+++ b/test/shell/lvresize-raid.sh
@@ -16,6 +16,9 @@ SKIP_WITH_LVMPOLLD=1
aux have_raid 1 3 0 || skip
+levels="5 6"
+aux have_raid4 && levels="4 5 6"
+
aux prepare_pvs 6 80
vgcreate -s 256K $vg $(cat DEVICES)
@@ -37,7 +40,7 @@ for deactivate in true false; do
#check raid_images_contiguous $vg $lv1
# Extend and reduce 3-striped RAID 4/5/6
- for i in 4 5 6 ; do
+ for i in $levels ; do
lvcreate --type raid$i -i 3 -l 3 -n $lv2 $vg
test $deactivate && {
@@ -59,7 +62,7 @@ done
# Bug 1005434
# Ensure extend is contiguous
-lvcreate --type raid4 -l 2 -i 2 -n $lv1 $vg "$dev4" "$dev5" "$dev6"
+lvcreate --type raid5 -l 2 -i 2 -n $lv1 $vg "$dev4" "$dev5" "$dev6"
lvextend -l +2 --alloc contiguous $vg/$lv1
check lv_tree_on $vg $lv1 "$dev4" "$dev5" "$dev6"
6 years, 11 months
master - lvconvert: fix raid repair regression
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e611f82a11fb9c...
Commit: e611f82a11fb9c489e73de8c05447ebe2cc26d9a
Parent: 8270ff5702e0fa846714ac7366aade84b3e85209
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Oct 28 21:45:00 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Oct 28 21:45:00 2016 +0200
lvconvert: fix raid repair regression
Limit prevention to raid1 as intended with commit 8270ff5702e0.
Related to rhbz1311765
---
lib/metadata/raid_manip.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index d15baf6..4d3d63f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -306,6 +306,9 @@ static int _raid_devs_sync_healthy(struct logical_volume *lv)
if (!_raid_in_sync(lv))
return 0;
+ if (!seg_is_raid1(first_seg(lv)))
+ return 1;
+
if (!lv_raid_dev_health(lv, &raid_health))
return_0;
6 years, 11 months
master - lvconvert: prevent non-synced raid1 primary leg repair
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8270ff5702e0fa...
Commit: 8270ff5702e0fa846714ac7366aade84b3e85209
Parent: e118b65d651d921390d3e8bbcac7170c3894d048
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Oct 28 15:54:27 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Oct 28 15:55:10 2016 +0200
lvconvert: prevent non-synced raid1 primary leg repair
(Automatic) repair may not be allowed during the initial sync of an upconverted
linear LV, because the data on the failing, primary leg hasn't been completely
synchronized to the N-1 other legs of the raid1 LV (replacing failed legs during
repair involves discontinuing access to any replaced legs data, thus preventing
data recovery on the primary leg e.g. via dd_rescue).
Even though repair would not cause data loss when adding legs to a fully synced
raid1 LV, we don't have information yet defining this state yet (e.g. a raid1
LV flag telling the fully synchronized status before any legs were added),
hence can't automatically decide to allow to repair.
If nonetheless a repair on a non-synced raid1 LVs is intended, the "--force"
option has to be provided.
Resolves: rhbz1311765
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 4 +-
lib/metadata/raid_manip.c | 60 ++++++++++++++++++++++++++-----------
tools/lvconvert.c | 4 +-
4 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1d0d6dc..49af38a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.167 -
======================================
+ Prevent non-synced raid1 repair unless --force
Prevent raid4 creation/conversion on non-supporting kernels
Add direct striped -> raid4 conversion
Fix raid4 parity image pair position on conversions from striped/raid0*
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 37db89c..cdd4984 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1208,8 +1208,8 @@ int lv_raid_convert(struct logical_volume *lv,
const uint32_t new_region_size,
struct dm_list *allocate_pvs);
int lv_raid_rebuild(struct logical_volume *lv, struct dm_list *rebuild_pvs);
-int lv_raid_replace(struct logical_volume *lv, struct dm_list *remove_pvs,
- struct dm_list *allocate_pvs);
+int lv_raid_replace(struct logical_volume *lv, int force,
+ struct dm_list *remove_pvs, struct dm_list *allocate_pvs);
int lv_raid_remove_missing(struct logical_volume *lv);
int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv);
/* -- metadata/raid_manip.c */
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 25547c4..d15baf6 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -266,19 +266,16 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r
*
* Returns: 1 if in-sync, 0 otherwise.
*/
+#define _RAID_IN_SYNC_RETRIES 6
static int _raid_in_sync(struct logical_volume *lv)
{
+ int retries = _RAID_IN_SYNC_RETRIES;
dm_percent_t sync_percent;
if (seg_is_striped(first_seg(lv)))
return 1;
- if (!lv_raid_percent(lv, &sync_percent)) {
- log_error("Unable to determine sync status of %s/%s.",
- lv->vg->name, lv->name);
- return 0;
- }
- if (sync_percent == DM_PERCENT_0) {
+ do {
/*
* FIXME We repeat the status read here to workaround an
* unresolved kernel bug when we see 0 even though the
@@ -290,14 +287,31 @@ static int _raid_in_sync(struct logical_volume *lv)
lv->vg->name, lv->name);
return 0;
}
- if (sync_percent == DM_PERCENT_100)
+ if (sync_percent > DM_PERCENT_0)
+ break;
+ if (retries == _RAID_IN_SYNC_RETRIES)
log_warn("WARNING: Sync status for %s is inconsistent.",
display_lvname(lv));
- }
+ usleep(500000);
+ } while (--retries);
return (sync_percent == DM_PERCENT_100) ? 1 : 0;
}
+/* Check if RaidLV @lv is synced or any raid legs of @lv are not synced */
+static int _raid_devs_sync_healthy(struct logical_volume *lv)
+{
+ char *raid_health;
+
+ if (!_raid_in_sync(lv))
+ return 0;
+
+ if (!lv_raid_dev_health(lv, &raid_health))
+ return_0;
+
+ return (strchr(raid_health, 'a') || strchr(raid_health, 'D')) ? 0 : 1;
+}
+
/*
* _raid_remove_top_layer
* @lv
@@ -1054,6 +1068,7 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
/*
* _raid_extract_images
* @lv
+ * @force: force a replacement in case of primary mirror leg
* @new_count: The absolute count of images (e.g. '2' for a 2-way mirror)
* @target_pvs: The list of PVs that are candidates for removal
* @shift: If set, use _shift_and_rename_image_components().
@@ -1068,7 +1083,8 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
*
* Returns: 1 on success, 0 on failure
*/
-static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
+static int _raid_extract_images(struct logical_volume *lv,
+ int force, uint32_t new_count,
struct dm_list *target_pvs, int shift,
struct dm_list *extracted_meta_lvs,
struct dm_list *extracted_data_lvs)
@@ -1136,11 +1152,16 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
!lv_is_on_pvs(seg_metalv(seg, s), target_pvs))
continue;
- if (!_raid_in_sync(lv) &&
- (!seg_is_mirrored(seg) || (s == 0))) {
+ /*
+ * Kernel may report raid LV in-sync but still
+ * image devices may not be in-sync or faulty.
+ */
+ if (!_raid_devs_sync_healthy(lv) &&
+ (!seg_is_mirrored(seg) || (s == 0 && !force))) {
log_error("Unable to extract %sRAID image"
- " while RAID array is not in-sync",
- seg_is_mirrored(seg) ? "primary " : "");
+ " while RAID array is not in-sync%s",
+ seg_is_mirrored(seg) ? "primary " : "",
+ seg_is_mirrored(seg) ? " (use --force option to replace)" : "");
return 0;
}
}
@@ -1185,7 +1206,7 @@ static int _raid_remove_images(struct logical_volume *lv,
if (!removal_lvs)
removal_lvs = &removed_lvs;
- if (!_raid_extract_images(lv, new_count, allocate_pvs, 1,
+ if (!_raid_extract_images(lv, 0, new_count, allocate_pvs, 1,
removal_lvs, removal_lvs)) {
log_error("Failed to extract images from %s/%s",
lv->vg->name, lv->name);
@@ -1375,7 +1396,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
return_0;
}
- if (!_raid_extract_images(lv, new_count, splittable_pvs, 1,
+ if (!_raid_extract_images(lv, 0, new_count, splittable_pvs, 1,
&removal_lvs, &data_list)) {
log_error("Failed to extract images from %s/%s",
lv->vg->name, lv->name);
@@ -3869,6 +3890,7 @@ has_enough_space:
* new SubLVS are allocated on PVs on list @allocate_pvs.
*/
static int _lv_raid_rebuild_or_replace(struct logical_volume *lv,
+ int force,
struct dm_list *remove_pvs,
struct dm_list *allocate_pvs,
int rebuild)
@@ -4043,7 +4065,8 @@ try_again:
* supplied - knowing that only the image with the error target
* will be affected.
*/
- if (!_raid_extract_images(lv, raid_seg->area_count - match_count,
+ if (!_raid_extract_images(lv, force,
+ raid_seg->area_count - match_count,
partial_segment_removed ?
&lv->vg->pvs : remove_pvs, 0,
&old_lvs, &old_lvs)) {
@@ -4148,7 +4171,7 @@ skip_alloc:
int lv_raid_rebuild(struct logical_volume *lv,
struct dm_list *rebuild_pvs)
{
- return _lv_raid_rebuild_or_replace(lv, rebuild_pvs, NULL, 1);
+ return _lv_raid_rebuild_or_replace(lv, 0, rebuild_pvs, NULL, 1);
}
/*
@@ -4161,10 +4184,11 @@ int lv_raid_rebuild(struct logical_volume *lv,
* allocating new SubLVs from PVs on list @allocate_pvs.
*/
int lv_raid_replace(struct logical_volume *lv,
+ int force,
struct dm_list *remove_pvs,
struct dm_list *allocate_pvs)
{
- return _lv_raid_rebuild_or_replace(lv, remove_pvs, allocate_pvs, 0);
+ return _lv_raid_rebuild_or_replace(lv, force, remove_pvs, allocate_pvs, 0);
}
int lv_raid_remove_missing(struct logical_volume *lv)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 23b5906..8376565 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1994,7 +1994,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
}
if (lp->replace)
- return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
+ return lv_raid_replace(lv, lp->force, lp->replace_pvh, lp->pvh);
if (lp->repair) {
if (!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
@@ -2017,7 +2017,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (!(failed_pvs = _failed_pv_list(lv->vg)))
return_0;
- if (!lv_raid_replace(lv, failed_pvs, lp->pvh)) {
+ if (!lv_raid_replace(lv, lp->force, failed_pvs, lp->pvh)) {
log_error("Failed to replace faulty devices in %s.",
display_lvname(lv));
return 0;
6 years, 11 months
master - lvconvert: check for supported raid0/raid4 segtypes
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e118b65d651d92...
Commit: e118b65d651d921390d3e8bbcac7170c3894d048
Parent: 61ae07966dfa68e7a03c054b1486136028c5c4a6
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Oct 27 16:44:32 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Oct 27 16:44:32 2016 +0200
lvconvert: check for supported raid0/raid4 segtypes
Validate kernel support for raid0/raid4 on given and
requested segtype before requesting conversions on them.
Because raid10 wasn't present in old RAID targets, add
the same validation to be prepared once we support them.
---
tools/lvconvert.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 90642aa..23b5906 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1963,16 +1963,24 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if ((seg_is_linear(seg) || seg_is_striped(seg) || seg_is_mirrored(seg) || lv_is_raid(lv)) &&
(lp->type_str && lp->type_str[0])) {
- /* Activation is required later which precludes existing unsupported raid0 segment */
- if (segtype_is_any_raid0(lp->segtype) &&
+ /* Activation is required later which precludes existing supported raid0 segment */
+ if ((seg_is_any_raid0(seg) || segtype_is_any_raid0(lp->segtype)) &&
!(lp->target_attr & RAID_FEATURE_RAID0)) {
log_error("RAID module does not support RAID0.");
return 0;
}
+ /* Activation is required later which precludes existing supported raid4 segment */
if (!_raid4_conversion_supported(lv, lp))
return 0;
+ /* Activation is required later which precludes existing supported raid10 segment */
+ if ((seg_is_raid10(seg) || segtype_is_raid10(lp->segtype)) &&
+ !(lp->target_attr & RAID_FEATURE_RAID10)) {
+ log_error("RAID module does not support RAID10.");
+ return 0;
+ }
+
if (!arg_is_set(cmd, stripes_long_ARG))
lp->stripes = 0;
6 years, 11 months
master - lvconvert-raid-takeover.sh: fix test
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=61ae07966dfa68...
Commit: 61ae07966dfa68e7a03c054b1486136028c5c4a6
Parent: ff05ed7afd16048b64ee3bd94476b1d19e5022db
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Oct 27 16:38:15 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Oct 27 16:38:15 2016 +0200
lvconvert-raid-takeover.sh: fix test
---
test/shell/lvconvert-raid-takeover.sh | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-takeover.sh b/test/shell/lvconvert-raid-takeover.sh
index 332786d..c1cb1aa 100644
--- a/test/shell/lvconvert-raid-takeover.sh
+++ b/test/shell/lvconvert-raid-takeover.sh
@@ -16,7 +16,8 @@ SKIP_WITH_LVMPOLLD=1
aux have_raid 1 9 0 || skip
-[ `aux have_raid 1.9.1` ] && correct_raid4_layout=1
+correct_raid4_layout=0
+aux have_raid 1 9 1 && correct_raid4_layout=1
aux prepare_vg 9 288
6 years, 11 months
master - lvchange/vgchange/lvconvert: prevent raid4 creation/activation/conversion on non-supporting raid targets
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff05ed7afd1604...
Commit: ff05ed7afd16048b64ee3bd94476b1d19e5022db
Parent: e84f527cd37fa713774e30c63509bfeef8271618
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Oct 27 11:38:16 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Oct 27 11:42:07 2016 +0200
lvchange/vgchange/lvconvert: prevent raid4 creation/activation/conversion on non-supporting raid targets
Check for dm-raid target version with non-standard raid4 mapping expecting the dedicated
parity device in the last rather than the first slot and prohibit to create, activate or
convert to such LVs from striped/raid0* or vice-versa in order to avoid data corruption.
Add related tests to lvconvert-raid-takeover.sh
Resolves: rhbz1388962
---
WHATS_NEW | 1 +
lib/activate/activate.c | 25 +++++++++++++++++++++++++
lib/activate/activate.h | 3 ++-
lib/metadata/lv.c | 16 +++++++++++++++-
lib/metadata/segtype.h | 3 ++-
lib/raid/raid.c | 10 ++++++++--
test/shell/lvconvert-raid-takeover.sh | 13 +++++++++++++
tools/lvconvert.c | 25 +++++++++++++++++++++++++
tools/lvcreate.c | 6 ++++++
9 files changed, 97 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3a8e006..1d0d6dc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.167 -
======================================
+ Prevent raid4 creation/conversion on non-supporting kernels
Add direct striped -> raid4 conversion
Fix raid4 parity image pair position on conversions from striped/raid0*
Fix a few unconverted return code values for some lvconvert error path.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 5550955..571f2b2 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -370,6 +370,11 @@ void activation_exit(void)
{
}
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
+{
+ return 1;
+}
+
int lv_is_active(const struct logical_volume *lv)
{
return 0;
@@ -1489,6 +1494,26 @@ out:
return r || l;
}
+/*
+ * Check if "raid4" @segtype is supported by kernel.
+ *
+ * if segment type is not raid4, return 1.
+ */
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
+{
+ unsigned attrs;
+
+ if (segtype_is_raid4(segtype) &&
+ (!segtype->ops->target_present ||
+ !segtype->ops->target_present(cmd, NULL, &attrs) ||
+ !(attrs & RAID_FEATURE_RAID4))) {
+ log_error("RAID module does not support RAID4.");
+ return 0;
+ }
+
+ return 1;
+}
+
int lv_is_active(const struct logical_volume *lv)
{
return _lv_is_active(lv, NULL, NULL, NULL);
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 1e8d7a8..3922d78 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -99,6 +99,7 @@ int target_present(struct cmd_context *cmd, const char *target_name,
int use_modprobe);
int target_version(const char *target_name, uint32_t *maj,
uint32_t *min, uint32_t *patchlevel);
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
int lvm_dm_prefix_check(int major, int minor, const char *prefix);
int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
struct dm_list *modules);
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 70036f9..14370bb 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -1418,6 +1418,7 @@ int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
enum activation_change activate, int needs_exclusive)
{
const char *ay_with_mode = NULL;
+ struct lv_segment *seg = first_seg(lv);
if (activate == CHANGE_ASY)
ay_with_mode = "sh";
@@ -1454,6 +1455,9 @@ deactivate:
break;
case CHANGE_ALY:
case CHANGE_AAY:
+ if (!raid4_is_supported(cmd, seg->segtype))
+ goto no_raid4;
+
if (needs_exclusive || _lv_is_exclusive(lv)) {
log_verbose("Activating logical volume %s exclusively locally.",
display_lvname(lv));
@@ -1468,6 +1472,9 @@ deactivate:
break;
case CHANGE_AEY:
exclusive:
+ if (!raid4_is_supported(cmd, seg->segtype))
+ goto no_raid4;
+
log_verbose("Activating logical volume %s exclusively.",
display_lvname(lv));
if (!activate_lv_excl(cmd, lv))
@@ -1476,6 +1483,9 @@ exclusive:
case CHANGE_ASY:
case CHANGE_AY:
default:
+ if (!raid4_is_supported(cmd, seg->segtype))
+ goto no_raid4;
+
if (needs_exclusive || _lv_is_exclusive(lv))
goto exclusive;
log_verbose("Activating logical volume %s.", display_lvname(lv));
@@ -1488,6 +1498,10 @@ exclusive:
log_error("Failed to unlock logical volume %s.", display_lvname(lv));
return 1;
+
+no_raid4:
+ log_error("Failed to activate %s LV %s", lvseg_name(seg), display_lvname(lv));
+ return 0;
}
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 9ca740d..292b8b6 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -268,6 +268,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
#define RAID_FEATURE_RAID10 (1U << 0) /* version 1.3 */
#define RAID_FEATURE_RAID0 (1U << 1) /* version 1.7 */
#define RAID_FEATURE_RESHAPING (1U << 2) /* version 1.8 */
+#define RAID_FEATURE_RAID4 (1U << 3) /* ! version 1.8 or 1.9.0 */
#ifdef RAID_INTERNAL
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 3bc3c75..92a96a3 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -366,7 +366,7 @@ static int _raid_target_present(struct cmd_context *cmd,
static int _raid_checked = 0;
static int _raid_present = 0;
- static int _raid_attrs = 0;
+ static unsigned _raid_attrs = 0;
uint32_t maj, min, patchlevel;
unsigned i;
@@ -389,6 +389,12 @@ static int _raid_target_present(struct cmd_context *cmd,
else
log_very_verbose("Target raid does not support %s.",
_features[i].feature);
+
+ if (!(maj == 1 && (min == 8 || (min == 9 && patchlevel == 0))))
+ _raid_attrs |= RAID_FEATURE_RAID4;
+ else
+ log_very_verbose("Target raid does not support %s.",
+ SEG_TYPE_NAME_RAID4);
}
if (attributes)
diff --git a/test/shell/lvconvert-raid-takeover.sh b/test/shell/lvconvert-raid-takeover.sh
index 0140e22..332786d 100644
--- a/test/shell/lvconvert-raid-takeover.sh
+++ b/test/shell/lvconvert-raid-takeover.sh
@@ -16,6 +16,8 @@ SKIP_WITH_LVMPOLLD=1
aux have_raid 1 9 0 || skip
+[ `aux have_raid 1.9.1` ] && correct_raid4_layout=1
+
aux prepare_vg 9 288
# Delay 1st leg so that rebuilding status characters
@@ -99,6 +101,9 @@ check lv_field $vg/$lv3 stripes 3
echo y | mkfs -t ext4 /dev/mapper/$vg-$lv3
fsck -fn /dev/mapper/$vg-$lv3
+if [ $correct_raid4_layout -eq 1 ]
+then
+
# Create 3-way raid4
lvcreate -y -aey --type raid4 -i 3 -L 64M -n $lv4 $vg
check lv_field $vg/$lv4 segtype "raid4"
@@ -164,4 +169,12 @@ check lv_field $vg/$lv1 segtype "striped"
check lv_field $vg/$lv1 stripes 3
fsck -fn /dev/mapper/$vg-$lv1
+else
+
+not lvcreate -y -aey --type raid4 -i 3 -L 64M -n $lv4 $vg
+not lvconvert -y --ty raid4 $vg/$lv1
+not lvconvert -y --ty raid4 $vg/$lv2
+
+fi
+
vgremove -ff $vg
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 772c268..90642aa 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1828,6 +1828,25 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd,
}
}
+/* Check for dm-raid target supporting raid4 conversion properly. */
+static int _raid4_conversion_supported(struct logical_volume *lv, struct lvconvert_params *lp)
+{
+ int ret = 1;
+ struct lv_segment *seg = first_seg(lv);
+
+ if (seg_is_raid4(seg))
+ ret = raid4_is_supported(lv->vg->cmd, seg->segtype);
+ else if (segtype_is_raid4(lp->segtype))
+ ret = raid4_is_supported(lv->vg->cmd, lp->segtype);
+
+ if (ret)
+ return 1;
+
+ log_error("Cannot convert %s LV %s to %s.",
+ lvseg_name(seg), display_lvname(lv), lp->segtype->name);
+ return 0;
+}
+
static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp)
{
int replace = 0, image_count = 0;
@@ -1951,6 +1970,9 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 0;
}
+ if (!_raid4_conversion_supported(lv, lp))
+ return 0;
+
if (!arg_is_set(cmd, stripes_long_ARG))
lp->stripes = 0;
@@ -2008,6 +2030,9 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
try_new_takeover_or_reshape:
+ if (!_raid4_conversion_supported(lv, lp))
+ return 0;
+
/* FIXME This needs changing globally. */
if (!arg_is_set(cmd, stripes_long_ARG))
lp->stripes = 0;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 387c8d4..dbc0708 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1054,6 +1054,12 @@ static int _lvcreate_params(struct cmd_context *cmd,
return 0;
}
+ if (segtype_is_raid4(lp->segtype) &&
+ !(lp->target_attr & RAID_FEATURE_RAID4)) {
+ log_error("RAID module does not support RAID4.");
+ return 0;
+ }
+
if (segtype_is_raid10(lp->segtype) && !(lp->target_attr & RAID_FEATURE_RAID10)) {
log_error("RAID module does not support RAID10.");
return 0;
6 years, 11 months
master - lvconvert: revert to only letting raid4 through to lv_raid_convert()
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e84f527cd37fa7...
Commit: e84f527cd37fa713774e30c63509bfeef8271618
Parent: 0468f5da6d2542a2a9c03df2c9e5adf3fed2131d
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Oct 26 17:47:48 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Oct 26 17:54:19 2016 +0200
lvconvert: revert to only letting raid4 through to lv_raid_convert()
Commit de78e8eae73c allowed to let any raid layout through
which we want to avoid until further validation cleanups.
Related to rhbz1386184
---
tools/lvconvert.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 1fbe1ea..772c268 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1937,7 +1937,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 1;
}
goto try_new_takeover_or_reshape;
- } else if (!lp->repair && !lp->replace && !*lp->type_str) {
+ } else if (!lp->repair && !lp->replace && (!*lp->type_str || seg->segtype == lp->segtype)) {
log_error("Conversion operation not yet supported.");
return 0;
}
@@ -2005,18 +2005,28 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 1;
}
+
try_new_takeover_or_reshape:
+
/* FIXME This needs changing globally. */
if (!arg_is_set(cmd, stripes_long_ARG))
lp->stripes = 0;
- if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
- lp->region_size, lp->pvh))
- return_0;
+ /* Only let raid4 through for now. */
+ if (lp->type_str && lp->type_str[0] && lp->segtype != seg->segtype &&
+ ((seg_is_raid4(seg) && seg_is_striped(lp) && lp->stripes > 1) ||
+ (seg_is_striped(seg) && seg->area_count > 1 && seg_is_raid4(lp)))) {
+ if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
+ lp->region_size, lp->pvh))
+ return_0;
- log_print_unless_silent("Logical volume %s successfully converted.",
- display_lvname(lv));
- return 1;
+ log_print_unless_silent("Logical volume %s successfully converted.",
+ display_lvname(lv));
+ return 1;
+ }
+
+ log_error("Conversion operation not yet supported.");
+ return 0;
}
static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volume *cow,
6 years, 11 months
master - raid_manip: fix typo
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0468f5da6d2542...
Commit: 0468f5da6d2542a2a9c03df2c9e5adf3fed2131d
Parent: 021715e897016212beb4123b25239338ab49707e
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Oct 26 17:46:53 2016 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Oct 26 17:53:55 2016 +0200
raid_manip: fix typo
Related to rhbz1386184
---
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 39d27f1..25547c4 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -3056,7 +3056,7 @@ static int _raid456_to_raid0_or_striped_wrapper(TAKEOVER_FN_ARGS)
return 0;
if (!yes && yes_no_prompt("Are you sure you want to convert \"%s\" LV %s to \"%s\" "
- "type using all resilience? [y/n]: ",
+ "type losing all resilience? [y/n]: ",
lvseg_name(seg), display_lvname(lv), new_segtype->name) == 'n') {
log_error("Logical volume %s NOT converted to \"%s\"",
display_lvname(lv), new_segtype->name);
6 years, 11 months
master - dmsetup: remove stray '\n' in delete log message
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=021715e8970162...
Commit: 021715e897016212beb4123b25239338ab49707e
Parent: 5eda3934885b23ce06f862a56b524ceaab3cb565
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Oct 24 17:21:35 2016 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Oct 24 17:21:35 2016 +0100
dmsetup: remove stray '\n' in delete log message
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index ec64d24..42f0b05 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -5323,7 +5323,7 @@ static int _stats_delete(CMD_ARGS)
log_error("Could not delete statistics region");
goto out;
}
- log_info("Deleted statistics region " FMTu64 ".\n", region_id);
+ log_info("Deleted statistics region " FMTu64 ".", region_id);
}
r = 1;
6 years, 11 months
master - dmsetup: obey --programid when deleting regions
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5eda3934885b23...
Commit: 5eda3934885b23ce06f862a56b524ceaab3cb565
Parent: de78e8eae73cb155fdb906ef2b8ddc9ca1a918c4
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Oct 24 17:21:18 2016 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Oct 24 17:21:18 2016 +0100
dmsetup: obey --programid when deleting regions
---
tools/dmsetup.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 9d357ec..ec64d24 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -5278,6 +5278,8 @@ static int _stats_delete(CMD_ARGS)
name = argv[0];
}
+ if (_switches[PROGRAM_ID_ARG])
+ program_id = _string_args[PROGRAM_ID_ARG];
if (_switches[ALL_PROGRAMS_ARG])
program_id = DM_STATS_ALL_PROGRAMS;
6 years, 11 months