1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

raid: use feature attributes for raid10

Test raid10 availability as a target feature (instead of doing
it in all the places where raid10 should be checked).

TODO: activation needs runtime validation - so metadata with raid10
are skipped from activation in user-friendly way in lvm2.
This commit is contained in:
Zdenek Kabelac 2014-02-24 13:15:40 +01:00
parent 23c069d16f
commit 95fe823eba
4 changed files with 47 additions and 14 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
Enhance raid code with feature flags, for now checks for raid10.
Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99)
Avoid a PV label scan while in a critical section.
Remove (always 0) skip argument from lv_activation_skip().

View File

@ -67,6 +67,11 @@ enum {
THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND = (1 << 6),
};
/* raid target attribute flags */
enum {
RAID_FEATURE_RAID10 = (1 << 0), /* version 1.3 */
};
void set_activation(int activation);
int activation(void);

View File

@ -326,15 +326,45 @@ static int _raid_target_percent(void **target_state,
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes __attribute__((unused)))
unsigned *attributes)
{
/* List of features with their kernel target version */
static const struct feature {
uint32_t maj;
uint32_t min;
unsigned raid_feature;
const char *feature;
} const _features[] = {
{ 1, 3, RAID_FEATURE_RAID10, "raid10" },
};
static int _raid_checked = 0;
static int _raid_present = 0;
static int _raid_attrs = 0;
uint32_t maj, min, patchlevel;
unsigned i;
if (!_raid_checked)
if (!_raid_checked) {
_raid_present = target_present(cmd, "raid", 1);
_raid_checked = 1;
if (!target_version("raid", &maj, &min, &patchlevel)) {
log_error("Cannot read target version of RAID kernel module.");
return 0;
}
for (i = 0; i < sizeof(_features)/sizeof(*_features); i++)
if ((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min))
_raid_attrs |= _features[i].raid_feature;
else
log_very_verbose("Target raid does not support %s.",
_features[i].feature);
_raid_checked = 1;
}
if (attributes)
*attributes = _raid_attrs;
return _raid_present;
}

View File

@ -977,19 +977,16 @@ static int _lvcreate_params(struct lvcreate_params *lp,
}
}
if (activation() && lp->segtype->ops->target_present &&
!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
log_error("%s: Required device-mapper target(s) not "
"detected in your kernel", lp->segtype->name);
return 0;
} else if (!strcmp(lp->segtype->name, "raid10")) {
uint32_t maj, min, patchlevel;
if (!target_version("raid", &maj, &min, &patchlevel)) {
log_error("Failed to determine version of RAID kernel module");
if (activation() && lp->segtype->ops->target_present) {
if (!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
log_error("%s: Required device-mapper target(s) not detected in your kernel.",
lp->segtype->name);
return 0;
}
if ((maj != 1) || (min < 3)) {
log_error("RAID module does not support RAID10");
if ((strcmp(lp->segtype->name, "raid10") == 0) &&
!(lp->target_attr & RAID_FEATURE_RAID10)) {
log_error("RAID module does not support RAID10.");
return 0;
}
}