[sheepdog-users] [PATCH stable-0.7] object cache: fix a wrong conversion assignment

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Jan 6 08:31:08 CET 2014


From: Liu Yuan <namei.unix at gmail.com>

If we assign the integer to a wider one, the width of that integer isn't
automatically converted and then we'll get a partial valume.

This fix following problem:

sheep -w size=1T # which will overflow a 32bit integer
dog vdi cache info # will get a wrong value

Reviewed-by: Robin Dong <sanbai at taobao.com>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/object_cache.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 1f8822e..0282135 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1407,8 +1407,8 @@ int object_cache_get_info(struct object_cache_info *info)
 {
 	int j = 0;
 
-	info->used = gcache.capacity * 1024 * 1024;
-	info->size = sys->object_cache_size * 1024 * 1024;
+	info->used = (uint64_t)gcache.capacity * 1024 * 1024;
+	info->size = (uint64_t)sys->object_cache_size * 1024 * 1024;
 
 	for (int i = 0; i < HASH_SIZE; i++) {
 		struct hlist_head *head = cache_hashtable + i;
-- 
1.7.10.4




More information about the sheepdog-users mailing list