master - cache: add more validation
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=533ac4d47dcecc976c05ba503acff11b9546b67c Commit: 533ac4d47dcecc976c05ba503acff11b9546b67c Parent: f0c18fceb43d77b0a79685fc7b1c8bbe64df7e97 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Aug 11 15:11:45 2015 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Aug 12 14:33:14 2015 +0200
cache: add more validation
--- WHATS_NEW | 1 + lib/cache_segtype/cache.c | 3 +++ lib/metadata/lv_manip.c | 6 +++++- lib/metadata/merge.c | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.128 - =================================== + Check for valid cache mode in validation of cache segment. Enhance internal API cache_set_mode() and cache_set_policy(). Enhance toollib's get_cache_params(). Runtime detect presence of cache smq policy.
lib/cache_segtype/cache.c +3 -0
@@ -100,6 +100,9 @@ static int _cache_pool_text_import(struct lv_segment *seg,* If the policy is not present, default policy is used. */ if ((sn =dm_config_find_node (sn,"policy_settings" ))) { +if (!seg->policy_name) +return SEG_LOG_ERROR ("policy_settings must have a policy_name in" ); +if (sn->v)return SEG_LOG_ERROR ("policy_settings must be a section in" );
lib/metadata/lv_manip.c +5 -1
@@ -7074,7 +7074,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, display_lvname(origin_lv));return NULL ; } - }else if (pool_lv &&seg_is_cache (lp)) { + }else if (seg_is_cache (lp)) { +if (!pool_lv) { +log_error (INTERNAL_ERROR "Pool LV for cache is missing." ); +return NULL ; + }if (!lv_is_cache_pool (pool_lv)) {log_error ("Logical volume %s is not a cache pool." ,display_lvname (pool_lv));
lib/metadata/merge.c +15 -1
@@ -208,7 +208,21 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) } } -if (seg_is_cache_pool (seg)) { +if (seg_is_cache_pool (seg) && + !dm_list_empty (&seg->lv->segs_using_this_lv)) { +switch (seg->feature_flags & + (DM_CACHE_FEATURE_PASSTHROUGH | +DM_CACHE_FEATURE_WRITETHROUGH | +DM_CACHE_FEATURE_WRITEBACK )) { +case DM_CACHE_FEATURE_PASSTHROUGH : +case DM_CACHE_FEATURE_WRITETHROUGH : +case DM_CACHE_FEATURE_WRITEBACK : +break ; +default : +log_error ("LV %s has invalid cache's feature flag." , + lv->name); + inc_error_count; + }if (!seg->policy_name) {log_error ("LV %s is missing cache policy name." , lv->name); inc_error_count;