mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-08 08:58:50 +03:00
raid: Use loop for text uint32_t parameter import.
Plus some other tidying up of the same file.
This commit is contained in:
parent
7097663ddd
commit
9d815e5f5a
@ -55,7 +55,7 @@ static int _raid_text_import_areas(struct lv_segment *seg,
|
|||||||
const struct dm_config_value *cv)
|
const struct dm_config_value *cv)
|
||||||
{
|
{
|
||||||
unsigned int s;
|
unsigned int s;
|
||||||
struct logical_volume *lv1;
|
struct logical_volume *lv;
|
||||||
const char *seg_name = dm_config_parent_name(sn);
|
const char *seg_name = dm_config_parent_name(sn);
|
||||||
|
|
||||||
if (!seg->area_count) {
|
if (!seg->area_count) {
|
||||||
@ -75,23 +75,23 @@ static int _raid_text_import_areas(struct lv_segment *seg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Metadata device comes first */
|
/* Metadata device comes first */
|
||||||
if (!(lv1 = find_lv(seg->lv->vg, cv->v.str))) {
|
if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
|
||||||
log_error("Couldn't find volume '%s' for segment '%s'.",
|
log_error("Couldn't find volume '%s' for segment '%s'.",
|
||||||
cv->v.str ? : "NULL", seg_name);
|
cv->v.str ? : "NULL", seg_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!set_lv_segment_area_lv(seg, s, lv1, 0, RAID_META))
|
if (!set_lv_segment_area_lv(seg, s, lv, 0, RAID_META))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* Data device comes second */
|
/* Data device comes second */
|
||||||
cv = cv->next;
|
cv = cv->next;
|
||||||
if (!(lv1 = find_lv(seg->lv->vg, cv->v.str))) {
|
if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
|
||||||
log_error("Couldn't find volume '%s' for segment '%s'.",
|
log_error("Couldn't find volume '%s' for segment '%s'.",
|
||||||
cv->v.str ? : "NULL", seg_name);
|
cv->v.str ? : "NULL", seg_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!set_lv_segment_area_lv(seg, s, lv1, 0, RAID_IMAGE))
|
if (!set_lv_segment_area_lv(seg, s, lv, 0, RAID_IMAGE))
|
||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -111,49 +111,28 @@ static int _raid_text_import(struct lv_segment *seg,
|
|||||||
struct dm_hash_table *pv_hash)
|
struct dm_hash_table *pv_hash)
|
||||||
{
|
{
|
||||||
const struct dm_config_value *cv;
|
const struct dm_config_value *cv;
|
||||||
|
const struct {
|
||||||
|
const char *name;
|
||||||
|
uint32_t *var;
|
||||||
|
} raid_attr_import[] = {
|
||||||
|
{ "region_size", &seg->region_size },
|
||||||
|
{ "stripe_size", &seg->stripe_size },
|
||||||
|
{ "writebehind", &seg->writebehind },
|
||||||
|
{ "min_recovery_rate", &seg->min_recovery_rate },
|
||||||
|
{ "max_recovery_rate", &seg->max_recovery_rate },
|
||||||
|
}, *aip = raid_attr_import;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (dm_config_has_node(sn, "region_size")) {
|
for (i = 0; i < DM_ARRAY_SIZE(raid_attr_import); i++, aip++) {
|
||||||
if (!dm_config_get_uint32(sn, "region_size", &seg->region_size)) {
|
if (dm_config_has_node(sn, aip->name)) {
|
||||||
log_error("Couldn't read 'region_size' for "
|
if (!dm_config_get_uint32(sn, aip->name, aip->var)) {
|
||||||
"segment %s of logical volume %s.",
|
log_error("Couldn't read '%s' for segment %s of logical volume %s.",
|
||||||
dm_config_parent_name(sn), seg->lv->name);
|
aip->name, dm_config_parent_name(sn), seg->lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (dm_config_has_node(sn, "stripe_size")) {
|
|
||||||
if (!dm_config_get_uint32(sn, "stripe_size", &seg->stripe_size)) {
|
|
||||||
log_error("Couldn't read 'stripe_size' for "
|
|
||||||
"segment %s of logical volume %s.",
|
|
||||||
dm_config_parent_name(sn), seg->lv->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dm_config_has_node(sn, "writebehind")) {
|
|
||||||
if (!dm_config_get_uint32(sn, "writebehind", &seg->writebehind)) {
|
|
||||||
log_error("Couldn't read 'writebehind' for "
|
|
||||||
"segment %s of logical volume %s.",
|
|
||||||
dm_config_parent_name(sn), seg->lv->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dm_config_has_node(sn, "min_recovery_rate")) {
|
|
||||||
if (!dm_config_get_uint32(sn, "min_recovery_rate",
|
|
||||||
&seg->min_recovery_rate)) {
|
|
||||||
log_error("Couldn't read 'min_recovery_rate' for "
|
|
||||||
"segment %s of logical volume %s.",
|
|
||||||
dm_config_parent_name(sn), seg->lv->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dm_config_has_node(sn, "max_recovery_rate")) {
|
|
||||||
if (!dm_config_get_uint32(sn, "max_recovery_rate",
|
|
||||||
&seg->max_recovery_rate)) {
|
|
||||||
log_error("Couldn't read 'max_recovery_rate' for "
|
|
||||||
"segment %s of logical volume %s.",
|
|
||||||
dm_config_parent_name(sn), seg->lv->name);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_config_get_list(sn, "raids", &cv)) {
|
if (!dm_config_get_list(sn, "raids", &cv)) {
|
||||||
log_error("Couldn't find RAID array for "
|
log_error("Couldn't find RAID array for "
|
||||||
"segment %s of logical volume %s.",
|
"segment %s of logical volume %s.",
|
||||||
@ -162,7 +141,7 @@ static int _raid_text_import(struct lv_segment *seg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_raid_text_import_areas(seg, sn, cv)) {
|
if (!_raid_text_import_areas(seg, sn, cv)) {
|
||||||
log_error("Failed to import RAID images");
|
log_error("Failed to import RAID component pairs.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user