mirror of
git://sourceware.org/git/lvm2.git
synced 2025-08-02 04:22:02 +03:00
segtypes: Add and use new segtype macros.
Includes fixing an inverted raid10 segtype check in _raid_add_target_line.
This commit is contained in:
@ -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;
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user