Skip to contentSkip to conversation

master - cache: avoid expression overflow

PATCH Zdenek Kabelac 1 participant 1 message May 7, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=48a8cf28f751156471a3fc65650fc600cd24833c
Commit:        48a8cf28f751156471a3fc65650fc600cd24833c
Parent:        e585a6bbcf8416f5eeb6b57e0b02ca5e52f23f96
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Wed May 7 11:12:05 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed May 7 14:14:54 2014 +0200

cache: avoid expression overflow

Cast data_extents to 64bit so calculation is in 64b arithmetic.

---
 WHATS_NEW                  |    1 +
 lib/metadata/cache_manip.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
index f0c36cb..88ae713 100644
@@ -1,5 +1,6 @@
 Version 2.02.107 - 
 ==================================
+  Use proper uint64 casting for calculation of cache metadata size.
   Better support for nesting of blocking signals.
   Use only sigaction handler and drop duplicate signal handler.
   Separate signal handling and flock code out into lib/misc.
lib/metadata/cache_manip.c +1 -1
index 9a055e8..deae6f2 100644
@@ -57,7 +57,7 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
 	 * ... plus a good amount of padding (2x) to cover any
 	 * policy hint data that may be added in the future.
 	 */
-	min_meta_size = 16 * (data_extents * vg->extent_size);
+	min_meta_size = (uint64_t)data_extents * vg->extent_size * 16;
 	min_meta_size /= *chunk_size; /* # of Bytes we need */
 	min_meta_size *= 2;              /* plus some padding */
 	min_meta_size /= 512;            /* in sectors */