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

cache: enhance cache-pool validation

Capture cache-pool without cache policy name set.
This commit is contained in:
Zdenek Kabelac 2015-07-14 09:58:37 +02:00
parent 077645476c
commit c2d4330f27
2 changed files with 11 additions and 10 deletions

View File

@ -208,6 +208,12 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
}
}
if (seg_is_cache_pool(seg)) {
if (!seg->policy_name) {
log_error("LV %s is missing cache policy name.", lv->name);
inc_error_count;
}
}
if (seg_is_pool(seg)) {
if (seg->area_count != 1 ||
seg_type(seg, 0) != AREA_LV) {

View File

@ -1381,7 +1381,6 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
const struct lv_segment *seg = (const struct lv_segment *) data;
const char *cache_policy_name;
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
@ -1389,16 +1388,12 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, GET_FIRST_RESERVED_NAME(cache_policy_undef),
GET_FIELD_RESERVED_VALUE(cache_policy_undef));
if (seg->policy_name) {
if (!(cache_policy_name = dm_pool_strdup(mem, seg->policy_name))) {
log_error("dm_pool_strdup failed");
return 0;
}
return _field_set_value(field, cache_policy_name, NULL);
} else {
log_error(INTERNAL_ERROR "unexpected NULL policy name");
return_0;
if (!seg->policy_name) {
log_error(INTERNAL_ERROR "Unexpected NULL policy name.");
return 0;
}
return _field_set_value(field, seg->policy_name, NULL);
}
static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,