aboutsummaryrefslogtreecommitdiff
path: root/xen-mapcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'xen-mapcache.c')
-rw-r--r--xen-mapcache.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/xen-mapcache.c b/xen-mapcache.c
index a456479..75ac313 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -216,12 +216,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];