9ae3a8
From 68dbc9269577747455be55f209066926d1994d3c Mon Sep 17 00:00:00 2001
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Date: Sat, 8 Feb 2014 10:42:18 +0100
9ae3a8
Subject: [PATCH 22/37] block: Fix 32 bit truncation in mark_request_serialising()
9ae3a8
9ae3a8
Message-id: <1392117622-28812-23-git-send-email-kwolf@redhat.com>
9ae3a8
Patchwork-id: 57187
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 22/37] block: Fix 32 bit truncation in mark_request_serialising()
9ae3a8
Bugzilla: 748906
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
On 32 bit hosts, size_t is too small for align as the bitmask
9ae3a8
~(align - 1) will zero out the higher 32 bits of the offset.
9ae3a8
9ae3a8
While at it, change the local overlap_bytes variable to unsigned to
9ae3a8
match the field in BdrvTrackedRequest.
9ae3a8
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
---
9ae3a8
 block.c | 6 +++---
9ae3a8
 1 file changed, 3 insertions(+), 3 deletions(-)
9ae3a8
---
9ae3a8
 block.c |    6 +++---
9ae3a8
 1 files changed, 3 insertions(+), 3 deletions(-)
9ae3a8
9ae3a8
diff --git a/block.c b/block.c
9ae3a8
index 24e94e6..94fd702 100644
9ae3a8
--- a/block.c
9ae3a8
+++ b/block.c
9ae3a8
@@ -2088,11 +2088,11 @@ static void tracked_request_begin(BdrvTrackedRequest *req,
9ae3a8
     QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
9ae3a8
 }
9ae3a8
 
9ae3a8
-static void mark_request_serialising(BdrvTrackedRequest *req, size_t align)
9ae3a8
+static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
9ae3a8
 {
9ae3a8
     int64_t overlap_offset = req->offset & ~(align - 1);
9ae3a8
-    int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
9ae3a8
-                      - overlap_offset;
9ae3a8
+    unsigned int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
9ae3a8
+                               - overlap_offset;
9ae3a8
 
9ae3a8
     if (!req->serialising) {
9ae3a8
         req->bs->serialising_in_flight++;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8