WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] blktap: fix and use ROUNDUP macro (bug 14

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktap: fix and use ROUNDUP macro (bug 1430 part 1)
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Jun 2009 10:25:14 -0700
Delivery-date: Thu, 04 Jun 2009 10:25:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1244023864 -3600
# Node ID f989778298d8074ad9135f3a538d449b6baab947
# Parent  e7b63b30ae3da2c3184dfa6fc00a816f90a158d5
blktap: fix and use ROUNDUP macro (bug 1430 part 1)

As pointed out in Xen Bugzilla 1430 in the blktap QCOW driver the
rounding function is wrong in line 824 of block-qcow.c.
This patch replaces this (and other roundings) with the already
existing ROUNDUP macro (and fixes the usual macro pitfall).

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 tools/blktap/drivers/block-qcow.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff -r e7b63b30ae3d -r f989778298d8 tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Wed Jun 03 11:10:07 2009 +0100
+++ b/tools/blktap/drivers/block-qcow.c Wed Jun 03 11:11:04 2009 +0100
@@ -55,7 +55,7 @@
 #define ROUNDUP(l, s) \
 ({ \
     (uint64_t)( \
-        (l + (s - 1)) - ((l + (s - 1)) % s)); \
+        ((l) + ((s) - 1)) - (((l) + ((s) - 1)) % (s))); \
 })
 
 #undef IOCB_IDX
@@ -800,14 +800,14 @@ static int tdqcow_open (struct disk_driv
 
        /* read the level 1 table */
        shift = s->cluster_bits + s->l2_bits;
-       s->l1_size = (header->size + (1LL << shift) - 1) >> shift;
+       s->l1_size = ROUNDUP(header->size, 1LL << shift);
        
        s->l1_table_offset = header->l1_table_offset;
 
        /*allocate a 4Kbyte multiple of memory*/
        l1_table_size = s->l1_size * sizeof(uint64_t);
        if (l1_table_size % 4096 > 0) {
-               l1_table_size = ((l1_table_size >> 12) + 1) << 12;
+               l1_table_size = ROUNDUP(l1_table_size, 4096);
        }
        ret = posix_memalign((void **)&s->l1_table, 4096, l1_table_size);
        if (ret != 0) goto fail;
@@ -821,7 +821,7 @@ static int tdqcow_open (struct disk_driv
 
        lseek(fd, 0, SEEK_SET);
        l1_table_block = l1_table_size + s->l1_table_offset;
-       l1_table_block = l1_table_block + 512 - (l1_table_block % 512); 
+       l1_table_block = ROUNDUP(l1_table_block, 512);
        ret = posix_memalign((void **)&buf2, 4096, l1_table_block);
        if (ret != 0) goto fail;
        if (read(fd, buf2, l1_table_block) != l1_table_block)
@@ -1226,11 +1226,11 @@ int qcow_create(const char *filename, ui
        
        header_size = (header_size + 7) & ~7;
        if (header_size % 4096 > 0) {
-               header_size = ((header_size >> 12) + 1) << 12;
+               header_size = ROUNDUP(header_size, 4096);
        }
 
        shift = header.cluster_bits + header.l2_bits;
-       l1_size = ((size * 512) + (1LL << shift) - 1) >> shift;
+       l1_size = ROUNDUP(size * 512, 1LL << shift);
 
        header.l1_table_offset = cpu_to_be64(header_size);
        DPRINTF("L1 Table offset: %d, size %d\n",

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktap: fix and use ROUNDUP macro (bug 1430 part 1), Xen patchbot-unstable <=