master - lockd: fix changing lock type on VG with pool
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d40830a2b13595...
Commit: d40830a2b13595943ca51d4bfd6249527a0972cf
Parent: 028715b0f07c0cb9740f8bd81e3d69a29c3341d2
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Sep 24 13:59:13 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Sep 24 14:03:20 2015 -0500
lockd: fix changing lock type on VG with pool
vgchange --lock-type iterates through LVs to ensure
no LVs are active before changing the lock type of
the VG, but the loop was not checking that an LV
actually has a lock before trying it, so it would
fail if the VG had any LVs that don't use locks,
e.g it would fail on a tmeta LV from a pool.
---
lib/locking/lvmlockd.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index e20920c..afbafcb 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -879,6 +879,9 @@ static int _lockd_all_lvs(struct cmd_context *cmd, struct volume_group *vg)
struct lv_list *lvl;
dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!lockd_lv_uses_lock(lvl->lv))
+ continue;
+
if (!lockd_lv(cmd, lvl->lv, "ex", 0)) {
log_error("LV %s/%s must be inactive on all hosts.",
vg->name, lvl->lv->name);
8 years, 7 months
master - raid: Detect whether or not kernel supports raid0.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=028715b0f07c0c...
Commit: 028715b0f07c0cb9740f8bd81e3d69a29c3341d2
Parent: 4a74e19f80958e0eafeb49ef7a346ba7421b5698
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Sep 24 19:52:22 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 19:59:29 2015 +0100
raid: Detect whether or not kernel supports raid0.
---
lib/metadata/segtype.h | 3 +++
lib/raid/raid.c | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index a14f9d0..fd833cd 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -60,6 +60,7 @@ struct dev_manager;
#define SEG_TYPE_NAME_FREE "free"
#define SEG_TYPE_NAME_ZERO "zero"
#define SEG_TYPE_NAME_RAID "raid"
+#define SEG_TYPE_NAME_RAID0 "raid0"
#define SEG_TYPE_NAME_RAID1 "raid1"
#define SEG_TYPE_NAME_RAID10 "raid10"
#define SEG_TYPE_NAME_RAID4 "raid4"
@@ -205,6 +206,8 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
const char *name);
#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 */
#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 13b9b6e..df22b54 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -331,6 +331,7 @@ static int _raid_target_present(struct cmd_context *cmd,
const char *feature;
} _features[] = {
{ 1, 3, RAID_FEATURE_RAID10, SEG_TYPE_NAME_RAID10 },
+ { 1, 7, RAID_FEATURE_RAID0, SEG_TYPE_NAME_RAID0 },
};
static int _raid_checked = 0;
8 years, 7 months
master - alloc: Move _calc_area_multiple.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a74e19f80958e...
Commit: 4a74e19f80958e0eafeb49ef7a346ba7421b5698
Parent: e773e719109ad54c289f86a54b316e787f0110c8
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Sep 24 17:56:19 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 17:56:19 2015 +0100
alloc: Move _calc_area_multiple.
---
lib/metadata/lv_manip.c | 90 +++++++++++++++++++++++-----------------------
1 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 429a487..02a43b7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1264,6 +1264,51 @@ static int _lv_segment_add_areas(struct logical_volume *lv,
return 1;
}
+static uint32_t _calc_area_multiple(const struct segment_type *segtype,
+ const uint32_t area_count,
+ const uint32_t stripes)
+{
+ if (!area_count)
+ return 1;
+
+ /* Striped */
+ if (segtype_is_striped(segtype))
+ return area_count;
+
+ /* Parity RAID (e.g. RAID 4/5/6) */
+ if (segtype_is_raid(segtype) && segtype->parity_devs) {
+ /*
+ * As articulated in _alloc_init, we can tell by
+ * the area_count whether a replacement drive is
+ * being allocated; and if this is the case, then
+ * there is no area_multiple that should be used.
+ */
+ if (area_count <= segtype->parity_devs)
+ return 1;
+
+ return area_count - segtype->parity_devs;
+ }
+
+ /*
+ * RAID10 - only has 2-way mirror right now.
+ * If we are to move beyond 2-way RAID10, then
+ * the 'stripes' argument will always need to
+ * be given.
+ */
+ if (!strcmp(segtype->name, _lv_type_names[LV_TYPE_RAID10])) {
+ if (!stripes)
+ return area_count / 2;
+ return stripes;
+ }
+
+ /* Mirrored stripes */
+ if (stripes)
+ return stripes;
+
+ /* Mirrored */
+ return 1;
+}
+
/*
* Reduce the size of an lv_segment. New size can be zero.
*/
@@ -1519,51 +1564,6 @@ struct alloc_handle {
struct dm_list alloced_areas[0];
};
-static uint32_t _calc_area_multiple(const struct segment_type *segtype,
- const uint32_t area_count,
- const uint32_t stripes)
-{
- if (!area_count)
- return 1;
-
- /* Striped */
- if (segtype_is_striped(segtype))
- return area_count;
-
- /* Parity RAID (e.g. RAID 4/5/6) */
- if (segtype_is_raid(segtype) && segtype->parity_devs) {
- /*
- * As articulated in _alloc_init, we can tell by
- * the area_count whether a replacement drive is
- * being allocated; and if this is the case, then
- * there is no area_multiple that should be used.
- */
- if (area_count <= segtype->parity_devs)
- return 1;
-
- return area_count - segtype->parity_devs;
- }
-
- /*
- * RAID10 - only has 2-way mirror right now.
- * If we are to move beyond 2-way RAID10, then
- * the 'stripes' argument will always need to
- * be given.
- */
- if (!strcmp(segtype->name, _lv_type_names[LV_TYPE_RAID10])) {
- if (!stripes)
- return area_count / 2;
- return stripes;
- }
-
- /* Mirrored stripes */
- if (stripes)
- return stripes;
-
- /* Mirrored */
- return 1;
-}
-
/*
* Returns log device size in extents, algorithm from kernel code
*/
8 years, 7 months
master - stripes: Introduce _round_to_stripe_boundary.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e773e719109ad5...
Commit: e773e719109ad54c289f86a54b316e787f0110c8
Parent: 39a97d86f09df0d89664c7ddae28ca1d1bb3a741
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Sep 24 17:50:53 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 17:50:53 2015 +0100
stripes: Introduce _round_to_stripe_boundary.
---
lib/metadata/lv_manip.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ac3d25f..429a487 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -941,6 +941,26 @@ dm_percent_t copy_percent(const struct logical_volume *lv)
return denominator ? dm_make_percent(numerator, denominator) : 100.0;
}
+/* Round up extents to next stripe boundary for number of stripes */
+static uint32_t _round_to_stripe_boundary(struct volume_group *vg, uint32_t extents,
+ uint32_t stripes, int extend)
+{
+ uint32_t size_rest, new_extents = extents;
+
+ if (!stripes)
+ return extents;
+
+ /* Round up extents to stripe divisible amount */
+ if ((size_rest = extents % stripes)) {
+ new_extents += extend ? stripes - size_rest : -size_rest;
+ log_print_unless_silent("Rounding size %s (%d extents) up to stripe boundary size %s (%d extents).",
+ display_size(vg->cmd, extents * vg->extent_size), extents,
+ display_size(vg->cmd, new_extents * vg->extent_size), new_extents);
+ }
+
+ return new_extents;
+}
+
/*
* All lv_segments get created here.
*/
@@ -6933,7 +6953,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
const char *new_lv_name)
{
struct cmd_context *cmd = vg->cmd;
- uint32_t size_rest, size;
+ uint32_t size;
uint64_t status = lp->permission | VISIBLE_LV;
const struct segment_type *create_segtype = lp->segtype;
struct logical_volume *lv, *origin_lv = NULL;
@@ -6998,12 +7018,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->stripe_size = vg->extent_size;
}
- if ((size_rest = lp->extents % lp->stripes)) {
- log_print_unless_silent("Rounding size (%d extents) up to stripe boundary "
- "size (%d extents).", lp->extents,
- lp->extents - size_rest + lp->stripes);
- lp->extents = lp->extents - size_rest + lp->stripes;
- }
+ lp->extents = _round_to_stripe_boundary(vg, lp->extents, lp->stripes, 1);
if (!lp->extents && !seg_is_thin_volume(lp)) {
log_error(INTERNAL_ERROR "Unable to create new logical volume with no extents.");
8 years, 7 months
master - segtypes: Add and use new segtype macros.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=39a97d86f09df0...
Commit: 39a97d86f09df0d89664c7ddae28ca1d1bb3a741
Parent: 41fe225b0deecea871354b321d23fad548857518
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Sep 24 14:59:07 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 14:59:07 2015 +0100
segtypes: Add and use new segtype macros.
Includes fixing an inverted raid10 segtype check in _raid_add_target_line.
---
lib/activate/dev_manager.c | 10 +++++-----
lib/metadata/lv_manip.c | 31 +++++++++++++++----------------
lib/metadata/mirror.c | 2 +-
lib/metadata/raid_manip.c | 16 +++++++---------
lib/metadata/segtype.h | 27 +++++++++++++++++++++++++++
lib/raid/raid.c | 2 +-
tools/lvchange.c | 2 +-
tools/lvcreate.c | 14 ++++++--------
8 files changed, 63 insertions(+), 41 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 5a1e18b..a5ee824 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -143,23 +143,23 @@ static int _get_segment_status_from_target_params(const char *target_name,
return 0;
}
- if (!strcmp(segtype->name, SEG_TYPE_NAME_CACHE)) {
+ if (segtype_is_cache(segtype)) {
if (!dm_get_status_cache(seg_status->mem, params, &(seg_status->cache)))
return_0;
seg_status->type = SEG_STATUS_CACHE;
- } else if (!strcmp(segtype->name, SEG_TYPE_NAME_RAID)) {
+ } else if (segtype_is_raid(segtype)) {
if (!dm_get_status_raid(seg_status->mem, params, &seg_status->raid))
return_0;
seg_status->type = SEG_STATUS_RAID;
- } else if (!strcmp(segtype->name, SEG_TYPE_NAME_THIN)) {
+ } else if (segtype_is_thin_volume(segtype)) {
if (!dm_get_status_thin(seg_status->mem, params, &seg_status->thin))
return_0;
seg_status->type = SEG_STATUS_THIN;
- } else if (!strcmp(segtype->name, SEG_TYPE_NAME_THIN_POOL)) {
+ } else if (segtype_is_thin_pool(segtype)) {
if (!dm_get_status_thin_pool(seg_status->mem, params, &seg_status->thin_pool))
return_0;
seg_status->type = SEG_STATUS_THIN_POOL;
- } else if (!strcmp(segtype->name, SEG_TYPE_NAME_SNAPSHOT)) {
+ } else if (segtype_is_snapshot(segtype)) {
if (!dm_get_status_snapshot(seg_status->mem, params, &seg_status->snapshot))
return_0;
seg_status->type = SEG_STATUS_SNAPSHOT;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 69a6b6e..ac3d25f 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -224,7 +224,7 @@ static int _lv_layout_and_role_raid(struct dm_pool *mem,
int *public_lv)
{
int top_level = 0;
- const char *seg_name;
+ const struct segment_type *segtype;
/* non-top-level LVs */
if (lv_is_raid_image(lv)) {
@@ -251,45 +251,45 @@ static int _lv_layout_and_role_raid(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID]))
goto_bad;
- seg_name = first_seg(lv)->segtype->name;
+ segtype = first_seg(lv)->segtype;
- if (!strcmp(seg_name, SEG_TYPE_NAME_RAID1)) {
+ if (segtype_is_raid1(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID1]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID10)) {
+ } else if (segtype_is_raid10(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID10]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID4)) {
+ } else if (segtype_is_raid4(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID4]))
goto_bad;
- } else if (!strncmp(seg_name, SEG_TYPE_NAME_RAID5, strlen(SEG_TYPE_NAME_RAID5))) {
+ } else if (segtype_is_any_raid5(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5]))
goto_bad;
- if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_LA)) {
+ if (segtype_is_raid5_la(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_LA]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_RA)) {
+ } else if (segtype_is_raid5_ra(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_RA]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_LS)) {
+ } else if (segtype_is_raid5_ls(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_LS]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_RS)) {
+ } else if (segtype_is_raid5_rs(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_RS]))
goto_bad;
}
- } else if (!strncmp(seg_name, SEG_TYPE_NAME_RAID6, strlen(SEG_TYPE_NAME_RAID6))) {
+ } else if (segtype_is_any_raid6(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6]))
goto_bad;
- if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_ZR)) {
+ if (segtype_is_raid6_zr(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_ZR]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_NR)) {
+ } else if (segtype_is_raid6_nr(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_NR]))
goto_bad;
- } else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_NC)) {
+ } else if (segtype_is_raid6_nc(segtype)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_NC]))
goto_bad;
}
@@ -3669,8 +3669,7 @@ int lv_add_log_segment(struct alloc_handle *ah, uint32_t first_area,
{
return lv_add_segment(ah, ah->area_count + first_area, 1, log_lv,
- get_segtype_from_string(log_lv->vg->cmd,
- SEG_TYPE_NAME_STRIPED),
+ get_segtype_from_string(log_lv->vg->cmd, SEG_TYPE_NAME_STRIPED),
0, status, 0);
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index d4d2104..8166e89 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -112,7 +112,7 @@ uint32_t lv_mirror_count(const struct logical_volume *lv)
seg = first_seg(lv);
/* FIXME: RAID10 only supports 2 copies right now */
- if (!strcmp(seg->segtype->name, SEG_TYPE_NAME_RAID10))
+ if (seg_is_raid10(seg))
return 2;
if (lv_is_pvmove(lv))
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 87e6c8c..5919e3b 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1102,7 +1102,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
}
if (!seg_is_mirrored(first_seg(lv)) ||
- !strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ seg_is_raid10(first_seg(lv))) {
log_error("Unable to split logical volume of segment type, %s",
lvseg_name(first_seg(lv)));
return 0;
@@ -1475,13 +1475,11 @@ int lv_raid_reshape(struct logical_volume *lv,
return 0;
}
- if (!strcmp(seg->segtype->name, SEG_TYPE_NAME_MIRROR) &&
- (!strcmp(new_segtype->name, SEG_TYPE_NAME_RAID1)))
- return _convert_mirror_to_raid1(lv, new_segtype);
+ if (seg_is_mirror(seg) && segtype_is_raid1(new_segtype))
+ return _convert_mirror_to_raid1(lv, new_segtype);
- log_error("Converting the segment type for %s/%s from %s to %s"
- " is not yet supported.", lv->vg->name, lv->name,
- lvseg_name(seg), new_segtype->name);
+ log_error("Converting the segment type for %s/%s from %s to %s is not yet supported.",
+ lv->vg->name, lv->name, lvseg_name(seg), new_segtype->name);
return 0;
}
@@ -1663,7 +1661,7 @@ int lv_raid_replace(struct logical_volume *lv,
lvseg_name(raid_seg),
lv->vg->name, lv->name);
return 0;
- } else if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ } else if (seg_is_raid10(raid_seg)) {
uint32_t i, rebuilds_per_group = 0;
/* FIXME: We only support 2-way mirrors in RAID10 currently */
uint32_t copies = 2;
@@ -1895,7 +1893,7 @@ static int _partial_raid_lv_is_redundant(const struct logical_volume *lv)
uint32_t i, s, rebuilds_per_group = 0;
uint32_t failed_components = 0;
- if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ if (seg_is_raid10(raid_seg)) {
/* FIXME: We only support 2-way mirrors in RAID10 currently */
copies = 2;
for (i = 0; i < raid_seg->area_count * copies; i++) {
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index aa18224..a14f9d0 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -80,6 +80,20 @@ struct dev_manager;
#define segtype_is_mirror(segtype) ((segtype)->flags & SEG_MIRROR ? 1 : 0)
#define segtype_is_pool(segtype) ((segtype)->flags & (SEG_CACHE_POOL | SEG_THIN_POOL) ? 1 : 0)
#define segtype_is_raid(segtype) ((segtype)->flags & SEG_RAID ? 1 : 0)
+#define segtype_is_raid1(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID1))
+#define segtype_is_raid4(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID4))
+#define segtype_is_raid5(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5))
+#define segtype_is_any_raid5(segtype) (!strncmp((segtype)->name, SEG_TYPE_NAME_RAID5, strlen(SEG_TYPE_NAME_RAID5)))
+#define segtype_is_raid5_la(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_LA))
+#define segtype_is_raid5_ra(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_RA))
+#define segtype_is_raid5_ls(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_LS))
+#define segtype_is_raid5_rs(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_RS))
+#define segtype_is_any_raid6(segtype) (!strncmp((segtype)->name, SEG_TYPE_NAME_RAID6, strlen(SEG_TYPE_NAME_RAID6)))
+#define segtype_is_raid6_zr(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_ZR))
+#define segtype_is_raid6_nr(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_NR))
+#define segtype_is_raid6_nc(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_NC))
+#define segtype_is_raid10(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID10))
+#define segtype_is_snapshot(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_SNAPSHOT))
#define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
#define segtype_is_thin(segtype) ((segtype)->flags & (SEG_THIN_POOL|SEG_THIN_VOLUME) ? 1 : 0)
#define segtype_is_thin_pool(segtype) ((segtype)->flags & SEG_THIN_POOL ? 1 : 0)
@@ -94,6 +108,19 @@ struct dev_manager;
#define seg_is_mirrored(seg) segtype_is_mirrored((seg)->segtype)
#define seg_is_pool(seg) segtype_is_pool((seg)->segtype)
#define seg_is_raid(seg) segtype_is_raid((seg)->segtype)
+#define seg_is_raid1(seg) segtype_is_raid1((seg)->segtype)
+#define seg_is_raid4(seg) segtype_is_raid4((seg)->segtype)
+#define seg_is_raid5(seg) segtype_is_raid5((seg)->segtype)
+#define seg_is_any_raid5(seg) segtype_is_any_raid5((seg)->segtype)
+#define seg_is_raid5_la(seg) segtype_is_raid5_la((seg)->segtype)
+#define seg_is_raid5_ra(seg) segtype_is_raid5_ra((seg)->segtype)
+#define seg_is_raid5_ls(seg) segtype_is_raid5_ls((seg)->segtype)
+#define seg_is_raid5_rs(seg) segtype_is_raid5_rs((seg)->segtype)
+#define seg_is_any_raid6(seg) segtype_is_any_raid6((seg)->segtype)
+#define seg_is_raid6_zr(seg) segtype_is_raid6_zr((seg)->segtype)
+#define seg_is_raid6_nr(seg) segtype_is_raid6_nr((seg)->segtype)
+#define seg_is_raid6_nc(seg) segtype_is_raid6_nc((seg)->segtype)
+#define seg_is_raid10(seg) segtype_is_raid10((seg)->segtype)
#define seg_is_replicator(seg) ((seg)->segtype->flags & SEG_REPLICATOR ? 1 : 0)
#define seg_is_replicator_dev(seg) ((seg)->segtype->flags & SEG_REPLICATOR_DEV ? 1 : 0)
#define seg_is_snapshot(seg) ((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 290a590..13b9b6e 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -242,7 +242,7 @@ static int _raid_add_target_line(struct dev_manager *dm __attribute__((unused)),
/* RAID 4/5/6 */
params.mirrors = 1;
params.stripes = seg->area_count - seg->segtype->parity_devs;
- } else if (strcmp(seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ } else if (seg_is_raid10(seg)) {
/* RAID 10 only supports 2 mirrors now */
params.mirrors = 2;
params.stripes = seg->area_count / 2;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index e24c07a..bd34d11 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -731,7 +731,7 @@ static int _lvchange_writemostly(struct logical_volume *lv)
struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *raid_seg = first_seg(lv);
- if (strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID1)) {
+ if (!seg_is_raid1(raid_seg)) {
log_error("--write%s can only be used with 'raid1' segment type",
arg_count(cmd, writemostly_ARG) ? "mostly" : "behind");
return 0;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index e19ae01..80c336a 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -453,7 +453,7 @@ static int _read_mirror_params(struct cmd_context *cmd,
static int _read_raid_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- if ((lp->stripes < 2) && !strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ if ((lp->stripes < 2) && segtype_is_raid10(lp->segtype)) {
if (arg_count(cmd, stripes_ARG)) {
/* User supplied the bad argument */
log_error("Segment type 'raid10' requires 2 or more stripes.");
@@ -468,15 +468,14 @@ static int _read_raid_params(struct cmd_context *cmd,
* RAID1 does not take a stripe arg
*/
if ((lp->stripes > 1) && seg_is_mirrored(lp) &&
- strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ !segtype_is_raid10(lp->segtype)) {
log_error("Stripe argument cannot be used with segment type, %s",
lp->segtype->name);
return 0;
}
if (arg_count(cmd, mirrors_ARG) && segtype_is_raid(lp->segtype) &&
- strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID1) &&
- strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ !segtype_is_raid1(lp->segtype) && !segtype_is_raid10(lp->segtype)) {
log_error("Mirror argument cannot be used with segment type, %s",
lp->segtype->name);
return 0;
@@ -512,7 +511,7 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
return 0;
}
- if ((lp->mirrors > 2) && !strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ if ((lp->mirrors > 2) && segtype_is_raid10(lp->segtype)) {
/*
* FIXME: When RAID10 is no longer limited to
* 2-way mirror, 'lv_mirror_count()'
@@ -974,8 +973,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
return 0;
}
- if (!strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10) &&
- !(lp->target_attr & RAID_FEATURE_RAID10)) {
+ if (segtype_is_raid10(lp->segtype) && !(lp->target_attr & RAID_FEATURE_RAID10)) {
log_error("RAID module does not support RAID10.");
return 0;
}
@@ -1215,7 +1213,7 @@ static int _check_raid_parameters(struct volume_group *vg,
lp->segtype->name);
return 0;
}
- } else if (!strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ } else if (segtype_is_raid10(lp->segtype)) {
if (!arg_count(cmd, stripes_ARG))
lp->stripes = devs / lp->mirrors;
if (lp->stripes < 2) {
8 years, 7 months
master - style: lv_manip.c changes
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=41fe225b0deece...
Commit: 41fe225b0deecea871354b321d23fad548857518
Parent: 1945a0f50415c024d706d29c39604347c4de883d
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Sep 24 13:43:58 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 13:43:58 2015 +0100
style: lv_manip.c changes
---
lib/metadata/lv_manip.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 808b630..69a6b6e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1585,7 +1585,7 @@ static int _sufficient_pes_free(struct alloc_handle *ah, struct dm_list *pvms,
{
uint32_t area_extents_needed = (extents_still_needed - allocated) * ah->area_count / ah->area_multiple;
uint32_t parity_extents_needed = (extents_still_needed - allocated) * ah->parity_count / ah->area_multiple;
- uint32_t metadata_extents_needed = (ah->alloc_and_split_meta) ? 0 : ah->metadata_area_count * RAID_METADATA_AREA_LEN; /* One each */
+ uint32_t metadata_extents_needed = ah->alloc_and_split_meta ? 0 : ah->metadata_area_count * RAID_METADATA_AREA_LEN; /* One each */
uint32_t total_extents_needed = area_extents_needed + parity_extents_needed + metadata_extents_needed;
uint32_t free_pes = pv_maps_size(pvms);
@@ -1728,9 +1728,9 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status,
struct lv_segment *seg;
area_multiple = _calc_area_multiple(segtype, area_count, 0);
+ extents = aa[0].len * area_multiple;
- if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count,
- aa[0].len * area_multiple,
+ if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents,
status, stripe_size, NULL,
area_count,
aa[0].len, 0u, region_size, 0u, NULL))) {
@@ -4549,7 +4549,7 @@ static int _lvresize_poolmetadata(struct cmd_context *cmd, struct volume_group *
struct dm_list *pvh)
{
struct logical_volume *lv = first_seg(pool_lv)->metadata_lv;
- alloc_policy_t alloc = lp->ac_alloc ?: lv->alloc;
+ alloc_policy_t alloc = lp->ac_alloc ? : lv->alloc;
struct lv_segment *mseg = last_seg(lv);
uint32_t seg_mirrors = lv_mirror_count(lv);
@@ -5158,7 +5158,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
/* Switch to layered LV resizing */
lv = seg_lv(seg, 0);
}
- alloc = lp->ac_alloc ?: lv->alloc;
+ alloc = lp->ac_alloc ? : lv->alloc;
if ((lp->resize == LV_REDUCE) && lp->argc)
log_print_unless_silent("Ignoring PVs on command line when reducing.");
8 years, 7 months
master - libdm: fix bogus macro causing false parameter count
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1945a0f50415c0...
Commit: 1945a0f50415c024d706d29c39604347c4de883d
Parent: 4e60e6244456785c88dcd5bc0998a348a639c17b
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Sep 24 14:22:52 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Sep 24 14:22:52 2015 +0200
libdm: fix bogus macro causing false parameter count
---
libdm/libdm-deptree.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 7bc098f..b5067f5 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2371,7 +2371,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
}
/* Is parameter non-zero? */
-#define PARAM_IS_SET(p) (p) ? 1 : 0
+#define PARAM_IS_SET(p) ((p) ? 1 : 0)
/* Return number of bits assuming 4 * 64 bit size */
static int _get_params_count(uint64_t bits)
8 years, 7 months
master - raid: Fix raid target write_behind parameter.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e60e624445678...
Commit: 4e60e6244456785c88dcd5bc0998a348a639c17b
Parent: 96a621019871c5fcde42aeae9df465231302b859
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Sep 23 15:53:27 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 23 15:53:27 2015 +0100
raid: Fix raid target write_behind parameter.
Now uses correct "max_write_behind" instead of "writebehind".
(Includes some tidying up.)
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 27 +++++++++++++++------------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f198a50..b665bbc 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Correct use of max_write_behind parameter when generating raid target line.
Fix dm-event systemd service to make sure it is executed before mounting.
Version 1.02.109 - 22nd September 2016
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 1a66d98..7bc098f 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2014 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -86,7 +86,7 @@ static const struct {
{ SEG_RAID6_NC, "raid6_nc"},
/*
- *WARNING: Since 'raid' target overloads this 1:1 mapping table
+ * WARNING: Since 'raid' target overloads this 1:1 mapping table
* for search do not add new enum elements past them!
*/
{ SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */
@@ -2369,7 +2369,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
return 1;
}
-
+
/* Is parameter non-zero? */
#define PARAM_IS_SET(p) (p) ? 1 : 0
@@ -2396,9 +2396,12 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if ((seg->flags & DM_NOSYNC) || (seg->flags & DM_FORCESYNC))
param_count++;
- param_count += 2 * (PARAM_IS_SET(seg->region_size) + PARAM_IS_SET(seg->writebehind) +
- PARAM_IS_SET(seg->min_recovery_rate) + PARAM_IS_SET(seg->max_recovery_rate));
+ param_count += 2 * (PARAM_IS_SET(seg->region_size) +
+ PARAM_IS_SET(seg->writebehind) +
+ PARAM_IS_SET(seg->min_recovery_rate) +
+ PARAM_IS_SET(seg->max_recovery_rate));
+ /* rebuilds and writemostly are 64 bits */
param_count += _get_params_count(seg->rebuilds);
param_count += _get_params_count(seg->writemostly);
@@ -2420,13 +2423,6 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if (seg->rebuilds & (1ULL << i))
EMIT_PARAMS(pos, " rebuild %u", i);
- for (i = 0; i < (seg->area_count / 2); i++)
- if (seg->writemostly & (1ULL << i))
- EMIT_PARAMS(pos, " write_mostly %u", i);
-
- if (seg->writebehind)
- EMIT_PARAMS(pos, " writebehind %u", seg->writebehind);
-
if (seg->min_recovery_rate)
EMIT_PARAMS(pos, " min_recovery_rate %u",
seg->min_recovery_rate);
@@ -2435,6 +2431,13 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
EMIT_PARAMS(pos, " max_recovery_rate %u",
seg->max_recovery_rate);
+ for (i = 0; i < (seg->area_count / 2); i++)
+ if (seg->writemostly & (1ULL << i))
+ EMIT_PARAMS(pos, " write_mostly %u", i);
+
+ if (seg->writebehind)
+ EMIT_PARAMS(pos, " max_write_behind %u", seg->writebehind);
+
/* Print number of metadata/data device pairs */
EMIT_PARAMS(pos, " %u", seg->area_count/2);
8 years, 7 months
master - raid: Fix raid target write_behind parameter.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6747665bd7cc9b...
Commit: 6747665bd7cc9b8e332f48aa4be56716876f5231
Parent: 96a621019871c5fcde42aeae9df465231302b859
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 23 15:43:00 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 23 15:43:00 2015 +0100
raid: Fix raid target write_behind parameter.
Now uses correct "write_behind" instead of "writebehind".
Patch also includes some tidying up.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 15 +++++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f198a50..52dfc01 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Correct use of write_behind parameter when generating raid target line.
Fix dm-event systemd service to make sure it is executed before mounting.
Version 1.02.109 - 22nd September 2016
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 1a66d98..cba4ea0 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2014 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -86,7 +86,7 @@ static const struct {
{ SEG_RAID6_NC, "raid6_nc"},
/*
- *WARNING: Since 'raid' target overloads this 1:1 mapping table
+ * WARNING: Since 'raid' target overloads this 1:1 mapping table
* for search do not add new enum elements past them!
*/
{ SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */
@@ -2369,7 +2369,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
return 1;
}
-
+
/* Is parameter non-zero? */
#define PARAM_IS_SET(p) (p) ? 1 : 0
@@ -2396,9 +2396,12 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if ((seg->flags & DM_NOSYNC) || (seg->flags & DM_FORCESYNC))
param_count++;
- param_count += 2 * (PARAM_IS_SET(seg->region_size) + PARAM_IS_SET(seg->writebehind) +
- PARAM_IS_SET(seg->min_recovery_rate) + PARAM_IS_SET(seg->max_recovery_rate));
+ param_count += 2 * (PARAM_IS_SET(seg->region_size) +
+ PARAM_IS_SET(seg->writebehind) +
+ PARAM_IS_SET(seg->min_recovery_rate) +
+ PARAM_IS_SET(seg->max_recovery_rate));
+ /* rebuilds and writemostly are 64 bits */
param_count += _get_params_count(seg->rebuilds);
param_count += _get_params_count(seg->writemostly);
@@ -2425,7 +2428,7 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
EMIT_PARAMS(pos, " write_mostly %u", i);
if (seg->writebehind)
- EMIT_PARAMS(pos, " writebehind %u", seg->writebehind);
+ EMIT_PARAMS(pos, " write_behind %u", seg->writebehind);
if (seg->min_recovery_rate)
EMIT_PARAMS(pos, " min_recovery_rate %u",
8 years, 7 months
master - libdm: Improve raid segment parameter handling.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96a621019871c5...
Commit: 96a621019871c5fcde42aeae9df465231302b859
Parent: 192d9ad97769f2c16f3ebe67e51cfb287e67f67c
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Sep 23 15:25:46 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 23 15:25:46 2015 +0100
libdm: Improve raid segment parameter handling.
---
libdm/libdm-deptree.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index cc00014..1a66d98 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2369,6 +2369,20 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
return 1;
}
+
+/* Is parameter non-zero? */
+#define PARAM_IS_SET(p) (p) ? 1 : 0
+
+/* Return number of bits assuming 4 * 64 bit size */
+static int _get_params_count(uint64_t bits)
+{
+ int r = 0;
+
+ r += 2 * hweight32(bits & 0xFFFFFFFF);
+ r += 2 * hweight32(bits >> 32);
+
+ return r;
+}
static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
uint32_t minor, struct load_segment *seg,
@@ -2382,25 +2396,11 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if ((seg->flags & DM_NOSYNC) || (seg->flags & DM_FORCESYNC))
param_count++;
- if (seg->region_size)
- param_count += 2;
-
- if (seg->writebehind)
- param_count += 2;
-
- if (seg->min_recovery_rate)
- param_count += 2;
-
- if (seg->max_recovery_rate)
- param_count += 2;
-
- /* rebuilds is 64-bit */
- param_count += 2 * hweight32(seg->rebuilds & 0xFFFFFFFF);
- param_count += 2 * hweight32(seg->rebuilds >> 32);
+ param_count += 2 * (PARAM_IS_SET(seg->region_size) + PARAM_IS_SET(seg->writebehind) +
+ PARAM_IS_SET(seg->min_recovery_rate) + PARAM_IS_SET(seg->max_recovery_rate));
- /* rebuilds is 64-bit */
- param_count += 2 * hweight32(seg->writemostly & 0xFFFFFFFF);
- param_count += 2 * hweight32(seg->writemostly >> 32);
+ param_count += _get_params_count(seg->rebuilds);
+ param_count += _get_params_count(seg->writemostly);
if ((seg->type == SEG_RAID1) && seg->stripe_size)
log_error("WARNING: Ignoring RAID1 stripe size");
8 years, 7 months