From 79d214032b21074709cd24669f53b5e24c5c377d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 19 Apr 2018 17:38:04 +0200 Subject: [PATCH] mirror: validate region_size for mirrors Check for region size properties of mirror segments. --- WHATS_NEW | 1 + lib/metadata/merge.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 434f4a0ff..2d085a153 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.178 - ===================================== + Extend validation of region_size for mirror segment. Reload whole device stack when reinitilizing mirror log. Mirrors without monitoring are WARNING and not blocking on error. Detect too big region_size with clustered mirrors. diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index f0da2fe2d..90b40e264 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -391,6 +391,14 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg, if (!(seg2 = first_seg(seg->log_lv)) || (find_mirror_seg(seg2) != seg)) seg_error("log LV does not point back to mirror segment"); } + if (seg_is_mirror(seg)) { + if (!seg->region_size) + seg_error("region size is zero"); + else if (seg->region_size > seg->lv->size) + seg_error("region size is bigger then LV itself"); + else if (!is_power_of_2(seg->region_size)) + seg_error("region size is non power of 2"); + } } else { /* !mirrored */ if (seg->log_lv) { if (lv_is_raid_image(lv))