]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
Xen, mapcache: Fix the compute of the size of bucket.
authorAnthony PERARD <anthony.perard@citrix.com>
Fri, 13 Apr 2012 17:18:56 +0000 (17:18 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Tue, 17 Apr 2012 10:12:53 +0000 (10:12 +0000)
Because the size of a mapping is wrong when there is an offset and a
size >= bucket_size.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
xen-mapcache.c

index d5f52b2cba914871a19d0c68aaa63cb4bae24c2f..eade81632dcba6ef147a066448ab8c03c83318cc 100644 (file)
@@ -214,12 +214,14 @@ tryagain:
     }
 
     /* size is always a multiple of MCACHE_BUCKET_SIZE */
-    if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE)
-        __size += MCACHE_BUCKET_SIZE;
-    if (__size % MCACHE_BUCKET_SIZE)
-        __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE);
-    if (!__size)
+    if (size) {
+        __size = size + address_offset;
+        if (__size % MCACHE_BUCKET_SIZE) {
+            __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE);
+        }
+    } else {
         __size = MCACHE_BUCKET_SIZE;
+    }
 
     entry = &mapcache->entry[address_index % mapcache->nr_buckets];