|
|
f15685 |
WHATS_NEW | 1 +
|
|
|
f15685 |
lib/activate/activate.c | 25 +++++++++++++++++++++++++
|
|
|
f15685 |
lib/activate/activate.h | 3 ++-
|
|
|
f15685 |
lib/metadata/lv.c | 16 +++++++++++++++-
|
|
|
f15685 |
lib/metadata/segtype.h | 3 ++-
|
|
|
f15685 |
lib/raid/raid.c | 10 ++++++++--
|
|
|
f15685 |
test/shell/lvconvert-raid-takeover.sh | 13 +++++++++++++
|
|
|
f15685 |
tools/lvconvert.c | 26 ++++++++++++++++++++++++++
|
|
|
f15685 |
tools/lvcreate.c | 6 ++++++
|
|
|
f15685 |
9 files changed, 98 insertions(+), 5 deletions(-)
|
|
|
f15685 |
|
|
|
f15685 |
diff --git a/WHATS_NEW b/WHATS_NEW
|
|
|
f15685 |
index 6a0c311..519bbc9 100644
|
|
|
f15685 |
--- a/WHATS_NEW
|
|
|
f15685 |
+++ b/WHATS_NEW
|
|
|
f15685 |
@@ -1,5 +1,6 @@
|
|
|
f15685 |
Version 2.02.167 -
|
|
|
f15685 |
======================================
|
|
|
f15685 |
+ Prevent raid4 creation/conversion on non-supporting kernels
|
|
|
f15685 |
Add direct striped -> raid4 conversion
|
|
|
f15685 |
Fix raid4 parity image pair position on conversions from striped/raid0*
|
|
|
f15685 |
Disable lvconvert of thin pool to raid while active.
|
|
|
f15685 |
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
|
|
|
f15685 |
index 5550955..571f2b2 100644
|
|
|
f15685 |
--- a/lib/activate/activate.c
|
|
|
f15685 |
+++ b/lib/activate/activate.c
|
|
|
f15685 |
@@ -370,6 +370,11 @@ void activation_exit(void)
|
|
|
f15685 |
{
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
|
|
|
f15685 |
+{
|
|
|
f15685 |
+ return 1;
|
|
|
f15685 |
+}
|
|
|
f15685 |
+
|
|
|
f15685 |
int lv_is_active(const struct logical_volume *lv)
|
|
|
f15685 |
{
|
|
|
f15685 |
return 0;
|
|
|
f15685 |
@@ -1489,6 +1494,26 @@ out:
|
|
|
f15685 |
return r || l;
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
+/*
|
|
|
f15685 |
+ * Check if "raid4" @segtype is supported by kernel.
|
|
|
f15685 |
+ *
|
|
|
f15685 |
+ * if segment type is not raid4, return 1.
|
|
|
f15685 |
+ */
|
|
|
f15685 |
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
|
|
|
f15685 |
+{
|
|
|
f15685 |
+ unsigned attrs;
|
|
|
f15685 |
+
|
|
|
f15685 |
+ if (segtype_is_raid4(segtype) &&
|
|
|
f15685 |
+ (!segtype->ops->target_present ||
|
|
|
f15685 |
+ !segtype->ops->target_present(cmd, NULL, &attrs) ||
|
|
|
f15685 |
+ !(attrs & RAID_FEATURE_RAID4))) {
|
|
|
f15685 |
+ log_error("RAID module does not support RAID4.");
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
+ }
|
|
|
f15685 |
+
|
|
|
f15685 |
+ return 1;
|
|
|
f15685 |
+}
|
|
|
f15685 |
+
|
|
|
f15685 |
int lv_is_active(const struct logical_volume *lv)
|
|
|
f15685 |
{
|
|
|
f15685 |
return _lv_is_active(lv, NULL, NULL, NULL);
|
|
|
f15685 |
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
|
|
|
f15685 |
index 1e8d7a8..3922d78 100644
|
|
|
f15685 |
--- a/lib/activate/activate.h
|
|
|
f15685 |
+++ b/lib/activate/activate.h
|
|
|
f15685 |
@@ -1,6 +1,6 @@
|
|
|
f15685 |
/*
|
|
|
f15685 |
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
|
|
f15685 |
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
*
|
|
|
f15685 |
* This file is part of LVM2.
|
|
|
f15685 |
*
|
|
|
f15685 |
@@ -99,6 +99,7 @@ int target_present(struct cmd_context *cmd, const char *target_name,
|
|
|
f15685 |
int use_modprobe);
|
|
|
f15685 |
int target_version(const char *target_name, uint32_t *maj,
|
|
|
f15685 |
uint32_t *min, uint32_t *patchlevel);
|
|
|
f15685 |
+int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
|
|
|
f15685 |
int lvm_dm_prefix_check(int major, int minor, const char *prefix);
|
|
|
f15685 |
int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
|
|
|
f15685 |
struct dm_list *modules);
|
|
|
f15685 |
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
|
|
|
f15685 |
index 53a1044..0f1b6e7 100644
|
|
|
f15685 |
--- a/lib/metadata/lv.c
|
|
|
f15685 |
+++ b/lib/metadata/lv.c
|
|
|
f15685 |
@@ -1,6 +1,6 @@
|
|
|
f15685 |
/*
|
|
|
f15685 |
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
|
|
f15685 |
- * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
*
|
|
|
f15685 |
* This file is part of LVM2.
|
|
|
f15685 |
*
|
|
|
f15685 |
@@ -1425,6 +1425,7 @@ int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
|
|
|
f15685 |
enum activation_change activate, int needs_exclusive)
|
|
|
f15685 |
{
|
|
|
f15685 |
const char *ay_with_mode = NULL;
|
|
|
f15685 |
+ struct lv_segment *seg = first_seg(lv);
|
|
|
f15685 |
|
|
|
f15685 |
if (activate == CHANGE_ASY)
|
|
|
f15685 |
ay_with_mode = "sh";
|
|
|
f15685 |
@@ -1461,6 +1462,9 @@ deactivate:
|
|
|
f15685 |
break;
|
|
|
f15685 |
case CHANGE_ALY:
|
|
|
f15685 |
case CHANGE_AAY:
|
|
|
f15685 |
+ if (!raid4_is_supported(cmd, seg->segtype))
|
|
|
f15685 |
+ goto no_raid4;
|
|
|
f15685 |
+
|
|
|
f15685 |
if (needs_exclusive || _lv_is_exclusive(lv)) {
|
|
|
f15685 |
log_verbose("Activating logical volume %s exclusively locally.",
|
|
|
f15685 |
display_lvname(lv));
|
|
|
f15685 |
@@ -1475,6 +1479,9 @@ deactivate:
|
|
|
f15685 |
break;
|
|
|
f15685 |
case CHANGE_AEY:
|
|
|
f15685 |
exclusive:
|
|
|
f15685 |
+ if (!raid4_is_supported(cmd, seg->segtype))
|
|
|
f15685 |
+ goto no_raid4;
|
|
|
f15685 |
+
|
|
|
f15685 |
log_verbose("Activating logical volume %s exclusively.",
|
|
|
f15685 |
display_lvname(lv));
|
|
|
f15685 |
if (!activate_lv_excl(cmd, lv))
|
|
|
f15685 |
@@ -1483,6 +1490,9 @@ exclusive:
|
|
|
f15685 |
case CHANGE_ASY:
|
|
|
f15685 |
case CHANGE_AY:
|
|
|
f15685 |
default:
|
|
|
f15685 |
+ if (!raid4_is_supported(cmd, seg->segtype))
|
|
|
f15685 |
+ goto no_raid4;
|
|
|
f15685 |
+
|
|
|
f15685 |
if (needs_exclusive || _lv_is_exclusive(lv))
|
|
|
f15685 |
goto exclusive;
|
|
|
f15685 |
log_verbose("Activating logical volume %s.", display_lvname(lv));
|
|
|
f15685 |
@@ -1495,6 +1505,10 @@ exclusive:
|
|
|
f15685 |
log_error("Failed to unlock logical volume %s.", display_lvname(lv));
|
|
|
f15685 |
|
|
|
f15685 |
return 1;
|
|
|
f15685 |
+
|
|
|
f15685 |
+no_raid4:
|
|
|
f15685 |
+ log_error("Failed to activate %s LV %s", lvseg_name(seg), display_lvname(lv));
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv)
|
|
|
f15685 |
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
|
|
|
f15685 |
index 9ca740d..292b8b6 100644
|
|
|
f15685 |
--- a/lib/metadata/segtype.h
|
|
|
f15685 |
+++ b/lib/metadata/segtype.h
|
|
|
f15685 |
@@ -1,6 +1,6 @@
|
|
|
f15685 |
/*
|
|
|
f15685 |
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
|
|
f15685 |
- * Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
*
|
|
|
f15685 |
* This file is part of LVM2.
|
|
|
f15685 |
*
|
|
|
f15685 |
@@ -268,6 +268,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
|
|
|
f15685 |
#define RAID_FEATURE_RAID10 (1U << 0) /* version 1.3 */
|
|
|
f15685 |
#define RAID_FEATURE_RAID0 (1U << 1) /* version 1.7 */
|
|
|
f15685 |
#define RAID_FEATURE_RESHAPING (1U << 2) /* version 1.8 */
|
|
|
f15685 |
+#define RAID_FEATURE_RAID4 (1U << 3) /* ! version 1.8 or 1.9.0 */
|
|
|
f15685 |
|
|
|
f15685 |
#ifdef RAID_INTERNAL
|
|
|
f15685 |
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
|
|
|
f15685 |
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
|
|
|
f15685 |
index 3bc3c75..92a96a3 100644
|
|
|
f15685 |
--- a/lib/raid/raid.c
|
|
|
f15685 |
+++ b/lib/raid/raid.c
|
|
|
f15685 |
@@ -1,5 +1,5 @@
|
|
|
f15685 |
/*
|
|
|
f15685 |
- * Copyright (C) 2011-2013 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
+ * Copyright (C) 2011-2016 Red Hat, Inc. All rights reserved.
|
|
|
f15685 |
*
|
|
|
f15685 |
* This file is part of LVM2.
|
|
|
f15685 |
*
|
|
|
f15685 |
@@ -366,7 +366,7 @@ static int _raid_target_present(struct cmd_context *cmd,
|
|
|
f15685 |
|
|
|
f15685 |
static int _raid_checked = 0;
|
|
|
f15685 |
static int _raid_present = 0;
|
|
|
f15685 |
- static int _raid_attrs = 0;
|
|
|
f15685 |
+ static unsigned _raid_attrs = 0;
|
|
|
f15685 |
uint32_t maj, min, patchlevel;
|
|
|
f15685 |
unsigned i;
|
|
|
f15685 |
|
|
|
f15685 |
@@ -389,6 +389,12 @@ static int _raid_target_present(struct cmd_context *cmd,
|
|
|
f15685 |
else
|
|
|
f15685 |
log_very_verbose("Target raid does not support %s.",
|
|
|
f15685 |
_features[i].feature);
|
|
|
f15685 |
+
|
|
|
f15685 |
+ if (!(maj == 1 && (min == 8 || (min == 9 && patchlevel == 0))))
|
|
|
f15685 |
+ _raid_attrs |= RAID_FEATURE_RAID4;
|
|
|
f15685 |
+ else
|
|
|
f15685 |
+ log_very_verbose("Target raid does not support %s.",
|
|
|
f15685 |
+ SEG_TYPE_NAME_RAID4);
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
if (attributes)
|
|
|
f15685 |
diff --git a/test/shell/lvconvert-raid-takeover.sh b/test/shell/lvconvert-raid-takeover.sh
|
|
|
f15685 |
index 0140e22..332786d 100644
|
|
|
f15685 |
--- a/test/shell/lvconvert-raid-takeover.sh
|
|
|
f15685 |
+++ b/test/shell/lvconvert-raid-takeover.sh
|
|
|
f15685 |
@@ -16,6 +16,8 @@ SKIP_WITH_LVMPOLLD=1
|
|
|
f15685 |
|
|
|
f15685 |
aux have_raid 1 9 0 || skip
|
|
|
f15685 |
|
|
|
f15685 |
+[ `aux have_raid 1.9.1` ] && correct_raid4_layout=1
|
|
|
f15685 |
+
|
|
|
f15685 |
aux prepare_vg 9 288
|
|
|
f15685 |
|
|
|
f15685 |
# Delay 1st leg so that rebuilding status characters
|
|
|
f15685 |
@@ -99,6 +101,9 @@ check lv_field $vg/$lv3 stripes 3
|
|
|
f15685 |
echo y | mkfs -t ext4 /dev/mapper/$vg-$lv3
|
|
|
f15685 |
fsck -fn /dev/mapper/$vg-$lv3
|
|
|
f15685 |
|
|
|
f15685 |
+if [ $correct_raid4_layout -eq 1 ]
|
|
|
f15685 |
+then
|
|
|
f15685 |
+
|
|
|
f15685 |
# Create 3-way raid4
|
|
|
f15685 |
lvcreate -y -aey --type raid4 -i 3 -L 64M -n $lv4 $vg
|
|
|
f15685 |
check lv_field $vg/$lv4 segtype "raid4"
|
|
|
f15685 |
@@ -164,4 +169,12 @@ check lv_field $vg/$lv1 segtype "striped"
|
|
|
f15685 |
check lv_field $vg/$lv1 stripes 3
|
|
|
f15685 |
fsck -fn /dev/mapper/$vg-$lv1
|
|
|
f15685 |
|
|
|
f15685 |
+else
|
|
|
f15685 |
+
|
|
|
f15685 |
+not lvcreate -y -aey --type raid4 -i 3 -L 64M -n $lv4 $vg
|
|
|
f15685 |
+not lvconvert -y --ty raid4 $vg/$lv1
|
|
|
f15685 |
+not lvconvert -y --ty raid4 $vg/$lv2
|
|
|
f15685 |
+
|
|
|
f15685 |
+fi
|
|
|
f15685 |
+
|
|
|
f15685 |
vgremove -ff $vg
|
|
|
f15685 |
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
|
|
|
f15685 |
index 541df72..7a4215a 100644
|
|
|
f15685 |
--- a/tools/lvconvert.c
|
|
|
f15685 |
+++ b/tools/lvconvert.c
|
|
|
f15685 |
@@ -1821,6 +1821,25 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd,
|
|
|
f15685 |
}
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
+/* Check for dm-raid target supporting raid4 conversion properly. */
|
|
|
f15685 |
+static int _raid4_conversion_supported(struct logical_volume *lv, struct lvconvert_params *lp)
|
|
|
f15685 |
+{
|
|
|
f15685 |
+ int ret = 1;
|
|
|
f15685 |
+ struct lv_segment *seg = first_seg(lv);
|
|
|
f15685 |
+
|
|
|
f15685 |
+ if (seg_is_raid4(seg))
|
|
|
f15685 |
+ ret = raid4_is_supported(lv->vg->cmd, seg->segtype);
|
|
|
f15685 |
+ else if (segtype_is_raid4(lp->segtype))
|
|
|
f15685 |
+ ret = raid4_is_supported(lv->vg->cmd, lp->segtype);
|
|
|
f15685 |
+
|
|
|
f15685 |
+ if (ret)
|
|
|
f15685 |
+ return 1;
|
|
|
f15685 |
+
|
|
|
f15685 |
+ log_error("Cannot convert %s LV %s to %s.",
|
|
|
f15685 |
+ lvseg_name(seg), display_lvname(lv), lp->segtype->name);
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
+}
|
|
|
f15685 |
+
|
|
|
f15685 |
static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp)
|
|
|
f15685 |
{
|
|
|
f15685 |
int replace = 0, image_count = 0;
|
|
|
f15685 |
@@ -1945,6 +1964,9 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
|
|
f15685 |
return 0;
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
+ if (!_raid4_conversion_supported(lv, lp))
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
+
|
|
|
f15685 |
if (!arg_is_set(cmd, stripes_long_ARG))
|
|
|
f15685 |
lp->stripes = 0;
|
|
|
f15685 |
|
|
|
f15685 |
@@ -2018,6 +2040,10 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
try_new_takeover_or_reshape:
|
|
|
f15685 |
+
|
|
|
f15685 |
+ if (!_raid4_conversion_supported(lv, lp))
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
+
|
|
|
f15685 |
/* FIXME This needs changing globally. */
|
|
|
f15685 |
if (!arg_is_set(cmd, stripes_long_ARG))
|
|
|
f15685 |
lp->stripes = 0;
|
|
|
f15685 |
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
|
|
|
f15685 |
index 387c8d4..dbc0708 100644
|
|
|
f15685 |
--- a/tools/lvcreate.c
|
|
|
f15685 |
+++ b/tools/lvcreate.c
|
|
|
f15685 |
@@ -1054,6 +1054,12 @@ static int _lvcreate_params(struct cmd_context *cmd,
|
|
|
f15685 |
return 0;
|
|
|
f15685 |
}
|
|
|
f15685 |
|
|
|
f15685 |
+ if (segtype_is_raid4(lp->segtype) &&
|
|
|
f15685 |
+ !(lp->target_attr & RAID_FEATURE_RAID4)) {
|
|
|
f15685 |
+ log_error("RAID module does not support RAID4.");
|
|
|
f15685 |
+ return 0;
|
|
|
f15685 |
+ }
|
|
|
f15685 |
+
|
|
|
f15685 |
if (segtype_is_raid10(lp->segtype) && !(lp->target_attr & RAID_FEATURE_RAID10)) {
|
|
|
f15685 |
log_error("RAID module does not support RAID10.");
|
|
|
f15685 |
return 0;
|