From df110bccbed2bc7f53355fcb16309eb2727ba483 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 3 Sep 2015 22:52:21 +0200 Subject: [PATCH] thin: validate mapped size of thin volume Never show we map more then 100% for a volume. But show warning when there could be some consistency problems. --- lib/thin/thin.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/thin/thin.c b/lib/thin/thin.c index c5f04f37f..7bf7f4e69 100644 --- a/lib/thin/thin.c +++ b/lib/thin/thin.c @@ -620,6 +620,15 @@ static int _thin_target_percent(void **target_state __attribute__((unused)), /* Pool allocates whole chunk so round-up to nearest one */ csize = first_seg(seg->pool_lv)->chunk_size; csize = ((seg->lv->size + csize - 1) / csize) * csize; + if (s->mapped_sectors > csize) { + log_warn("WARNING: LV %s maps %s while the size is only %s.", + display_lvname(seg->lv), + display_size(cmd, s->mapped_sectors), + display_size(cmd, csize)); + /* Don't show nonsense numbers like i.e. 1000% full */ + s->mapped_sectors = csize; + } + *percent = dm_make_percent(s->mapped_sectors, csize); *total_denominator += csize; } else {