1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cache: validation for cache_metadata_format

Only  cache-pool segtype may store cache_metadata_format.
Only supported values are 0,1,2
Format 2 requires LV status uses LV_METADATA_FORMAT.
Format 0 (unselected) or 1 shall not set this 'incompatible' status.
This commit is contained in:
Zdenek Kabelac 2017-02-26 21:22:43 +01:00
parent 825c16e57e
commit 64d3f05aa1

View File

@ -328,6 +328,13 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (seg_is_cache_pool(seg)) {
if (!dm_list_empty(&seg->lv->segs_using_this_lv)) {
switch (seg->cache_metadata_format) {
case CACHE_METADATA_FORMAT_2:
case CACHE_METADATA_FORMAT_1:
break;
default:
seg_error("has invalid cache metadata format");
}
switch (seg->cache_mode) {
case CACHE_MODE_WRITETHROUGH:
case CACHE_MODE_WRITEBACK:
@ -341,13 +348,22 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
}
if (!validate_cache_chunk_size(lv->vg->cmd, seg->chunk_size))
seg_error("has invalid chunk size.");
if (seg->lv->status & LV_METADATA_FORMAT) {
if (seg->cache_metadata_format != CACHE_METADATA_FORMAT_2)
seg_error("sets METADATA_FORMAT flag");
} else if (seg->cache_metadata_format == CACHE_METADATA_FORMAT_2)
seg_error("is missing METADATA_FORMAT flag");
} else { /* !cache_pool */
if (seg->cache_metadata_format)
seg_error("sets cache metadata format");
if (seg->cache_mode)
seg_error("sets cache mode");
if (seg->policy_name)
seg_error("sets policy name");
if (seg->policy_settings)
seg_error("sets policy settings");
if (seg->lv->status & LV_METADATA_FORMAT)
seg_error("sets METADATA_FORMAT flag");
}
if (!seg_can_error_when_full(seg) && lv_is_error_when_full(lv))